feat: fire UNIT_THREAT_LIST_UPDATE event on threat changes

Fire UNIT_THREAT_LIST_UPDATE from SMSG_THREAT_UPDATE,
SMSG_HIGHEST_THREAT_UPDATE, and SMSG_THREAT_CLEAR. Threat data is
already parsed and stored in threatLists_ — this event notifies
addon systems when the data changes.

Used by Omen, ThreatPlates, and other threat meter addons to refresh
their displays when threat values update.
This commit is contained in:
Kelsi 2026-03-21 09:08:02 -07:00
parent f580fd7e6b
commit ac9214c03f

View file

@ -2848,6 +2848,7 @@ void GameHandler::handlePacket(network::Packet& packet) {
// All threat dropped on the local player (e.g. Vanish, Feign Death) // All threat dropped on the local player (e.g. Vanish, Feign Death)
threatLists_.clear(); threatLists_.clear();
LOG_DEBUG("SMSG_THREAT_CLEAR: threat wiped"); LOG_DEBUG("SMSG_THREAT_CLEAR: threat wiped");
if (addonEventCallback_) addonEventCallback_("UNIT_THREAT_LIST_UPDATE", {});
break; break;
case Opcode::SMSG_THREAT_REMOVE: { case Opcode::SMSG_THREAT_REMOVE: {
// packed_guid (unit) + packed_guid (victim whose threat was removed) // packed_guid (unit) + packed_guid (victim whose threat was removed)
@ -2891,6 +2892,8 @@ void GameHandler::handlePacket(network::Packet& packet) {
std::sort(list.begin(), list.end(), std::sort(list.begin(), list.end(),
[](const ThreatEntry& a, const ThreatEntry& b){ return a.threat > b.threat; }); [](const ThreatEntry& a, const ThreatEntry& b){ return a.threat > b.threat; });
threatLists_[unitGuid] = std::move(list); threatLists_[unitGuid] = std::move(list);
if (addonEventCallback_)
addonEventCallback_("UNIT_THREAT_LIST_UPDATE", {});
break; break;
} }