diff --git a/modules/game_creatureinformation/creatureinformation.lua b/modules/game_creatureinformation/creatureinformation.lua index 2dca4ba547..1423bc32b3 100644 --- a/modules/game_creatureinformation/creatureinformation.lua +++ b/modules/game_creatureinformation/creatureinformation.lua @@ -180,11 +180,13 @@ function toggleInformation() end end -function controller:onGameStart() +function controller:onInit() controller:registerEvents(Creature, creatureEvents) controller:registerEvents(LocalPlayer, { onManaChange = onManaChange }) +end - if devMode then +if devMode then + function controller:onGameStart() local spectators = modules.game_interface.getMapPanel():getSpectators() for _, creature in ipairs(spectators) do onCreate(creature) diff --git a/modules/game_interface/interface.otmod b/modules/game_interface/interface.otmod index 75cca2ddf9..34c78c9c4c 100644 --- a/modules/game_interface/interface.otmod +++ b/modules/game_interface/interface.otmod @@ -49,6 +49,7 @@ Module - game_store - game_quickloot - game_cyclopedia + - game_creatureinformation @onLoad: init() @onUnload: terminate() \ No newline at end of file diff --git a/src/client/map.cpp b/src/client/map.cpp index e2feb1857c..1db773978a 100644 --- a/src/client/map.cpp +++ b/src/client/map.cpp @@ -126,6 +126,13 @@ void Map::cleanDynamicThings() for (const auto& mapview : m_mapViews) mapview->followCreature(nullptr); + for (const auto& [uid, creature] : m_knownCreatures) { + creature->setWidgetInformation(nullptr); + removeThing(creature); + } + + m_knownCreatures.clear(); + std::vector widgets; widgets.reserve(m_attachedObjectWidgetMap.size()); @@ -137,15 +144,12 @@ void Map::cleanDynamicThings() for (const auto& widget : widgets) widget->destroy(); - for (const auto& [uid, creature] : m_knownCreatures) - removeThing(creature); - - m_knownCreatures.clear(); - for (auto i = -1; ++i <= g_gameConfig.getMapMaxZ();) m_floors[i].missiles.clear(); cleanTexts(); + + g_lua.collectGarbage(); } void Map::addThing(const ThingPtr& thing, const Position& pos, const int16_t stackPos)