diff --git a/polymer/eduke32/source/lunatic/control.lua b/polymer/eduke32/source/lunatic/control.lua index 058824e83..325d97ee3 100644 --- a/polymer/eduke32/source/lunatic/control.lua +++ b/polymer/eduke32/source/lunatic/control.lua @@ -522,7 +522,7 @@ function _getinventory(ps, inv, i) end end -function _addphealth(ps, spr, hlthadd) +function _addphealth(ps, aci, hlthadd) if (ps.newowner >= 0) then ffiC.G_ClearCameraView(ps) end @@ -531,7 +531,7 @@ function _addphealth(ps, spr, hlthadd) return end - local notatomic = (spr.picnum ~= D.ATOMICHEALTH) + local notatomic = (sprite[aci].picnum ~= D.ATOMICHEALTH) local j = sprite[ps.i].extra if (notatomic and j > ps.max_player_health and hlthadd > 0) then @@ -555,8 +555,8 @@ function _addphealth(ps, spr, hlthadd) if (hlthadd > 0) then local qmaxhlth = bit.rshift(ps.max_player_health, 2) if (j-hlthadd < qmaxhlth and j >= qmaxhlth) then - -- TODO - --A_PlaySound(DUKE_GOTHEALTHATLOW, ps->i) + -- XXX: DUKE_GOTHEALTHATLOW + _sound(229, aci) end ps.last_extra = j diff --git a/polymer/eduke32/source/lunatic/defs.ilua b/polymer/eduke32/source/lunatic/defs.ilua index c85ee1676..a51e7ab31 100644 --- a/polymer/eduke32/source/lunatic/defs.ilua +++ b/polymer/eduke32/source/lunatic/defs.ilua @@ -1092,7 +1092,7 @@ local function our_gameevent(event, func) if (event:sub(1,6) ~= "EVENT_") then event = "EVENT_"..event end - local eventidx = con_lang.labels.EVENT[event] + local eventidx = con_lang.EVENT[event] if (eventidx == nil) then errorf(2, "gameevent: invalid event label %q", event) end @@ -1309,6 +1309,12 @@ DBG_.printkv = printkv DBG_.loadstring = loadstring DBG_.serializeGamevars = serializeGamevars DBG_.loadGamevarsString = loadGamevarsString +DBG_.oom = function() + local s = "1" + for i=1,math.huge do + s = s..s + end +end ---=== Finishing environment setup ===--- diff --git a/polymer/eduke32/source/lunatic/lunacon.lua b/polymer/eduke32/source/lunatic/lunacon.lua index 64524967c..aa86f3c3b 100644 --- a/polymer/eduke32/source/lunatic/lunacon.lua +++ b/polymer/eduke32/source/lunatic/lunacon.lua @@ -1034,7 +1034,7 @@ local Ci = { addkills = cmd(D) / (PLS".actors_killed="..PLS".actors_killed+%1;"..ACS".actorstayput=-1"), addphealth = cmd(D) - / format("_con._addphealth(%s,%s,%%1)", PLS"", SPS""), + / format("_con._addphealth(%s,_aci,%%1)", PLS""), angoff = cmd(D) / "spritext[_aci].angoff=%1", debug = cmd(D) @@ -1143,7 +1143,7 @@ local Ci = { activatebysector = cmd(R,R), addlogvar = cmd(R), addlog = cmd() * #sp1, - addweaponvar = cmd(R,R), -- exec SPECIAL HANDLING! + addweaponvar = cmd(R,R), -- NLCF cansee = cmd(R,R,R,R,R,R,R,R,W), canseespr = cmd(R,R,W), changespritesect = cmd(R,R), diff --git a/polymer/eduke32/source/lunatic/m32/compinside.lua b/polymer/eduke32/source/lunatic/m32/compinside.lua index a11e014b4..84c30ee53 100644 --- a/polymer/eduke32/source/lunatic/m32/compinside.lua +++ b/polymer/eduke32/source/lunatic/m32/compinside.lua @@ -80,6 +80,6 @@ function compinside(n) end print("====================") - print("inside(): " .. tostring(sti:getstats())) - print("contains(): " .. tostring(sts:getstats())) + print("inside(): " .. sti:getstatstr()) + print("contains(): " .. sts:getstatstr()) end diff --git a/polymer/eduke32/source/lunatic/m32/randwalk.lua b/polymer/eduke32/source/lunatic/m32/randwalk.lua index 481335a86..01834f2b7 100644 --- a/polymer/eduke32/source/lunatic/m32/randwalk.lua +++ b/polymer/eduke32/source/lunatic/m32/randwalk.lua @@ -85,8 +85,8 @@ function randwalk(N, spritenum, minlen, maxlen, randofs, funci, logfn) minlen, maxlen, randofs, logfn) printf("-- Times [ms] (total=%f)", N*stallres.mean) print("All: ".. tostring(stallres)) - print("Succeeded: ".. tostring(st.succ:getstats())) - print("Failed: ".. tostring(st.fail:getstats())) + print("Succeeded: ".. st.succ:getstatstr()) + print("Failed: ".. st.fail:getstatstr()) if (logfn ~= nil) then local logfile, errmsg = io.open(logfn, "w") diff --git a/polymer/eduke32/source/lunatic/profdemo.lua b/polymer/eduke32/source/lunatic/profdemo.lua index 000ae2357..078264f73 100755 --- a/polymer/eduke32/source/lunatic/profdemo.lua +++ b/polymer/eduke32/source/lunatic/profdemo.lua @@ -56,8 +56,8 @@ if (numreps > 1) then local key = keys[i] if (unit[key] ~= nil) then print("== "..key.." times:") - print(" "..tostring(st[key]:getstats()).." ["..unit[key].."]") - print(" "..tostring(stperx[key]:getstats()).." ["..unitperx[key].."]") + print(" "..st[key]:getstatstr().." ["..unit[key].."]") + print(" "..stperx[key]:getstatstr().." ["..unitperx[key].."]") end end end diff --git a/polymer/eduke32/source/lunatic/stat.lua b/polymer/eduke32/source/lunatic/stat.lua index ee0254570..df14e4e01 100644 --- a/polymer/eduke32/source/lunatic/stat.lua +++ b/polymer/eduke32/source/lunatic/stat.lua @@ -5,6 +5,8 @@ local ffi = require("ffi") local math = require("math") local string = require("string") +local tostring = tostring + module(...) @@ -75,6 +77,10 @@ local mt = { return rstatres(s.n, s.m, var, math.sqrt(var), s.min, s.max) end, + getstatstr = function(s) + return tostring(s:getstats()) + end, + reset = function(s) s.n = 0 s.m, s.s, s.min, s.max = NaN, NaN, NaN, NaN diff --git a/polymer/eduke32/source/lunatic/test.elua b/polymer/eduke32/source/lunatic/test.elua index d14e2a494..4df85fe4e 100644 --- a/polymer/eduke32/source/lunatic/test.elua +++ b/polymer/eduke32/source/lunatic/test.elua @@ -204,6 +204,7 @@ gameevent(gv.EVENT_JUMP, gameevent("JUMP", function(actori, playeri, dist) print("I'm first!") +-- DBG_.oom() end ) @@ -279,7 +280,7 @@ gameactor(1680, TROOPSTRENGTH, "TROOPSTAND", -- LIZTROOP hs:add(1000*(gv.gethitickms()-t)) if (hs.n == 300) then - printf("hitscan: %s", tostring(hs:getstats())) + printf("hitscan: %s", hs:getstatstr()) hs:reset() error("greetings from LIZTROOP actor") end @@ -311,6 +312,8 @@ function check_sector_idx() end spritesofsect(0) +--DBG_.oom() + -- This will complain about wrong usage of 'error'. In particular, -- the nil must not propagate to C! error(nil)