From 05cfcaacf6f99c6055321e79bbd7f353e72cf8cc Mon Sep 17 00:00:00 2001 From: Kelsi Date: Sun, 29 Mar 2026 19:16:18 -0700 Subject: [PATCH] fix: clearTarget fired PLAYER_TARGET_CHANGED before zeroing targetGuid MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/game/combat_handler.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/game/combat_handler.cpp b/src/game/combat_handler.cpp index 48675377..4fd94a4d 100644 --- a/src/game/combat_handler.cpp +++ b/src/game/combat_handler.cpp @@ -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; }