Fixed possible crash in Aura::HandleModPossessPet

Also small code cleanup.
This commit is contained in:
VladimirMangos 2008-12-09 11:47:49 +03:00
parent 6cee03bae0
commit 82cbd9152d
2 changed files with 22 additions and 15 deletions

View file

@ -1524,7 +1524,9 @@ void Pet::ToggleAutocast(uint32 spellid, bool apply)
if(apply)
{
for (i = 0; i < m_autospells.size() && m_autospells[i] != spellid; i++);
for (i = 0; i < m_autospells.size() && m_autospells[i] != spellid; i++)
; // just search
if (i == m_autospells.size())
{
m_autospells.push_back(spellid);
@ -1535,7 +1537,9 @@ void Pet::ToggleAutocast(uint32 spellid, bool apply)
else
{
AutoSpellList::iterator itr2 = m_autospells.begin();
for (i = 0; i < m_autospells.size() && m_autospells[i] != spellid; i++, itr2++);
for (i = 0; i < m_autospells.size() && m_autospells[i] != spellid; i++, itr2++)
; // just search
if (i < m_autospells.size())
{
m_autospells.erase(itr2);

View file

@ -3030,8 +3030,11 @@ void Aura::HandleModPossessPet(bool apply, bool Real)
return;
Unit* caster = GetCaster();
if(!caster || caster->GetTypeId() != TYPEID_PLAYER)
return;
Pet *pet = caster->GetPet();
if(!pet || (pet != m_target) || !caster || (caster->GetTypeId() != TYPEID_PLAYER))
if(!pet || pet != m_target)
return;
if(apply)