fix: invalidate macro spell cache when spells are learned/removed

The macro primary spell cache stored 0 (no spell found) when a macro
referenced a spell the player hadn't learned yet. After learning the
spell from a trainer or leveling up, the cache was never refreshed,
so the macro button stayed broken. Now tracks the known spell count
and clears the cache when it changes, ensuring newly learned spells
are resolved on the next frame.
This commit is contained in:
Kelsi 2026-03-20 08:52:57 -07:00
parent 87e1ac7cdd
commit b960a1cdd5
2 changed files with 7 additions and 0 deletions

View file

@ -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;