From 15bcfe3f349f0f61fe3f1d3dd159d61986aa5357 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Fri, 23 Aug 2013 17:01:10 +0000 Subject: [PATCH] Lunatic: on the Lua side, rename gv.g_RETURN to the prettier gv.RETURN. On the C side, keep the name g_RETURN. I'm still superstitious about dropping the "g_". git-svn-id: https://svn.eduke32.com/eduke32@4031 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/lunatic/defs.ilua | 6 +++++- polymer/eduke32/source/lunatic/lunacon.lua | 24 +++++++++++----------- polymer/eduke32/source/lunatic/test.lua | 2 +- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/polymer/eduke32/source/lunatic/defs.ilua b/polymer/eduke32/source/lunatic/defs.ilua index 7ce897072..9d029859f 100644 --- a/polymer/eduke32/source/lunatic/defs.ilua +++ b/polymer/eduke32/source/lunatic/defs.ilua @@ -581,7 +581,6 @@ ffi.cdef[[ const int32_t screenpeek; hudweapon_t hudweap; int32_t g_logoFlags; -int32_t g_RETURN; ]] -- INTERNAL VARIABLES/FUNCTIONS @@ -589,6 +588,7 @@ decl("map_t MapInfo[$*$];", con_lang.MAXVOLUMES+1, con_lang.MAXLEVELS) decl("char EpisodeNames[$][33];", con_lang.MAXVOLUMES) decl[[ +int32_t g_RETURN; int32_t g_elCONSize; char *g_elCON; void El_SetCON(const char *conluacode); @@ -2342,9 +2342,11 @@ end -- Map of 'gv' variable names to C ones. local varnameMap = { gametic = "g_moveThingsCount", + RETURN = "g_RETURN", } gv_access.gametic = true +gv_access.RETURN = true local tmpmt = { __index = function(_, key) @@ -2365,6 +2367,8 @@ local tmpmt = { if (gv_access[key] == nil) then -- Variables declared 'const' are handled by LuaJIT. ffiC[key] = val + elseif (varnameMap[key]) then + ffiC[varnameMap[key]] = val else error("write access forbidden", 2) end diff --git a/polymer/eduke32/source/lunatic/lunacon.lua b/polymer/eduke32/source/lunatic/lunacon.lua index bde94fb14..7311eca4f 100644 --- a/polymer/eduke32/source/lunatic/lunacon.lua +++ b/polymer/eduke32/source/lunatic/lunacon.lua @@ -347,7 +347,7 @@ local function new_initial_gvartab() -- NOTE: THISACTOR can mean different things in some contexts. THISACTOR = RO "_aci", - RETURN = RW "_gv.g_RETURN", + RETURN = RW "_gv.RETURN", HITAG = RW(CSV".HITAG"), LOTAG = RW(CSV".LOTAG"), TEXTURE = RW(CSV".TEXTURE"), @@ -2277,7 +2277,7 @@ local Cinner = { operatemasterswitches = cmd(R) / "_con._G_OperateMasterSwitches(%1)", checkactivatormotion = cmd(R) - / "_gv.g_RETURN=_con._checkactivatormotion(%1)", + / "_gv.RETURN=_con._checkactivatormotion(%1)", time = cmd(R) -- no-op / "", inittimer = cmd(R) @@ -2350,17 +2350,17 @@ local Cinner = { spawn = cmd(D) / "_con.spawn(%1,_aci)", espawn = cmd(D) - / "_gv.g_RETURN=_con.spawn(%1,_aci)", + / "_gv.RETURN=_con.spawn(%1,_aci)", espawnvar = cmd(R) - / "_gv.g_RETURN=_con.spawn(%1,_aci)", + / "_gv.RETURN=_con.spawn(%1,_aci)", qspawn = cmd(D) / "_con.spawn(%1,_aci,true)", qspawnvar = cmd(R) / "_con.spawn(%1,_aci,true)", eqspawn = cmd(D) - / "_gv.g_RETURN=_con.spawn(%1,_aci,true)", + / "_gv.RETURN=_con.spawn(%1,_aci,true)", eqspawnvar = cmd(R) - / "_gv.g_RETURN=_con.spawn(%1,_aci,true)", + / "_gv.RETURN=_con.spawn(%1,_aci,true)", angoff = cmd(D) / "spriteext[_aci].angoff=%1", @@ -2390,13 +2390,13 @@ local Cinner = { / ACS".timetosleep=%1", eshoot = cmd(D) - / "_gv.g_RETURN=_con._shoot(_aci,%1)", + / "_gv.RETURN=_con._shoot(_aci,%1)", eshootvar = cmd(R) - / "_gv.g_RETURN=_con._shoot(_aci,%1)", + / "_gv.RETURN=_con._shoot(_aci,%1)", ezshoot = cmd(R,D) - / "_gv.g_RETURN=_con._shoot(_aci,%2,%1)", + / "_gv.RETURN=_con._shoot(_aci,%2,%1)", ezshootvar = cmd(R,R) - / "_gv.g_RETURN=_con._shoot(_aci,%2,%1)", + / "_gv.RETURN=_con._shoot(_aci,%2,%1)", shoot = cmd(D) / "_con._shoot(_aci,%1)", shootvar = cmd(R) @@ -2439,9 +2439,9 @@ local Cinner = { -- player/sprite searching findplayer = cmd(W) - / "_gv.g_RETURN,%1=_con._findplayer(_pli,_aci)", -- player index, distance + / "_gv.RETURN,%1=_con._findplayer(_pli,_aci)", -- player index, distance findotherplayer = cmd(W) - / "_gv.g_RETURN,%1=0,0x7fffffff", -- TODO_MP + / "_gv.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) diff --git a/polymer/eduke32/source/lunatic/test.lua b/polymer/eduke32/source/lunatic/test.lua index 2889f8a8f..4bab982d2 100644 --- a/polymer/eduke32/source/lunatic/test.lua +++ b/polymer/eduke32/source/lunatic/test.lua @@ -628,7 +628,7 @@ gameevent function (aci, pli) local ps = player[pli] - local neww, curw = gv.g_RETURN, ps.curr_weapon + local neww, curw = gv.RETURN, ps.curr_weapon local r, g, b = testbit(neww, 1), testbit(neww, 2), testbit(neww, 4) local speed = FADE_SPEED[neww] or 1