diff --git a/include/ui/game_screen.hpp b/include/ui/game_screen.hpp index a4ca889b..cd200126 100644 --- a/include/ui/game_screen.hpp +++ b/include/ui/game_screen.hpp @@ -437,6 +437,7 @@ private: // Macro cooldown cache: maps macro ID → resolved primary spell ID (0 = no spell found) std::unordered_map macroPrimarySpellCache_; + size_t macroCacheSpellCount_ = 0; // invalidates cache when spell list changes uint32_t resolveMacroPrimarySpellId(uint32_t macroId, game::GameHandler& gameHandler); // Death Knight rune bar: client-predicted fill (0.0=depleted, 1.0=ready) for smooth animation diff --git a/src/ui/game_screen.cpp b/src/ui/game_screen.cpp index 7c4bd892..fafe0379 100644 --- a/src/ui/game_screen.cpp +++ b/src/ui/game_screen.cpp @@ -8643,6 +8643,12 @@ VkDescriptorSet GameScreen::getSpellIcon(uint32_t spellId, pipeline::AssetManage } uint32_t GameScreen::resolveMacroPrimarySpellId(uint32_t macroId, game::GameHandler& gameHandler) { + // Invalidate cache when spell list changes (learning/unlearning spells) + size_t curSpellCount = gameHandler.getKnownSpells().size(); + if (curSpellCount != macroCacheSpellCount_) { + macroPrimarySpellCache_.clear(); + macroCacheSpellCount_ = curSpellCount; + } auto cacheIt = macroPrimarySpellCache_.find(macroId); if (cacheIt != macroPrimarySpellCache_.end()) return cacheIt->second;