mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-16 01:11:28 +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,
|
||||
PROJ,
|
||||
EVENT,
|
||||
setmetatable(shallow_copy(SFLAG), { __metatable="noffiC" }),
|
||||
-- setmetatable(
|
||||
shallow_copy(SFLAG),
|
||||
-- { __metatable="noffiC" }),
|
||||
STAT,
|
||||
GAMEFUNC,
|
||||
}
|
||||
|
|
|
@ -518,6 +518,7 @@ ffi.cdef[[
|
|||
const int32_t screenpeek;
|
||||
hudweapon_t hudweap;
|
||||
int32_t g_logoFlags;
|
||||
int32_t g_RETURN; // deprecated from Lua
|
||||
]]
|
||||
|
||||
-- INTERNAL VARIABLES/FUNCTIONS
|
||||
|
@ -528,7 +529,6 @@ const char *s_buildRev;
|
|||
const char *g_sizes_of_what[];
|
||||
int32_t g_sizes_of[];
|
||||
int32_t g_elCallDepth;
|
||||
int32_t g_elEventRETURN;
|
||||
const char **g_argv;
|
||||
char g_modDir[];
|
||||
actor_t actor[MAXSPRITES];
|
||||
|
@ -1143,8 +1143,8 @@ local camera_mt = {
|
|||
gv_access.cam = setmtonce({}, camera_mt)
|
||||
gv_access._ud = ffiC.ud
|
||||
|
||||
-- Support for some CON global system gamevars
|
||||
gv_access._csv = ffi.new "struct { int32_t RETURN, LOTAG, HITAG, TEXTURE; }"
|
||||
-- Support for some CON global system gamevars. RETURN handled separately.
|
||||
gv_access._csv = ffi.new "struct { int32_t LOTAG, HITAG, TEXTURE; }"
|
||||
|
||||
function gv_access._get_yxaspect()
|
||||
return ffiC.yxaspect
|
||||
|
@ -1170,14 +1170,6 @@ function gv_access._set_guniqhudid(id)
|
|||
ffiC.guniqhudid = id
|
||||
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
|
||||
function gv_access.currentEpisode()
|
||||
return ffiC.ud.volume_number
|
||||
|
|
|
@ -50,6 +50,7 @@ krand;
|
|||
ksqrt;
|
||||
inside;
|
||||
getangle;
|
||||
Mulscale;
|
||||
cansee;
|
||||
hitscan;
|
||||
neartag;
|
||||
|
@ -82,10 +83,12 @@ s_buildRev;
|
|||
g_sizes_of_what;
|
||||
g_sizes_of;
|
||||
g_elCallDepth;
|
||||
g_elEventRETURN;
|
||||
g_RETURN;
|
||||
g_argv;
|
||||
g_modDir;
|
||||
|
||||
MapInfo;
|
||||
|
||||
kopen4loadfrommod;
|
||||
|
||||
g_scriptModules;
|
||||
|
@ -130,6 +133,7 @@ g_scriptVersion;
|
|||
g_currentFrameRate;
|
||||
g_currentMenu;
|
||||
g_earthquakeTime;
|
||||
CheatKeys;
|
||||
g_logoFlags;
|
||||
|
||||
luaJIT_BC_lunacon;
|
||||
|
|
|
@ -50,6 +50,7 @@ krand;
|
|||
ksqrt;
|
||||
inside;
|
||||
getangle;
|
||||
Mulscale;
|
||||
cansee;
|
||||
hitscan;
|
||||
neartag;
|
||||
|
|
|
@ -207,7 +207,7 @@ local function new_initial_gvartab()
|
|||
-- NOTE: THISACTOR can mean different things in some contexts.
|
||||
THISACTOR = RO "_aci",
|
||||
|
||||
RETURN = RW(CSV".RETURN"),
|
||||
RETURN = RW "_gv.g_RETURN",
|
||||
HITAG = RW(CSV".HITAG"),
|
||||
LOTAG = RW(CSV".LOTAG"),
|
||||
TEXTURE = RW(CSV".TEXTURE"),
|
||||
|
@ -420,9 +420,7 @@ function on.event_end(eventidx, codetab)
|
|||
assert(type(codetab)=="table")
|
||||
addcodef("gameevent(%d, function (_aci, _pli, _dist)", eventidx)
|
||||
addcode(get_cache_sap_code())
|
||||
addcode(CSV".RETURN=gv._RETURN()")
|
||||
addcode(codetab)
|
||||
addcodef("gv._RETURN(%s)", CSV".RETURN")
|
||||
addcode("end)")
|
||||
|
||||
g_code.event[eventidx] = codetab
|
||||
|
@ -1913,7 +1911,7 @@ local Cinner = {
|
|||
operatemasterswitches = cmd(R)
|
||||
/ "_con._G_OperateMasterSwitches(%1)",
|
||||
checkactivatormotion = cmd(R)
|
||||
/ CSV".RETURN=_con._checkactivatormotion(%1)",
|
||||
/ "_gv.g_RETURN=_con._checkactivatormotion(%1)",
|
||||
time = cmd(R) -- no-op
|
||||
/ "",
|
||||
inittimer = cmd(R)
|
||||
|
@ -1984,17 +1982,17 @@ local Cinner = {
|
|||
spawn = cmd(D)
|
||||
/ "_con.spawn(_aci,%1)",
|
||||
espawn = cmd(D)
|
||||
/ CSV".RETURN=_con.spawn(_aci,%1)",
|
||||
/ "_gv.g_RETURN=_con.spawn(_aci,%1)",
|
||||
espawnvar = cmd(R)
|
||||
/ CSV".RETURN=_con.spawn(_aci,%1)",
|
||||
/ "_gv.g_RETURN=_con.spawn(_aci,%1)",
|
||||
qspawn = cmd(D)
|
||||
/ "_con.spawn(_aci,%1,true)",
|
||||
qspawnvar = cmd(R)
|
||||
/ "_con.spawn(_aci,%1,true)",
|
||||
eqspawn = cmd(D)
|
||||
/ CSV".RETURN=_con.spawn(_aci,%1,true)",
|
||||
/ "_gv.g_RETURN=_con.spawn(_aci,%1,true)",
|
||||
eqspawnvar = cmd(R)
|
||||
/ CSV".RETURN=_con.spawn(_aci,%1,true)",
|
||||
/ "_gv.g_RETURN=_con.spawn(_aci,%1,true)",
|
||||
|
||||
angoff = cmd(D)
|
||||
/ "spriteext[_aci].angoff=%1",
|
||||
|
@ -2022,13 +2020,13 @@ local Cinner = {
|
|||
/ ACS".timetosleep=%1",
|
||||
|
||||
eshoot = cmd(D)
|
||||
/ CSV".RETURN=_con._shoot(_aci,%1)",
|
||||
/ "_gv.g_RETURN=_con._shoot(_aci,%1)",
|
||||
eshootvar = cmd(R)
|
||||
/ CSV".RETURN=_con._shoot(_aci,%1)",
|
||||
/ "_gv.g_RETURN=_con._shoot(_aci,%1)",
|
||||
ezshoot = cmd(R,D)
|
||||
/ CSV".RETURN=_con._shoot(_aci,%2,%1)",
|
||||
/ "_gv.g_RETURN=_con._shoot(_aci,%2,%1)",
|
||||
ezshootvar = cmd(R,R)
|
||||
/ CSV".RETURN=_con._shoot(_aci,%2,%1)",
|
||||
/ "_gv.g_RETURN=_con._shoot(_aci,%2,%1)",
|
||||
shoot = cmd(D)
|
||||
/ "_con._shoot(_aci,%1)",
|
||||
shootvar = cmd(R)
|
||||
|
@ -2071,9 +2069,9 @@ local Cinner = {
|
|||
|
||||
-- player/sprite searching
|
||||
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)
|
||||
/ CSV".RETURN,%1=0,0x7fffffff", -- TODO_MP
|
||||
/ "_gv.g_RETURN,%1=0,0x7fffffff", -- TODO_MP
|
||||
findnearspritezvar = cmd(D,R,R,W)
|
||||
/ "%4=_con._findnear(_aci,true,'z',%1,%2,%3)",
|
||||
findnearspritez = cmd(D,D,D,W)
|
||||
|
|
|
@ -27,7 +27,7 @@ el_actor_t g_elActors[MAXTILES];
|
|||
int32_t g_elEventError;
|
||||
|
||||
int32_t g_elCallDepth = 0;
|
||||
int32_t g_elEventRETURN;
|
||||
int32_t g_RETURN;
|
||||
|
||||
// for timing events and actors
|
||||
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;
|
||||
int32_t i;
|
||||
|
||||
g_elEventRETURN = *iReturn;
|
||||
const int32_t o_RETURN = g_RETURN;
|
||||
g_RETURN = *iReturn;
|
||||
|
||||
g_elCallDepth++;
|
||||
i = call_regd_function3(L, &g_elEvents[eventidx], iActor, iPlayer, lDist);
|
||||
g_elCallDepth--;
|
||||
|
||||
*iReturn = g_elEventRETURN;
|
||||
*iReturn = g_RETURN;
|
||||
g_RETURN = o_RETURN;
|
||||
|
||||
if (i != 0)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue