From 3ae18f03a159223fb8f18226eae27a9130774f9e Mon Sep 17 00:00:00 2001 From: Kelsi Date: Sat, 21 Mar 2026 01:55:30 -0700 Subject: [PATCH] feat: fire UNIT_HEALTH/POWER/AURA events for party members; fix closeLoot event MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fire UNIT_HEALTH, UNIT_POWER, and UNIT_AURA events from SMSG_PARTY_MEMBER_STATS with proper unit IDs (party1..4, raid1..40). Previously, health/power changes for party members via the stats packet were silent — raid frame addons never got notified. Also fix closeLoot() not firing LOOT_CLOSED event when the loot window is closed by the player (only handleLootReleaseResponse fired it). --- src/game/game_handler.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/game/game_handler.cpp b/src/game/game_handler.cpp index 01abd3dc..d26a673a 100644 --- a/src/game/game_handler.cpp +++ b/src/game/game_handler.cpp @@ -20130,6 +20130,40 @@ void GameHandler::handlePartyMemberStats(network::Packet& packet, bool isFull) { LOG_DEBUG("Party member stats for ", member->name, ": HP=", member->curHealth, "/", member->maxHealth, " Level=", member->level); + + // Fire addon events for party/raid member health/power/aura changes + if (addonEventCallback_) { + // Resolve unit ID for this member (party1..4 or raid1..40) + std::string unitId; + if (partyData.groupType == 1) { + // Raid: find 1-based index + for (size_t i = 0; i < partyData.members.size(); ++i) { + if (partyData.members[i].guid == memberGuid) { + unitId = "raid" + std::to_string(i + 1); + break; + } + } + } else { + // Party: find 1-based index excluding self + int found = 0; + for (const auto& m : partyData.members) { + if (m.guid == playerGuid) continue; + ++found; + if (m.guid == memberGuid) { + unitId = "party" + std::to_string(found); + break; + } + } + } + if (!unitId.empty()) { + if (updateFlags & (0x0002 | 0x0004)) // CUR_HP or MAX_HP + addonEventCallback_("UNIT_HEALTH", {unitId}); + if (updateFlags & (0x0010 | 0x0020)) // CUR_POWER or MAX_POWER + addonEventCallback_("UNIT_POWER", {unitId}); + if (updateFlags & 0x0200) // AURAS + addonEventCallback_("UNIT_AURA", {unitId}); + } + } } // ============================================================ @@ -20660,6 +20694,7 @@ void GameHandler::lootItem(uint8_t slotIndex) { void GameHandler::closeLoot() { if (!lootWindowOpen) return; lootWindowOpen = false; + if (addonEventCallback_) addonEventCallback_("LOOT_CLOSED", {}); masterLootCandidates_.clear(); if (currentLoot.lootGuid != 0 && targetGuid == currentLoot.lootGuid) { clearTarget();