From 2e879fe354b9681885a351a28f6619352ff535a7 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Fri, 20 Mar 2026 08:01:54 -0700 Subject: [PATCH] fix: sync item cooldowns to action bar slots on login The cooldown sync after SMSG_ACTION_BUTTONS and SMSG_INITIAL_SPELLS only handled SPELL-type action bar slots. ITEM-type slots (potions, trinkets, engineering items) were skipped, so items on the action bar showed no cooldown overlay after login even if their on-use spell was on cooldown. Now looks up each item's on-use spell IDs from the item info cache and syncs any matching spellCooldowns entries. --- src/game/game_handler.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/game/game_handler.cpp b/src/game/game_handler.cpp index 7059473d..71e4da73 100644 --- a/src/game/game_handler.cpp +++ b/src/game/game_handler.cpp @@ -4502,6 +4502,21 @@ void GameHandler::handlePacket(network::Packet& packet) { slot.cooldownRemaining = cdIt->second; slot.cooldownTotal = cdIt->second; } + } else if (slot.type == ActionBarSlot::ITEM && slot.id != 0) { + // Items (potions, trinkets): look up the item's on-use spell + // and check if that spell has a pending cooldown. + const auto* qi = getItemInfo(slot.id); + if (qi && qi->valid) { + for (const auto& sp : qi->spells) { + if (sp.spellId == 0) continue; + auto cdIt = spellCooldowns.find(sp.spellId); + if (cdIt != spellCooldowns.end() && cdIt->second > 0.0f) { + slot.cooldownRemaining = cdIt->second; + slot.cooldownTotal = cdIt->second; + break; + } + } + } } } LOG_INFO("SMSG_ACTION_BUTTONS: populated action bar from server"); @@ -18779,6 +18794,19 @@ void GameHandler::handleInitialSpells(network::Packet& packet) { slot.cooldownTotal = it->second; slot.cooldownRemaining = it->second; } + } else if (slot.type == ActionBarSlot::ITEM && slot.id != 0) { + const auto* qi = getItemInfo(slot.id); + if (qi && qi->valid) { + for (const auto& sp : qi->spells) { + if (sp.spellId == 0) continue; + auto it = spellCooldowns.find(sp.spellId); + if (it != spellCooldowns.end() && it->second > 0.0f) { + slot.cooldownTotal = it->second; + slot.cooldownRemaining = it->second; + break; + } + } + } } }