fix: sync pending spell cooldowns to action bar after login

SMSG_SPELL_COOLDOWN arrives before SMSG_ACTION_BUTTONS during login,
so cooldown times were stored in spellCooldowns but never applied to
the newly populated action bar slots. Players would see all abilities
as ready immediately after login even if spells were on cooldown.
Now applies pending cooldowns from the spellCooldowns map to each
matching slot when the action bar is first populated.
This commit is contained in:
Kelsi 2026-03-20 06:59:23 -07:00
parent 72993121ab
commit 533831e18d

View file

@ -4492,6 +4492,18 @@ void GameHandler::handlePacket(network::Packet& packet) {
} }
actionBar[i] = slot; actionBar[i] = slot;
} }
// Apply any pending cooldowns from spellCooldowns to newly populated slots.
// SMSG_SPELL_COOLDOWN often arrives before SMSG_ACTION_BUTTONS during login,
// so the per-slot cooldownRemaining would be 0 without this sync.
for (auto& slot : actionBar) {
if (slot.type == ActionBarSlot::SPELL && slot.id != 0) {
auto cdIt = spellCooldowns.find(slot.id);
if (cdIt != spellCooldowns.end() && cdIt->second > 0.0f) {
slot.cooldownRemaining = cdIt->second;
slot.cooldownTotal = cdIt->second;
}
}
}
LOG_INFO("SMSG_ACTION_BUTTONS: populated action bar from server"); LOG_INFO("SMSG_ACTION_BUTTONS: populated action bar from server");
packet.setReadPos(packet.getSize()); packet.setReadPos(packet.getSize());
break; break;