aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSubv <s.v.h21@hotmail.com>2012-12-14 11:06:56 -0500
committerSubv <s.v.h21@hotmail.com>2012-12-14 11:06:56 -0500
commit4b1e65d057a5a18c6c36defc6ca993ba62d2036f (patch)
treea68f6f2666ecf94a39f6c77d2eaef84320bb5164 /src
parent36c3e46fdb0bcd119aee0bffa42452f793a53386 (diff)
Core/PetAI: Fixed a crash in PetAI::CanAttack
Closes #8660
Diffstat (limited to 'src')
-rw-r--r--src/server/game/AI/CoreAI/PetAI.cpp8
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());