fix: clearTarget fired PLAYER_TARGET_CHANGED before zeroing targetGuid

Callbacks and addons querying the current target during this event saw
the old (stale) target instead of null. setTarget correctly updates the
GUID before firing — clearTarget now does the same.
This commit is contained in:
Kelsi 2026-03-29 19:16:18 -07:00
parent bf63d8e385
commit 05cfcaacf6

View file

@ -1070,9 +1070,14 @@ void CombatHandler::setTarget(uint64_t guid) {
void CombatHandler::clearTarget() {
if (owner_.targetGuid != 0) {
LOG_INFO("Target cleared");
// Zero the GUID before firing the event so callbacks/addons that query
// the current target see null (consistent with setTarget which updates
// targetGuid before the event).
owner_.targetGuid = 0;
owner_.fireAddonEvent("PLAYER_TARGET_CHANGED", {});
} else {
owner_.targetGuid = 0;
}
owner_.targetGuid = 0;
owner_.tabCycleIndex = -1;
owner_.tabCycleStale = true;
}