mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 04:37:00 +00:00
[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:
parent
031f2b00f1
commit
c3254c88ca
4 changed files with 23 additions and 19 deletions
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue