From 9285a9054bd0d1d8cd868de2cfc271af9a2e8db0 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Fri, 15 Mar 2013 16:56:15 +0000 Subject: [PATCH] Lunatic translator: warn if setting reserved bits in some system gamevar redef. git-svn-id: https://svn.eduke32.com/eduke32@3563 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/lunatic/lunacon.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/polymer/eduke32/source/lunatic/lunacon.lua b/polymer/eduke32/source/lunatic/lunacon.lua index 730334160..1ba739598 100644 --- a/polymer/eduke32/source/lunatic/lunacon.lua +++ b/polymer/eduke32/source/lunatic/lunacon.lua @@ -271,11 +271,18 @@ local function new_initial_gvartab() LEVEL = RO "_gv.currentLevel()", } + -- Reserved bits + gamevar.LOGO_FLAGS.rbits = bit.bnot(2047) + for w=0,MAX_WEAPONS-1 do for i=1,#wmembers do local member = wmembers[i]:gsub(".* ","") -- strip e.g. "int32_t " local name = format("WEAPON%d_%s", w, member:upper()) gamevar[name] = PRW(format(PLSX".weapon[%d].%s", w, member)) + + if (member=="flags") then + gamevar[name].rbits = bit.bnot(0x1ffff) + end end end @@ -1050,10 +1057,15 @@ function Cmd.gamevar(identifier, initval, flags) "flags (%d)", identifier, flagsnosys) end + if (ogv.rbits and bit.band(ogv.rbits, initval)~=0) then + warnprintf("set one or more reserved bits (0x%s) in overriding `%s'", + bit.tohex(bit.band(ogv.rbits, initval)), identifier) + end + -- Emit code to set the variable at Lua parse time. if (bit.band(oflags, GVFLAG.PERPLAYER) ~= 0) then -- Replace player index by 0. - -- TODO: init for all players. + -- TODO_MP: init for all players. local pvar, numrepls = ogv.name:gsub("_pli", "0") assert(numrepls>=1) addcodef("%s=%d", pvar, initval)