Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: widget reference in creature information #1058

Merged
merged 1 commit into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions modules/game_creatureinformation/creatureinformation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions modules/game_interface/interface.otmod
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Module
- game_store
- game_quickloot
- game_cyclopedia
- game_creatureinformation

@onLoad: init()
@onUnload: terminate()
14 changes: 9 additions & 5 deletions src/client/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<UIWidgetPtr> widgets;
widgets.reserve(m_attachedObjectWidgetMap.size());

Expand All @@ -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)
Expand Down
Loading