fix: include pet unit ID in all spellcast addon events

Add pet GUID check to all spellcast event dispatchers:
- UNIT_SPELLCAST_START
- UNIT_SPELLCAST_SUCCEEDED
- UNIT_SPELLCAST_CHANNEL_START
- UNIT_SPELLCAST_CHANNEL_STOP
- UNIT_SPELLCAST_INTERRUPTED + STOP

Previously these events only fired for player/target/focus, meaning
pet cast bars and pet spell tracking addons wouldn't work. Now pet
spellcasts properly fire with unitId="pet".
This commit is contained in:
Kelsi 2026-03-21 06:19:14 -07:00
parent 6687c617d9
commit b04e36aaa4

View file

@ -3452,6 +3452,7 @@ void GameHandler::handlePacket(network::Packet& packet) {
if (failGuid == playerGuid || failGuid == 0) unitId = "player"; if (failGuid == playerGuid || failGuid == 0) unitId = "player";
else if (failGuid == targetGuid) unitId = "target"; else if (failGuid == targetGuid) unitId = "target";
else if (failGuid == focusGuid) unitId = "focus"; else if (failGuid == focusGuid) unitId = "focus";
else if (failGuid == petGuid_) unitId = "pet";
if (!unitId.empty()) { if (!unitId.empty()) {
addonEventCallback_("UNIT_SPELLCAST_INTERRUPTED", {unitId}); addonEventCallback_("UNIT_SPELLCAST_INTERRUPTED", {unitId});
addonEventCallback_("UNIT_SPELLCAST_STOP", {unitId}); addonEventCallback_("UNIT_SPELLCAST_STOP", {unitId});
@ -7465,6 +7466,7 @@ void GameHandler::handlePacket(network::Packet& packet) {
if (chanCaster == playerGuid) unitId = "player"; if (chanCaster == playerGuid) unitId = "player";
else if (chanCaster == targetGuid) unitId = "target"; else if (chanCaster == targetGuid) unitId = "target";
else if (chanCaster == focusGuid) unitId = "focus"; else if (chanCaster == focusGuid) unitId = "focus";
else if (chanCaster == petGuid_) unitId = "pet";
if (!unitId.empty()) if (!unitId.empty())
addonEventCallback_("UNIT_SPELLCAST_CHANNEL_START", {unitId, std::to_string(chanSpellId)}); addonEventCallback_("UNIT_SPELLCAST_CHANNEL_START", {unitId, std::to_string(chanSpellId)});
} }
@ -7501,6 +7503,7 @@ void GameHandler::handlePacket(network::Packet& packet) {
if (chanCaster2 == playerGuid) unitId = "player"; if (chanCaster2 == playerGuid) unitId = "player";
else if (chanCaster2 == targetGuid) unitId = "target"; else if (chanCaster2 == targetGuid) unitId = "target";
else if (chanCaster2 == focusGuid) unitId = "focus"; else if (chanCaster2 == focusGuid) unitId = "focus";
else if (chanCaster2 == petGuid_) unitId = "pet";
if (!unitId.empty()) if (!unitId.empty())
addonEventCallback_("UNIT_SPELLCAST_CHANNEL_STOP", {unitId}); addonEventCallback_("UNIT_SPELLCAST_CHANNEL_STOP", {unitId});
} }
@ -19309,6 +19312,7 @@ void GameHandler::handleSpellStart(network::Packet& packet) {
if (data.casterUnit == playerGuid) unitId = "player"; if (data.casterUnit == playerGuid) unitId = "player";
else if (data.casterUnit == targetGuid) unitId = "target"; else if (data.casterUnit == targetGuid) unitId = "target";
else if (data.casterUnit == focusGuid) unitId = "focus"; else if (data.casterUnit == focusGuid) unitId = "focus";
else if (data.casterUnit == petGuid_) unitId = "pet";
if (!unitId.empty()) if (!unitId.empty())
addonEventCallback_("UNIT_SPELLCAST_START", {unitId, std::to_string(data.spellId)}); addonEventCallback_("UNIT_SPELLCAST_START", {unitId, std::to_string(data.spellId)});
} }
@ -19458,6 +19462,7 @@ void GameHandler::handleSpellGo(network::Packet& packet) {
if (data.casterUnit == playerGuid) unitId = "player"; if (data.casterUnit == playerGuid) unitId = "player";
else if (data.casterUnit == targetGuid) unitId = "target"; else if (data.casterUnit == targetGuid) unitId = "target";
else if (data.casterUnit == focusGuid) unitId = "focus"; else if (data.casterUnit == focusGuid) unitId = "focus";
else if (data.casterUnit == petGuid_) unitId = "pet";
if (!unitId.empty()) if (!unitId.empty())
addonEventCallback_("UNIT_SPELLCAST_SUCCEEDED", {unitId, std::to_string(data.spellId)}); addonEventCallback_("UNIT_SPELLCAST_SUCCEEDED", {unitId, std::to_string(data.spellId)});
} }