Skip to content
Snippets Groups Projects
Commit d2405264 authored by DarkGod's avatar DarkGod
Browse files

Merge branch 'debug-entity-upvalue' into 'master'

Debug entity upvalue

Moves the upvalue checker into Entity:init, so that entities created by talents and such get run through it as well.
parents d8d9475f 754df486
No related branches found
No related tags found
No related merge requests found
......@@ -64,6 +64,7 @@ end
-- @usage Entity.new{display='#', color_r=255, color_g=255, color_b=255}
function _M:init(t, no_default)
t = t or {}
self.uid = next_uid
__uids[self.uid] = self
next_uid = next_uid + 1
......@@ -120,6 +121,18 @@ function _M:init(t, no_default)
self:addParticles(Particles.new(pd.name, pd.rad or 1, pd.args))
end
end
if config.settings.cheat then
local ok, err = table.check(self, function(t, where, v, tv)
if tv ~= "function" then return true end
local n, v = debug.getupvalue(v, 1)
if not n then return true end
return nil, ("Entity closure checker: %s has upvalue %s"):format(tostring(where), tostring(n))
end)
if not ok then
error("Entity definition has a closure: "..err)
end
end
end
--- If we are cloned we need a new uid
......@@ -975,18 +988,6 @@ function _M:loadList(file, no_default, res, mod, loaded)
local e = newenv.class.new(t, no_default)
if type(mod) == "function" then mod(e) end
if config.settings.cheat then
local ok, err = table.check(e, function(t, where, v, tv)
if tv ~= "function" then return true end
local n, v = debug.getupvalue(v, 1)
if not n then return true end
return nil, ("Entity closure checker: %s has upvalue %s"):format(tostring(where), tostring(n))
end)
if not ok then
error("Entity definition has a closure: "..err)
end
end
res[#res+1] = e
if t.define_as then res[t.define_as] = e end
end,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment