Subversion Repositories eduke32

Rev

Rev 4567 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4567 Rev 4570
Line 1682... Line 1682...
1682
-- calling this one.
1682
-- calling this one.
1683
local function getnumlocals(l)
1683
local function getnumlocals(l)
1684
    -- 200 is the max. number of locals at one level
1684
    -- 200 is the max. number of locals at one level
1685
    for i=1,200 do
1685
    for i=1,200 do
1686
        -- level:
1686
        -- level:
1687
        -- 0 is getlocal() itself.
1687
        -- 0 is debug.getlocal() itself.
1688
        -- 1 is this function (getnumlocals).
1688
        -- 1 is this function (getnumlocals).
1689
        -- 2 is the function calling getnumlocals()
1689
        -- 2 is the function calling getnumlocals()
1690
        -- 3 is the function calling that one.
1690
        -- 3 is the function calling that one.
1691
        if (debug.getlocal(3, i) == nil) then
1691
        if (debug.getlocal(3, i) == nil) then
1692
            return i-1
1692
            return i-1
Line 2286... Line 2286...
2286
        -- A local to temporarily hold module locals.
2286
        -- A local to temporarily hold module locals.
2287
        sb:addraw("local L")
2287
        sb:addraw("local L")
2288
2288
2289
        -- XXX: System gamevars? Most of them ought to be saved with C data.
2289
        -- XXX: System gamevars? Most of them ought to be saved with C data.
2290
        for modname, modvars in pairs(module_gamevars) do
2290
        for modname, modvars in pairs(module_gamevars) do
-
 
2291
            local isCON = (modname==CON_MODULE_NAME)
-
 
2292
2291
            sb:startmod(modname)
2293
            sb:startmod(modname)
2292
2294
2293
            -- Handle global gamevars first.
2295
            -- Handle global gamevars first.
2294
            for i=1,#modvars do
2296
            for i=1,#modvars do
2295
                local varname = modvars[i]
2297
                local varname = modvars[i]
2296
                local excludedVars = modname==CON_MODULE_NAME and varname=="_V" and
2298
                local excludedVars = isCON and varname=="_V" and
2297
                    package_loaded[CON_MODULE_NAME]._V._IS_NORESET_GAMEVAR or nil
2299
                    package_loaded[CON_MODULE_NAME]._V._IS_NORESET_GAMEVAR or nil
2298
2300
2299
                -- Serialize gamevar named 'varname' from module named 'modname'.
2301
                -- Serialize gamevar named 'varname' from module named 'modname'.
2300
                -- XXX: May error. This will terminate EDuke32 since this callback
2302
                -- XXX: May error. This will terminate EDuke32 since this callback
2301
                -- is run unprotected.
2303
                -- is run unprotected.
2302
                if (sb:add("M."..varname, package_loaded[modname][varname], excludedVars)) then
2304
                if (sb:add("M."..varname, package_loaded[modname][varname], excludedVars)) then
2303
                    -- We couldn't serialize that gamevar.
2305
                    -- We couldn't serialize that gamevar.
2304
                    slenptr[0] = -1
2306
                    slenptr[0] = -1
2305
                    -- Signal which gamevar that was.
2307
                    -- Signal which gamevar that was.
2306
                    return (modname==CON_MODULE_NAME and "<CON>" or modname).."."..varname
2308
                    return (isCON and "<CON>" or modname).."."..varname
2307
                end
2309
                end
2308
            end
2310
            end
2309
2311
2310
            local modthread = module_thread[modname]
2312
            local modthread = module_thread[modname]
2311
2313
Line 2333... Line 2335...
2333
2335
2334
        -- Get the whole code as a string.
2336
        -- Get the whole code as a string.
2335
        local savecode = sb:getcode()
2337
        local savecode = sb:getcode()
2336
2338
2337
        if (ffiC._DEBUG_LUNATIC ~= 0) then
2339
        if (ffiC._DEBUG_LUNATIC ~= 0) then
2338
            -- Dump the code if Lunatic debugging is enabled and there is a
2340
            -- Dump the code if Lunatic debugging is enabled (-Lopts=diag) and
2339
            -- LUNATIC_SAVECODE_FN variable in the environment.
2341
            -- there is a LUNATIC_SAVECODE_FN variable in the environment.
2340
            local os = require("os")
2342
            local os = require("os")
2341
            local fn = os.getenv("LUNATIC_SAVECODE_FN")
2343
            local fn = os.getenv("LUNATIC_SAVECODE_FN")
2342
2344
2343
            if (fn ~= nil) then
2345
            if (fn ~= nil) then
2344
                if (levelnum >= 0) then
2346
                if (levelnum >= 0) then
Line 2536... Line 2538...
2536
    local conlabels, conaction, conmove, conai = confunc()
2538
    local conlabels, conaction, conmove, conai = confunc()
2537
    table.remove(modname_stack)
2539
    table.remove(modname_stack)
2538
2540
2539
    local function protect_con_table(tab)
2541
    local function protect_con_table(tab)
2540
        -- NOTE: Some of our code specifically excepts the name tables to be
2542
        -- NOTE: Some of our code specifically excepts the name tables to be
2541
        -- indexable with nonexistent keys. See e.g. control.c: _A_SpawnGlass()
2543
        -- indexable with nonexistent keys. See e.g. control.lua: _A_SpawnGlass()
2542
        if (ffiC._LUNATIC_STRICT ~= 0) then
2544
        if (ffiC._LUNATIC_STRICT ~= 0) then
2543
            tab = setmetatable(tab, index_error_mt)
2545
            tab = setmetatable(tab, index_error_mt)
2544
        end
2546
        end
2545
        return setmtonce({}, { __index=tab, __newindex=basemod_newidx })
2547
        return setmtonce({}, { __index=tab, __newindex=basemod_newidx })
2546
    end
2548
    end
Line 2586... Line 2588...
2586
        i = i+1
2588
        i = i+1
2587
    end
2589
    end
2588
2590
2589
    ffiC.g_elFirstTime = 0
2591
    ffiC.g_elFirstTime = 0
2590
end
2592
end
-
 
2593
-
 
2594
if (g_restorefunc) then
-
 
2595
    -- Clear it so that it may be garbage-collected.
-
 
2596
    g_restorefunc = nil
-
 
2597
end