*Fix a crash caused by possess pet. Thanks to nanouniko

--HG--
branch : trunk
This commit is contained in:
megamage
2009-08-26 21:30:45 -05:00
parent a6e7a83644
commit c5ff737ef8
2 changed files with 19 additions and 4 deletions
+13 -1
View File
@@ -5129,9 +5129,21 @@ SpellCastResult Spell::CheckCast(bool strict)
} }
break; break;
} }
case SPELL_AURA_MOD_POSSESS_PET:
{
if(m_caster->GetTypeId() != TYPEID_PLAYER)
return SPELL_FAILED_NO_PET;
Pet *pet = ((Player*)m_caster)->GetPet();
if(!pet)
return SPELL_FAILED_NO_PET;
if(pet->GetCharmerGUID())
return SPELL_FAILED_CHARMED;
break;
}
case SPELL_AURA_MOD_POSSESS: case SPELL_AURA_MOD_POSSESS:
case SPELL_AURA_MOD_CHARM: case SPELL_AURA_MOD_CHARM:
case SPELL_AURA_MOD_POSSESS_PET:
case SPELL_AURA_AOE_CHARM: case SPELL_AURA_AOE_CHARM:
{ {
if(m_caster->GetCharmerGUID()) if(m_caster->GetCharmerGUID())
+6 -3
View File
@@ -6724,6 +6724,7 @@ void AuraEffect::HandleModPossess(bool apply, bool Real, bool /*changeAmount*/)
m_target->RemoveCharmedBy(caster); m_target->RemoveCharmedBy(caster);
} }
// only one spell has this aura
void AuraEffect::HandleModPossessPet(bool apply, bool Real, bool /*changeAmount*/) void AuraEffect::HandleModPossessPet(bool apply, bool Real, bool /*changeAmount*/)
{ {
if(!Real) if(!Real)
@@ -6733,10 +6734,11 @@ void AuraEffect::HandleModPossessPet(bool apply, bool Real, bool /*changeAmount*
if(!caster || caster->GetTypeId() != TYPEID_PLAYER) if(!caster || caster->GetTypeId() != TYPEID_PLAYER)
return; return;
if(((Player*)caster)->GetPet() != m_target)
return;
if(apply) if(apply)
{ {
if(caster->GetGuardianPet() != m_target)
return;
m_target->SetCharmedBy(caster, CHARM_TYPE_POSSESS); m_target->SetCharmedBy(caster, CHARM_TYPE_POSSESS);
} }
else else
@@ -6748,7 +6750,8 @@ void AuraEffect::HandleModPossessPet(bool apply, bool Real, bool /*changeAmount*
if(!m_target->getVictim()) if(!m_target->getVictim())
{ {
m_target->GetMotionMaster()->MoveFollow(caster, PET_FOLLOW_DIST, m_target->GetFollowAngle()); m_target->GetMotionMaster()->MoveFollow(caster, PET_FOLLOW_DIST, m_target->GetFollowAngle());
m_target->GetCharmInfo()->SetCommandState(COMMAND_FOLLOW); if(m_target->GetCharmInfo())
m_target->GetCharmInfo()->SetCommandState(COMMAND_FOLLOW);
} }
} }
} }