mirror of
https://github.com/DrBeef/Raze.git
synced 2025-02-22 11:41:08 +00:00
Lunatic: implement the non-local control flow needed for some commands.
git-svn-id: https://svn.eduke32.com/eduke32@3250 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
5b07f67627
commit
76b970e547
5 changed files with 42 additions and 6 deletions
|
@ -5112,6 +5112,7 @@ void A_Execute(int32_t iActor,int32_t iPlayer,int32_t lDist)
|
||||||
{
|
{
|
||||||
#ifdef LUNATIC
|
#ifdef LUNATIC
|
||||||
double t;
|
double t;
|
||||||
|
int32_t killit=0;
|
||||||
#endif
|
#endif
|
||||||
vmstate_t tempvm = { iActor, iPlayer, lDist, &actor[iActor].t_data[0],
|
vmstate_t tempvm = { iActor, iPlayer, lDist, &actor[iActor].t_data[0],
|
||||||
&sprite[iActor], 0
|
&sprite[iActor], 0
|
||||||
|
@ -5176,7 +5177,7 @@ void A_Execute(int32_t iActor,int32_t iPlayer,int32_t lDist)
|
||||||
t = gethitickms();
|
t = gethitickms();
|
||||||
|
|
||||||
if (L_IsInitialized(&g_ElState) && El_HaveActor(vm.g_sp->picnum))
|
if (L_IsInitialized(&g_ElState) && El_HaveActor(vm.g_sp->picnum))
|
||||||
El_CallActor(&g_ElState, vm.g_sp->picnum, iActor, iPlayer, lDist);
|
killit = (El_CallActor(&g_ElState, vm.g_sp->picnum, iActor, iPlayer, lDist)==1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
insptr = 4 + (g_tile[vm.g_sp->picnum].execPtr);
|
insptr = 4 + (g_tile[vm.g_sp->picnum].execPtr);
|
||||||
|
@ -5188,7 +5189,11 @@ void A_Execute(int32_t iActor,int32_t iPlayer,int32_t lDist)
|
||||||
g_actorCalls[vm.g_sp->picnum]++;
|
g_actorCalls[vm.g_sp->picnum]++;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (vm.g_flags & VM_KILL)
|
if ((vm.g_flags & VM_KILL)
|
||||||
|
#ifdef LUNATIC
|
||||||
|
|| killit
|
||||||
|
#endif
|
||||||
|
)
|
||||||
{
|
{
|
||||||
// if player was set to squish, first stop that...
|
// if player was set to squish, first stop that...
|
||||||
if (vm.g_p >= 0 && g_player[vm.g_p].ps->actorsqu == vm.g_i)
|
if (vm.g_p >= 0 && g_player[vm.g_p].ps->actorsqu == vm.g_i)
|
||||||
|
|
|
@ -159,6 +159,17 @@ end
|
||||||
|
|
||||||
--- Exported functions
|
--- Exported functions
|
||||||
|
|
||||||
|
-- Non-local control flow. These ones call the original error(), not our
|
||||||
|
-- redefinition in defs.ilua.
|
||||||
|
function longjmp()
|
||||||
|
error(false)
|
||||||
|
end
|
||||||
|
|
||||||
|
function killit()
|
||||||
|
-- TODO: guard against deletion of player sprite?
|
||||||
|
error(true)
|
||||||
|
end
|
||||||
|
|
||||||
-- The return value is true iff the ammo was at the weapon's max.
|
-- The return value is true iff the ammo was at the weapon's max.
|
||||||
-- In that case, no action is taken.
|
-- In that case, no action is taken.
|
||||||
function addammo(ps, weapon, amount)
|
function addammo(ps, weapon, amount)
|
||||||
|
|
|
@ -670,7 +670,8 @@ local Ci = {
|
||||||
-- these can appear anywhere in the script
|
-- these can appear anywhere in the script
|
||||||
["break"] = cmd()
|
["break"] = cmd()
|
||||||
/ "do return end", -- TODO: more exact semantics
|
/ "do return end", -- TODO: more exact semantics
|
||||||
["return"] = cmd(),
|
["return"] = cmd()
|
||||||
|
/ "_con.longjmp()", -- TODO: test with code from Wiki "return" entry
|
||||||
|
|
||||||
state = cmd(I)
|
state = cmd(I)
|
||||||
/ "%1()", -- TODO: mangle names
|
/ "%1()", -- TODO: mangle names
|
||||||
|
@ -846,7 +847,7 @@ local Ci = {
|
||||||
getlastpal = cmd(),
|
getlastpal = cmd(),
|
||||||
insertspriteq = cmd(),
|
insertspriteq = cmd(),
|
||||||
killit = cmd()
|
killit = cmd()
|
||||||
/ "do return 2 end", -- exec SPECIAL HANDLING!
|
/ "_con.killit()", -- exec SPECIAL HANDLING!
|
||||||
mikesnd = cmd(),
|
mikesnd = cmd(),
|
||||||
nullop = cmd(),
|
nullop = cmd(),
|
||||||
pkick = cmd(),
|
pkick = cmd(),
|
||||||
|
|
|
@ -190,10 +190,17 @@ int32_t El_CallEvent(L_State *estate, int32_t eventidx, int32_t iActor, int32_t
|
||||||
|
|
||||||
if (i == LUA_ERRRUN)
|
if (i == LUA_ERRRUN)
|
||||||
{
|
{
|
||||||
|
if (lua_isboolean(L, -1))
|
||||||
|
{
|
||||||
|
lua_pop(L, 1);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Bassert(lua_type(L, -1)==LUA_TSTRING);
|
||||||
OSD_Printf("event \"%s\" (state \"%s\") runtime error: %s\n", EventNames[eventidx].text,
|
OSD_Printf("event \"%s\" (state \"%s\") runtime error: %s\n", EventNames[eventidx].text,
|
||||||
estate->name, lua_tostring(L, -1)); // get err msg
|
estate->name, lua_tostring(L, -1)); // get err msg
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
return 4;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -207,10 +214,18 @@ int32_t El_CallActor(L_State *estate, int32_t actortile, int32_t iActor, int32_t
|
||||||
|
|
||||||
if (i == LUA_ERRRUN)
|
if (i == LUA_ERRRUN)
|
||||||
{
|
{
|
||||||
|
if (lua_isboolean(L, -1))
|
||||||
|
{
|
||||||
|
int32_t killit = lua_toboolean(L, -1);
|
||||||
|
lua_pop(L, 1);
|
||||||
|
return killit;
|
||||||
|
}
|
||||||
|
|
||||||
|
Bassert(lua_type(L, -1)==LUA_TSTRING);
|
||||||
OSD_Printf("actor %d (sprite %d, state \"%s\") runtime error: %s\n", actortile, iActor,
|
OSD_Printf("actor %d (sprite %d, state \"%s\") runtime error: %s\n", actortile, iActor,
|
||||||
estate->name, lua_tostring(L, -1)); // get err msg
|
estate->name, lua_tostring(L, -1)); // get err msg
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
return 4;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -266,6 +266,10 @@ gameactor(1680, -- LIZTROOP
|
||||||
-- Duke Vader / Anakin Nukewalker?
|
-- Duke Vader / Anakin Nukewalker?
|
||||||
actor[i]:set_action("TROOPFLINTCH")
|
actor[i]:set_action("TROOPFLINTCH")
|
||||||
actor[i]:set_move("SHRUNKVELS")
|
actor[i]:set_move("SHRUNKVELS")
|
||||||
|
|
||||||
|
if (dist < 1024) then
|
||||||
|
con.killit()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue