From c58fc3073f4dbcd39384c78a17453bfe12ec7786 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Fri, 13 Mar 2026 06:11:10 -0700 Subject: [PATCH] fix: clear action bar slots when spells are removed or unlearned SMSG_REMOVED_SPELL and SMSG_SEND_UNLEARN_SPELLS both erased spells from knownSpells but left stale references on the action bar. After a respec or forced spell removal, action bar buttons would show removed talents and spells as still present. Now both handlers clear matching slots and persist the updated bar layout. --- src/game/game_handler.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/game/game_handler.cpp b/src/game/game_handler.cpp index 157fc8eb..778c8980 100644 --- a/src/game/game_handler.cpp +++ b/src/game/game_handler.cpp @@ -16565,6 +16565,16 @@ void GameHandler::handleRemovedSpell(network::Packet& packet) { uint32_t spellId = classicSpellId ? packet.readUInt16() : packet.readUInt32(); knownSpells.erase(spellId); LOG_INFO("Removed spell: ", spellId); + + // Clear any action bar slots referencing this spell + bool barChanged = false; + for (auto& slot : actionBar) { + if (slot.type == ActionBarSlot::SPELL && slot.id == spellId) { + slot = ActionBarSlot{}; + barChanged = true; + } + } + if (barChanged) saveCharacterConfig(); } void GameHandler::handleSupercededSpell(network::Packet& packet) { @@ -16622,11 +16632,19 @@ void GameHandler::handleUnlearnSpells(network::Packet& packet) { uint32_t spellCount = packet.readUInt32(); LOG_INFO("Unlearning ", spellCount, " spells"); + bool barChanged = false; for (uint32_t i = 0; i < spellCount && packet.getSize() - packet.getReadPos() >= 4; ++i) { uint32_t spellId = packet.readUInt32(); knownSpells.erase(spellId); LOG_INFO(" Unlearned spell: ", spellId); + for (auto& slot : actionBar) { + if (slot.type == ActionBarSlot::SPELL && slot.id == spellId) { + slot = ActionBarSlot{}; + barChanged = true; + } + } } + if (barChanged) saveCharacterConfig(); if (spellCount > 0) { addSystemChatMessage("Unlearned " + std::to_string(spellCount) + " spells");