feat: fire UNIT_DISPLAYPOWER when unit power type changes

When a unit's power type changes (e.g., druid shifting from mana to
rage in bear form, or warrior switching stances), fire UNIT_DISPLAYPOWER
so unit frame addons can switch the power bar display (mana blue bar →
rage red bar). Detected via UNIT_FIELD_BYTES_0 byte 3 changes in the
VALUES update path.
This commit is contained in:
Kelsi 2026-03-22 18:33:56 -07:00
parent 92a1e9b0c3
commit 81180086e3

View file

@ -12546,7 +12546,17 @@ void GameHandler::applyUpdateObjectBlock(const UpdateBlock& block, bool& newItem
// (Classic packs maxHealth/level/faction adjacent to power indices)
} else if (key == ufMaxHealth) { unit->setMaxHealth(val); healthChanged = true; }
else if (key == ufBytes0) {
uint8_t oldPT = unit->getPowerType();
unit->setPowerType(static_cast<uint8_t>((val >> 24) & 0xFF));
if (unit->getPowerType() != oldPT && addonEventCallback_) {
std::string uid;
if (block.guid == playerGuid) uid = "player";
else if (block.guid == targetGuid) uid = "target";
else if (block.guid == focusGuid) uid = "focus";
else if (block.guid == petGuid_) uid = "pet";
if (!uid.empty())
addonEventCallback_("UNIT_DISPLAYPOWER", {uid});
}
} else if (key == ufFlags) { unit->setUnitFlags(val); }
else if (key == ufDynFlags) {
uint32_t oldDyn = unit->getDynamicFlags();