diff options
author | Subv <s.v.h21@hotmail.com> | 2012-12-14 11:06:56 -0500 |
---|---|---|
committer | Subv <s.v.h21@hotmail.com> | 2012-12-14 11:06:56 -0500 |
commit | 4b1e65d057a5a18c6c36defc6ca993ba62d2036f (patch) | |
tree | a68f6f2666ecf94a39f6c77d2eaef84320bb5164 | |
parent | 36c3e46fdb0bcd119aee0bffa42452f793a53386 (diff) |
Core/PetAI: Fixed a crash in PetAI::CanAttack
Closes #8660
-rw-r--r-- | src/server/game/AI/CoreAI/PetAI.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/server/game/AI/CoreAI/PetAI.cpp b/src/server/game/AI/CoreAI/PetAI.cpp index a860c8152c5..b7fa3940a20 100644 --- a/src/server/game/AI/CoreAI/PetAI.cpp +++ b/src/server/game/AI/CoreAI/PetAI.cpp @@ -550,10 +550,14 @@ bool PetAI::CanAttack(Unit* target) return (me->IsWithinMeleeRange(target) || me->GetCharmInfo()->IsCommandAttack()); // Pets attacking something (or chasing) should only switch targets if owner tells them to - if (me->getVictim() && (me->getVictim() != target)) + if (me->getVictim() && me->getVictim() != target) { // Check if our owner selected this target and clicked "attack" - Unit* ownerTarget = me->GetCharmerOrOwner()->ToPlayer()->GetSelectedUnit(); + Unit* ownerTarget = NULL; + if (Player* owner = me->GetCharmerOrOwner()->ToPlayer()) + ownerTarget = owner->GetSelectedUnit(); + else + ownerTarget = me->GetCharmerOrOwner()->getVictim(); if (ownerTarget && me->GetCharmInfo()->IsCommandAttack()) return (target->GetGUID() == ownerTarget->GetGUID()); |