diff --git a/game/engines/default/engine/Map.lua b/game/engines/default/engine/Map.lua index 337ae86683c868b37e17ffb583067cc1c4cd6fdf..36a4666e2e8255beef404b8cc80bc786e5a13c3e 100644 --- a/game/engines/default/engine/Map.lua +++ b/game/engines/default/engine/Map.lua @@ -326,13 +326,23 @@ function _M:close() se._mo = nil end end end - self.map[i][pos] = nil end end self.closed = true self.changed = true end +--- Closes things in the object to allow it to be garbage collected +-- Map objects are NOT automatically garbage collected because they contain FOV C structure, which themselves have a reference +-- to the map. Cyclic references! BAD BAD BAD !<br/> +-- The closing should be handled automatically by the Zone class so no bother for authors +function _M:reopen() + if not self.closed then return end + self:redisplay() + self.closed = nil + self.changed = true +end + --- Cleans the FOV infos (seens table) function _M:cleanFOV() if not self.clean_fov then return end diff --git a/game/engines/default/engine/Zone.lua b/game/engines/default/engine/Zone.lua index d3c836d0219b38e112d7de7ec5b5f8dd568e743b..01365a2147e2257fb67ec59955268e36867ba77b 100644 --- a/game/engines/default/engine/Zone.lua +++ b/game/engines/default/engine/Zone.lua @@ -651,6 +651,9 @@ function _M:getLevel(game, lev, old_lev, no_close) -- Clean up things collectgarbage("collect") + -- Re-open the level if needed (the method does the check itself) + level.map:reopen() + return level end diff --git a/game/modules/tome/data/quests/trollmire-treasure.lua b/game/modules/tome/data/quests/trollmire-treasure.lua index 9f298f672bc25cd619fc982ba3e6e1bc1919786d..0fdd319b06c42b419ff612bca14783bb0da59a0d 100644 --- a/game/modules/tome/data/quests/trollmire-treasure.lua +++ b/game/modules/tome/data/quests/trollmire-treasure.lua @@ -47,7 +47,7 @@ enter_level3 = function(self) g.desc = "Beware!" g.change_level_check = function() require("engine.ui.Dialog"):yesnoPopup("Danger...", "This way lead to the lair of a mighty troll, traces of blood are everywhere. Are you sure?", function(ret) - if ret then game:changeLevel(4, "trollmire") end + if ret then game:changeLevel(4) end end) return true end