mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 10:40:46 +00:00
LunaCON: properly initialize values of session (NODEFAULT) gamevars.
git-svn-id: https://svn.eduke32.com/eduke32@4570 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
363f0b3af6
commit
757dbe9d6b
4 changed files with 24 additions and 12 deletions
|
@ -431,7 +431,6 @@ local ActorLabels = {
|
|||
xpanning = SX".xpanning",
|
||||
ypanning = SX".ypanning",
|
||||
|
||||
-- Read access differs from write, write not available:
|
||||
alpha = { "_math.floor(spriteext[%s].alpha*255)", "spriteext[%s].alpha=(%%s)/255" },
|
||||
|
||||
isvalid = { "_con._isvalid(%s)" },
|
||||
|
|
|
@ -1684,7 +1684,7 @@ local function getnumlocals(l)
|
|||
-- 200 is the max. number of locals at one level
|
||||
for i=1,200 do
|
||||
-- level:
|
||||
-- 0 is getlocal() itself.
|
||||
-- 0 is debug.getlocal() itself.
|
||||
-- 1 is this function (getnumlocals).
|
||||
-- 2 is the function calling getnumlocals()
|
||||
-- 3 is the function calling that one.
|
||||
|
@ -2288,12 +2288,14 @@ do
|
|||
|
||||
-- XXX: System gamevars? Most of them ought to be saved with C data.
|
||||
for modname, modvars in pairs(module_gamevars) do
|
||||
local isCON = (modname==CON_MODULE_NAME)
|
||||
|
||||
sb:startmod(modname)
|
||||
|
||||
-- Handle global gamevars first.
|
||||
for i=1,#modvars do
|
||||
local varname = modvars[i]
|
||||
local excludedVars = modname==CON_MODULE_NAME and varname=="_V" and
|
||||
local excludedVars = isCON and varname=="_V" and
|
||||
package_loaded[CON_MODULE_NAME]._V._IS_NORESET_GAMEVAR or nil
|
||||
|
||||
-- Serialize gamevar named 'varname' from module named 'modname'.
|
||||
|
@ -2303,7 +2305,7 @@ do
|
|||
-- We couldn't serialize that gamevar.
|
||||
slenptr[0] = -1
|
||||
-- Signal which gamevar that was.
|
||||
return (modname==CON_MODULE_NAME and "<CON>" or modname).."."..varname
|
||||
return (isCON and "<CON>" or modname).."."..varname
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -2335,8 +2337,8 @@ do
|
|||
local savecode = sb:getcode()
|
||||
|
||||
if (ffiC._DEBUG_LUNATIC ~= 0) then
|
||||
-- Dump the code if Lunatic debugging is enabled and there is a
|
||||
-- LUNATIC_SAVECODE_FN variable in the environment.
|
||||
-- Dump the code if Lunatic debugging is enabled (-Lopts=diag) and
|
||||
-- there is a LUNATIC_SAVECODE_FN variable in the environment.
|
||||
local os = require("os")
|
||||
local fn = os.getenv("LUNATIC_SAVECODE_FN")
|
||||
|
||||
|
@ -2538,7 +2540,7 @@ if (assert(concode ~= nil)) then
|
|||
|
||||
local function protect_con_table(tab)
|
||||
-- NOTE: Some of our code specifically excepts the name tables to be
|
||||
-- indexable with nonexistent keys. See e.g. control.c: _A_SpawnGlass()
|
||||
-- indexable with nonexistent keys. See e.g. control.lua: _A_SpawnGlass()
|
||||
if (ffiC._LUNATIC_STRICT ~= 0) then
|
||||
tab = setmetatable(tab, index_error_mt)
|
||||
end
|
||||
|
@ -2588,3 +2590,8 @@ if (not g_firstRun) then
|
|||
|
||||
ffiC.g_elFirstTime = 0
|
||||
end
|
||||
|
||||
if (g_restorefunc) then
|
||||
-- Clear it so that it may be garbage-collected.
|
||||
g_restorefunc = nil
|
||||
end
|
||||
|
|
|
@ -121,8 +121,8 @@ _backtrace_ added. Additionally, errors not caught by a `pcall` result a
|
|||
permanent message to appear on the screen, containing the source file name and
|
||||
line number.
|
||||
|
||||
*`print(...)`*::
|
||||
The messages are printed to the OSD and the log. Color codes available in
|
||||
*`print(str)`*::
|
||||
Prints a single message to the OSD and the log. Color codes available in
|
||||
EDuke32 (e.g. `^10` for dark red) are interpreted. Overriding `tostring` has no
|
||||
effect on Lunatic's `print` as it uses the initial, built-in `tostring`
|
||||
function instead of looking it up in the global environment.
|
||||
|
|
|
@ -1476,7 +1476,6 @@ function Cmd.gamevar(identifier, initval, flags)
|
|||
return
|
||||
end
|
||||
|
||||
-- TODO: handle user bits like NORESET or NODEFAULT
|
||||
if (bit.band(flags, bit.bnot(GVFLAG.USER_MASK)) ~= 0) then
|
||||
-- TODO: a couple of the presumably safe ones
|
||||
errprintf("gamevar flags other than 1, 2, 1024 or 131072: NYI or forbidden")
|
||||
|
@ -1492,6 +1491,7 @@ function Cmd.gamevar(identifier, initval, flags)
|
|||
end
|
||||
|
||||
local ogv = g_gamevar[identifier]
|
||||
-- handle NORESET or NODEFAULT
|
||||
local isSessionVar = (bit.band(flags, GVFLAG.NODEFAULT) ~= 0)
|
||||
local storeWithSavegames = (bit.band(flags, GVFLAG.NORESET) == 0)
|
||||
|
||||
|
@ -1573,9 +1573,15 @@ function Cmd.gamevar(identifier, initval, flags)
|
|||
end
|
||||
|
||||
-- Declare new session gamevar.
|
||||
g_gamevar[identifier] = { name=format("_gv._sessionVar[%d]", g_numSessionVars),
|
||||
flags=flags, loc=getLocation(), used=0 }
|
||||
local gv = { name=format("_gv._sessionVar[%d]", g_numSessionVars),
|
||||
flags=flags, loc=getLocation(), used=0 }
|
||||
g_numSessionVars = g_numSessionVars+1
|
||||
|
||||
g_gamevar[identifier] = gv;
|
||||
-- Initialize it (i.e. set to the declared initial value) on first run,
|
||||
-- but not from savegames.
|
||||
addcodef("if _S then %s=%d end", gv.name, initval)
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue