feat: fire ACTIONBAR_UPDATE_USABLE on player power changes

When the player's mana/rage/energy changes, action bar addons need
ACTIONBAR_UPDATE_USABLE to update button dimming (grey out abilities
the player can't afford). Now fires from both the SMSG_POWER_UPDATE
handler and the SMSG_UPDATE_OBJECT VALUES power field change path.

Without this event, action bar buttons showed as usable even when the
player ran out of mana — the usability state only refreshed on spell
cast attempts, not on power changes.
This commit is contained in:
Kelsi 2026-03-22 18:53:11 -07:00
parent 8fd1dfb4f1
commit 661fba12c0

View file

@ -2199,8 +2199,11 @@ void GameHandler::handlePacket(network::Packet& packet) {
else if (guid == targetGuid) unitId = "target";
else if (guid == focusGuid) unitId = "focus";
else if (guid == petGuid_) unitId = "pet";
if (!unitId.empty())
if (!unitId.empty()) {
addonEventCallback_("UNIT_POWER", {unitId});
if (guid == playerGuid)
addonEventCallback_("ACTIONBAR_UPDATE_USABLE", {});
}
}
break;
}
@ -12675,7 +12678,12 @@ void GameHandler::applyUpdateObjectBlock(const UpdateBlock& block, bool& newItem
else if (block.guid == petGuid_) unitId = "pet";
if (!unitId.empty()) {
if (healthChanged) addonEventCallback_("UNIT_HEALTH", {unitId});
if (powerChanged) addonEventCallback_("UNIT_POWER", {unitId});
if (powerChanged) {
addonEventCallback_("UNIT_POWER", {unitId});
// When player power changes, action bar usability may change
if (block.guid == playerGuid)
addonEventCallback_("ACTIONBAR_UPDATE_USABLE", {});
}
}
}