mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-12 07:43:51 +00:00
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:
parent
6f6571fc7a
commit
f681de0a08
1 changed files with 2 additions and 10 deletions
|
|
@ -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)});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue