mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-14 08:30:58 +00:00
Lunatic: simplify RETURN handling, make its behavior across events same as C-CON.
There's only one RETURN value on the C side (g_RETURN), which is also referenced from Lua. Upon entering an event, its value takes on the per-event default one, and its value when the event code finishes is passed back to the game. Independently of that, its value is always saved and restored across event calls. git-svn-id: https://svn.eduke32.com/eduke32@3601 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
57416c541a
commit
c7d97d55ec
6 changed files with 29 additions and 30 deletions
|
@ -316,7 +316,9 @@ labels =
|
||||||
STR,
|
STR,
|
||||||
PROJ,
|
PROJ,
|
||||||
EVENT,
|
EVENT,
|
||||||
setmetatable(shallow_copy(SFLAG), { __metatable="noffiC" }),
|
-- setmetatable(
|
||||||
|
shallow_copy(SFLAG),
|
||||||
|
-- { __metatable="noffiC" }),
|
||||||
STAT,
|
STAT,
|
||||||
GAMEFUNC,
|
GAMEFUNC,
|
||||||
}
|
}
|
||||||
|
|
|
@ -518,6 +518,7 @@ ffi.cdef[[
|
||||||
const int32_t screenpeek;
|
const int32_t screenpeek;
|
||||||
hudweapon_t hudweap;
|
hudweapon_t hudweap;
|
||||||
int32_t g_logoFlags;
|
int32_t g_logoFlags;
|
||||||
|
int32_t g_RETURN; // deprecated from Lua
|
||||||
]]
|
]]
|
||||||
|
|
||||||
-- INTERNAL VARIABLES/FUNCTIONS
|
-- INTERNAL VARIABLES/FUNCTIONS
|
||||||
|
@ -528,7 +529,6 @@ const char *s_buildRev;
|
||||||
const char *g_sizes_of_what[];
|
const char *g_sizes_of_what[];
|
||||||
int32_t g_sizes_of[];
|
int32_t g_sizes_of[];
|
||||||
int32_t g_elCallDepth;
|
int32_t g_elCallDepth;
|
||||||
int32_t g_elEventRETURN;
|
|
||||||
const char **g_argv;
|
const char **g_argv;
|
||||||
char g_modDir[];
|
char g_modDir[];
|
||||||
actor_t actor[MAXSPRITES];
|
actor_t actor[MAXSPRITES];
|
||||||
|
@ -1143,8 +1143,8 @@ local camera_mt = {
|
||||||
gv_access.cam = setmtonce({}, camera_mt)
|
gv_access.cam = setmtonce({}, camera_mt)
|
||||||
gv_access._ud = ffiC.ud
|
gv_access._ud = ffiC.ud
|
||||||
|
|
||||||
-- Support for some CON global system gamevars
|
-- Support for some CON global system gamevars. RETURN handled separately.
|
||||||
gv_access._csv = ffi.new "struct { int32_t RETURN, LOTAG, HITAG, TEXTURE; }"
|
gv_access._csv = ffi.new "struct { int32_t LOTAG, HITAG, TEXTURE; }"
|
||||||
|
|
||||||
function gv_access._get_yxaspect()
|
function gv_access._get_yxaspect()
|
||||||
return ffiC.yxaspect
|
return ffiC.yxaspect
|
||||||
|
@ -1170,14 +1170,6 @@ function gv_access._set_guniqhudid(id)
|
||||||
ffiC.guniqhudid = id
|
ffiC.guniqhudid = id
|
||||||
end
|
end
|
||||||
|
|
||||||
function gv_access._RETURN(setval)
|
|
||||||
if (setval ~= nil) then
|
|
||||||
ffiC.g_elEventRETURN = setval
|
|
||||||
else
|
|
||||||
return ffiC.g_elEventRETURN
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- TODO: make return 1-based index
|
-- TODO: make return 1-based index
|
||||||
function gv_access.currentEpisode()
|
function gv_access.currentEpisode()
|
||||||
return ffiC.ud.volume_number
|
return ffiC.ud.volume_number
|
||||||
|
|
|
@ -50,6 +50,7 @@ krand;
|
||||||
ksqrt;
|
ksqrt;
|
||||||
inside;
|
inside;
|
||||||
getangle;
|
getangle;
|
||||||
|
Mulscale;
|
||||||
cansee;
|
cansee;
|
||||||
hitscan;
|
hitscan;
|
||||||
neartag;
|
neartag;
|
||||||
|
@ -82,10 +83,12 @@ s_buildRev;
|
||||||
g_sizes_of_what;
|
g_sizes_of_what;
|
||||||
g_sizes_of;
|
g_sizes_of;
|
||||||
g_elCallDepth;
|
g_elCallDepth;
|
||||||
g_elEventRETURN;
|
g_RETURN;
|
||||||
g_argv;
|
g_argv;
|
||||||
g_modDir;
|
g_modDir;
|
||||||
|
|
||||||
|
MapInfo;
|
||||||
|
|
||||||
kopen4loadfrommod;
|
kopen4loadfrommod;
|
||||||
|
|
||||||
g_scriptModules;
|
g_scriptModules;
|
||||||
|
@ -130,6 +133,7 @@ g_scriptVersion;
|
||||||
g_currentFrameRate;
|
g_currentFrameRate;
|
||||||
g_currentMenu;
|
g_currentMenu;
|
||||||
g_earthquakeTime;
|
g_earthquakeTime;
|
||||||
|
CheatKeys;
|
||||||
g_logoFlags;
|
g_logoFlags;
|
||||||
|
|
||||||
luaJIT_BC_lunacon;
|
luaJIT_BC_lunacon;
|
||||||
|
|
|
@ -50,6 +50,7 @@ krand;
|
||||||
ksqrt;
|
ksqrt;
|
||||||
inside;
|
inside;
|
||||||
getangle;
|
getangle;
|
||||||
|
Mulscale;
|
||||||
cansee;
|
cansee;
|
||||||
hitscan;
|
hitscan;
|
||||||
neartag;
|
neartag;
|
||||||
|
|
|
@ -207,7 +207,7 @@ local function new_initial_gvartab()
|
||||||
-- NOTE: THISACTOR can mean different things in some contexts.
|
-- NOTE: THISACTOR can mean different things in some contexts.
|
||||||
THISACTOR = RO "_aci",
|
THISACTOR = RO "_aci",
|
||||||
|
|
||||||
RETURN = RW(CSV".RETURN"),
|
RETURN = RW "_gv.g_RETURN",
|
||||||
HITAG = RW(CSV".HITAG"),
|
HITAG = RW(CSV".HITAG"),
|
||||||
LOTAG = RW(CSV".LOTAG"),
|
LOTAG = RW(CSV".LOTAG"),
|
||||||
TEXTURE = RW(CSV".TEXTURE"),
|
TEXTURE = RW(CSV".TEXTURE"),
|
||||||
|
@ -420,9 +420,7 @@ function on.event_end(eventidx, codetab)
|
||||||
assert(type(codetab)=="table")
|
assert(type(codetab)=="table")
|
||||||
addcodef("gameevent(%d, function (_aci, _pli, _dist)", eventidx)
|
addcodef("gameevent(%d, function (_aci, _pli, _dist)", eventidx)
|
||||||
addcode(get_cache_sap_code())
|
addcode(get_cache_sap_code())
|
||||||
addcode(CSV".RETURN=gv._RETURN()")
|
|
||||||
addcode(codetab)
|
addcode(codetab)
|
||||||
addcodef("gv._RETURN(%s)", CSV".RETURN")
|
|
||||||
addcode("end)")
|
addcode("end)")
|
||||||
|
|
||||||
g_code.event[eventidx] = codetab
|
g_code.event[eventidx] = codetab
|
||||||
|
@ -1913,7 +1911,7 @@ local Cinner = {
|
||||||
operatemasterswitches = cmd(R)
|
operatemasterswitches = cmd(R)
|
||||||
/ "_con._G_OperateMasterSwitches(%1)",
|
/ "_con._G_OperateMasterSwitches(%1)",
|
||||||
checkactivatormotion = cmd(R)
|
checkactivatormotion = cmd(R)
|
||||||
/ CSV".RETURN=_con._checkactivatormotion(%1)",
|
/ "_gv.g_RETURN=_con._checkactivatormotion(%1)",
|
||||||
time = cmd(R) -- no-op
|
time = cmd(R) -- no-op
|
||||||
/ "",
|
/ "",
|
||||||
inittimer = cmd(R)
|
inittimer = cmd(R)
|
||||||
|
@ -1984,17 +1982,17 @@ local Cinner = {
|
||||||
spawn = cmd(D)
|
spawn = cmd(D)
|
||||||
/ "_con.spawn(_aci,%1)",
|
/ "_con.spawn(_aci,%1)",
|
||||||
espawn = cmd(D)
|
espawn = cmd(D)
|
||||||
/ CSV".RETURN=_con.spawn(_aci,%1)",
|
/ "_gv.g_RETURN=_con.spawn(_aci,%1)",
|
||||||
espawnvar = cmd(R)
|
espawnvar = cmd(R)
|
||||||
/ CSV".RETURN=_con.spawn(_aci,%1)",
|
/ "_gv.g_RETURN=_con.spawn(_aci,%1)",
|
||||||
qspawn = cmd(D)
|
qspawn = cmd(D)
|
||||||
/ "_con.spawn(_aci,%1,true)",
|
/ "_con.spawn(_aci,%1,true)",
|
||||||
qspawnvar = cmd(R)
|
qspawnvar = cmd(R)
|
||||||
/ "_con.spawn(_aci,%1,true)",
|
/ "_con.spawn(_aci,%1,true)",
|
||||||
eqspawn = cmd(D)
|
eqspawn = cmd(D)
|
||||||
/ CSV".RETURN=_con.spawn(_aci,%1,true)",
|
/ "_gv.g_RETURN=_con.spawn(_aci,%1,true)",
|
||||||
eqspawnvar = cmd(R)
|
eqspawnvar = cmd(R)
|
||||||
/ CSV".RETURN=_con.spawn(_aci,%1,true)",
|
/ "_gv.g_RETURN=_con.spawn(_aci,%1,true)",
|
||||||
|
|
||||||
angoff = cmd(D)
|
angoff = cmd(D)
|
||||||
/ "spriteext[_aci].angoff=%1",
|
/ "spriteext[_aci].angoff=%1",
|
||||||
|
@ -2022,13 +2020,13 @@ local Cinner = {
|
||||||
/ ACS".timetosleep=%1",
|
/ ACS".timetosleep=%1",
|
||||||
|
|
||||||
eshoot = cmd(D)
|
eshoot = cmd(D)
|
||||||
/ CSV".RETURN=_con._shoot(_aci,%1)",
|
/ "_gv.g_RETURN=_con._shoot(_aci,%1)",
|
||||||
eshootvar = cmd(R)
|
eshootvar = cmd(R)
|
||||||
/ CSV".RETURN=_con._shoot(_aci,%1)",
|
/ "_gv.g_RETURN=_con._shoot(_aci,%1)",
|
||||||
ezshoot = cmd(R,D)
|
ezshoot = cmd(R,D)
|
||||||
/ CSV".RETURN=_con._shoot(_aci,%2,%1)",
|
/ "_gv.g_RETURN=_con._shoot(_aci,%2,%1)",
|
||||||
ezshootvar = cmd(R,R)
|
ezshootvar = cmd(R,R)
|
||||||
/ CSV".RETURN=_con._shoot(_aci,%2,%1)",
|
/ "_gv.g_RETURN=_con._shoot(_aci,%2,%1)",
|
||||||
shoot = cmd(D)
|
shoot = cmd(D)
|
||||||
/ "_con._shoot(_aci,%1)",
|
/ "_con._shoot(_aci,%1)",
|
||||||
shootvar = cmd(R)
|
shootvar = cmd(R)
|
||||||
|
@ -2071,9 +2069,9 @@ local Cinner = {
|
||||||
|
|
||||||
-- player/sprite searching
|
-- player/sprite searching
|
||||||
findplayer = cmd(W)
|
findplayer = cmd(W)
|
||||||
/ CSV".RETURN,%1=_con._findplayer(_pli,_aci)", -- player index, distance
|
/ "_gv.g_RETURN,%1=_con._findplayer(_pli,_aci)", -- player index, distance
|
||||||
findotherplayer = cmd(W)
|
findotherplayer = cmd(W)
|
||||||
/ CSV".RETURN,%1=0,0x7fffffff", -- TODO_MP
|
/ "_gv.g_RETURN,%1=0,0x7fffffff", -- TODO_MP
|
||||||
findnearspritezvar = cmd(D,R,R,W)
|
findnearspritezvar = cmd(D,R,R,W)
|
||||||
/ "%4=_con._findnear(_aci,true,'z',%1,%2,%3)",
|
/ "%4=_con._findnear(_aci,true,'z',%1,%2,%3)",
|
||||||
findnearspritez = cmd(D,D,D,W)
|
findnearspritez = cmd(D,D,D,W)
|
||||||
|
|
|
@ -27,7 +27,7 @@ el_actor_t g_elActors[MAXTILES];
|
||||||
int32_t g_elEventError;
|
int32_t g_elEventError;
|
||||||
|
|
||||||
int32_t g_elCallDepth = 0;
|
int32_t g_elCallDepth = 0;
|
||||||
int32_t g_elEventRETURN;
|
int32_t g_RETURN;
|
||||||
|
|
||||||
// for timing events and actors
|
// for timing events and actors
|
||||||
uint32_t g_eventCalls[MAXEVENTS], g_actorCalls[MAXTILES];
|
uint32_t g_eventCalls[MAXEVENTS], g_actorCalls[MAXTILES];
|
||||||
|
@ -489,13 +489,15 @@ int32_t El_CallEvent(L_State *estate, int32_t eventidx, int32_t iActor, int32_t
|
||||||
lua_State *const L = estate->L;
|
lua_State *const L = estate->L;
|
||||||
int32_t i;
|
int32_t i;
|
||||||
|
|
||||||
g_elEventRETURN = *iReturn;
|
const int32_t o_RETURN = g_RETURN;
|
||||||
|
g_RETURN = *iReturn;
|
||||||
|
|
||||||
g_elCallDepth++;
|
g_elCallDepth++;
|
||||||
i = call_regd_function3(L, &g_elEvents[eventidx], iActor, iPlayer, lDist);
|
i = call_regd_function3(L, &g_elEvents[eventidx], iActor, iPlayer, lDist);
|
||||||
g_elCallDepth--;
|
g_elCallDepth--;
|
||||||
|
|
||||||
*iReturn = g_elEventRETURN;
|
*iReturn = g_RETURN;
|
||||||
|
g_RETURN = o_RETURN;
|
||||||
|
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue