mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-22 23:30:14 +00:00
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.
This commit is contained in:
parent
625754f0f7
commit
2e879fe354
1 changed files with 28 additions and 0 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue