aboutsummaryrefslogtreecommitdiff
path: root/src/game/Unit.cpp
diff options
context:
space:
mode:
authormegamage <none@none>2009-04-08 23:05:17 -0500
committermegamage <none@none>2009-04-08 23:05:17 -0500
commit031fe61a53cc3a9edd4883ffc0190095eba24905 (patch)
tree2410cb4578281d615b361bf49c24e0f68fad46b4 /src/game/Unit.cpp
parent0c5efdf9415153faecfa2d6de02630e094aa9a1d (diff)
*Fix a crash when a player with a charmed target removes the pet.
--HG-- branch : trunk
Diffstat (limited to 'src/game/Unit.cpp')
-rw-r--r--src/game/Unit.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index aba18ca3b9d..eb5bd306511 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -8012,7 +8012,7 @@ void Unit::SetGuardian(Guardian* guardian, bool apply)
if(AddUInt64Value(UNIT_FIELD_SUMMON, guardian->GetGUID()))
{
- if(GetTypeId() == TYPEID_PLAYER)
+ if(GetTypeId() == TYPEID_PLAYER && !GetCharmGUID())
{
if(guardian->isPet())
((Player*)this)->PetSpellInitialize();
@@ -8047,12 +8047,17 @@ void Unit::SetGuardian(Guardian* guardian, bool apply)
//Check if there is another guardian
for(ControlList::iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr)
{
+ if(GetCharmGUID() == (*itr)->GetGUID())
+ continue;
+
assert((*itr)->GetOwnerGUID() == GetGUID());
+ assert((*itr)->GetTypeId() == TYPEID_UNIT);
if(AddUInt64Value(UNIT_FIELD_SUMMON, (*itr)->GetGUID()))
{
- if(GetTypeId() == TYPEID_PLAYER)
+ //show another pet bar if there is no charm bar
+ if(GetTypeId() == TYPEID_PLAYER && !GetCharmGUID())
{
- if(guardian->isPet())
+ if(((Creature*)(*itr))->isPet())
((Player*)this)->PetSpellInitialize();
else
((Player*)this)->CharmSpellInitialize();