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.
This commit is contained in:
Kelsi 2026-03-29 18:39:52 -07:00
parent 6f6571fc7a
commit f681de0a08

View file

@ -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)});
}