diff --git a/game/engines/default/engine/Savefile.lua b/game/engines/default/engine/Savefile.lua index cbbbe5cdf9968406c82d5955c1c4f8c83c593386..65707db69f0f22eb8998a3e990f075ceca44787d 100644 --- a/game/engines/default/engine/Savefile.lua +++ b/game/engines/default/engine/Savefile.lua @@ -474,7 +474,14 @@ function _M:loadReal(load) lines[#lines+1] = l end f:close() - local o = class.load(table.concat(lines), load) + local ok, o = xpcall(function() return class.load(table.concat(lines), load) end, debug.traceback) + if not ok then + print("[SAVEFILE ERROR] loading object", load, "resulting in: ", o) + self:addDelayLoad{loaded = function() game:onTickEnd(function() + require("engine.ui.Dialog"):simplePopup("Savefile loading WARNING", "The game has detected a problem in the savefile and attempted to fix it.\nIt is likely to work without any adverse effects but should a problem arise, please mention this event in the bug report.") + end) end} + return nil + end -- Resolve self referencing tables now resolveSelf(o, o, true)