[10833] Avoid use unsafe remove auras in aura apply code.

Specailly example Aura::HandleModCharm code where old code
call RemoveSpellsCausingAura or (a) dead and not called,
or (b) will remove aura self at call.

* Added safe for aura holder context version of RemoveSpellsCausingAura
* Cleanup old simple RemoveSpellsCausingAura code also.
This commit is contained in:
VladimirMangos 2010-12-07 12:26:20 +03:00
parent 031f2b00f1
commit c3254c88ca
4 changed files with 23 additions and 19 deletions

View file

@ -2930,7 +2930,7 @@ void Aura::HandleAuraModShapeshift(bool apply, bool Real)
case FORM_MOONKIN:
{
// remove movement affects
target->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT);
target->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT, GetHolder());
Unit::AuraList const& slowingAuras = target->GetAurasByType(SPELL_AURA_MOD_DECREASE_SPEED);
for (Unit::AuraList::const_iterator iter = slowingAuras.begin(); iter != slowingAuras.end();)
{
@ -3227,7 +3227,7 @@ void Aura::HandleAuraTransform(bool apply, bool Real)
//dismount polymorphed target (after patch 2.4.2)
if (target->IsMounted())
target->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED);
target->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED, GetHolder());
}
}
else
@ -3639,11 +3639,9 @@ void Aura::HandleModCharm(bool apply, bool Real)
if( apply )
{
if (!target->GetCharmerGuid().IsEmpty())
{
target->RemoveSpellsCausingAura(SPELL_AURA_MOD_CHARM);
target->RemoveSpellsCausingAura(SPELL_AURA_MOD_POSSESS);
}
// is it really need after spell check checks?
target->RemoveSpellsCausingAura(SPELL_AURA_MOD_CHARM, GetHolder());
target->RemoveSpellsCausingAura(SPELL_AURA_MOD_POSSESS, GetHolder());
target->SetCharmerGuid(GetCasterGuid());
target->setFaction(caster->getFaction());

View file

@ -456,21 +456,26 @@ bool Unit::canReachWithAttack(Unit *pVictim) const
void Unit::RemoveSpellsCausingAura(AuraType auraType)
{
if (auraType >= TOTAL_AURAS) return;
AuraList::const_iterator iter, next;
for (iter = m_modAuras[auraType].begin(); iter != m_modAuras[auraType].end(); iter = next)
for (AuraList::const_iterator iter = m_modAuras[auraType].begin(); iter != m_modAuras[auraType].end();)
{
next = iter;
++next;
RemoveAurasDueToSpell((*iter)->GetId());
iter = m_modAuras[auraType].begin();
}
}
if (*iter)
void Unit::RemoveSpellsCausingAura(AuraType auraType, SpellAuraHolder* except)
{
for (AuraList::const_iterator iter = m_modAuras[auraType].begin(); iter != m_modAuras[auraType].end();)
{
// skip `except` aura
if ((*iter)->GetHolder() == except)
{
RemoveAurasDueToSpell((*iter)->GetId());
if (!m_modAuras[auraType].empty())
next = m_modAuras[auraType].begin();
else
return;
++iter;
continue;
}
RemoveAurasDueToSpell((*iter)->GetId(), except);
iter = m_modAuras[auraType].begin();
}
}

View file

@ -1602,6 +1602,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
void RemoveNotOwnSingleTargetAuras(uint32 newPhase = 0x0);
void RemoveAurasAtMechanicImmunity(uint32 mechMask, uint32 exceptSpellId, bool non_positive = false);
void RemoveSpellsCausingAura(AuraType auraType);
void RemoveSpellsCausingAura(AuraType auraType, SpellAuraHolder* except);
void RemoveRankAurasDueToSpell(uint32 spellId);
bool RemoveNoStackAurasDueToAuraHolder(SpellAuraHolder *holder);
void RemoveAurasWithInterruptFlags(uint32 flags);

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10832"
#define REVISION_NR "10833"
#endif // __REVISION_NR_H__