From cc0ad5165cb925ca75730dbbf6f50950d371e51b Mon Sep 17 00:00:00 2001 From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54> Date: Fri, 27 May 2011 09:35:01 +0000 Subject: [PATCH] Fixed the "black map" bug git-svn-id: http://svn.net-core.org/repos/t-engine4@3449 51575b47-30f0-44d4-a5cc-537603b46e54 --- game/engines/default/engine/Map.lua | 12 +++++++++++- game/engines/default/engine/Zone.lua | 3 +++ game/modules/tome/data/quests/trollmire-treasure.lua | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/game/engines/default/engine/Map.lua b/game/engines/default/engine/Map.lua index 337ae86683..36a4666e2e 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 d3c836d021..01365a2147 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 9f298f672b..0fdd319b06 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 -- GitLab