From f681de0a0867548d7a6476b0afd33cd52808a375 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Sun, 29 Mar 2026 18:39:52 -0700 Subject: [PATCH] refactor: use guidToUnitId() instead of inline 4-way GUID comparison handleSpellStart and handleSpellGo duplicated the player/target/focus/ pet GUID-to-unitId mapping that already exists in guidToUnitId(). If a new unit-id category is added (e.g. mouseover), these inline copies would not pick it up. --- src/game/spell_handler.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/game/spell_handler.cpp b/src/game/spell_handler.cpp index ddfd3266..e6baf8b7 100644 --- a/src/game/spell_handler.cpp +++ b/src/game/spell_handler.cpp @@ -897,11 +897,7 @@ void SpellHandler::handleSpellStart(network::Packet& packet) { // Fire UNIT_SPELLCAST_START if (owner_.addonEventCallback_) { - std::string unitId; - if (data.casterUnit == owner_.playerGuid) unitId = "player"; - else if (data.casterUnit == owner_.targetGuid) unitId = "target"; - else if (data.casterUnit == owner_.focusGuid) unitId = "focus"; - else if (data.casterUnit == owner_.petGuid_) unitId = "pet"; + std::string unitId = owner_.guidToUnitId(data.casterUnit); if (!unitId.empty()) owner_.addonEventCallback_("UNIT_SPELLCAST_START", {unitId, std::to_string(data.spellId)}); } @@ -1025,11 +1021,7 @@ void SpellHandler::handleSpellGo(network::Packet& packet) { // Fire UNIT_SPELLCAST_SUCCEEDED if (owner_.addonEventCallback_) { - std::string unitId; - if (data.casterUnit == owner_.playerGuid) unitId = "player"; - else if (data.casterUnit == owner_.targetGuid) unitId = "target"; - else if (data.casterUnit == owner_.focusGuid) unitId = "focus"; - else if (data.casterUnit == owner_.petGuid_) unitId = "pet"; + std::string unitId = owner_.guidToUnitId(data.casterUnit); if (!unitId.empty()) owner_.addonEventCallback_("UNIT_SPELLCAST_SUCCEEDED", {unitId, std::to_string(data.spellId)}); }