diff options
author | QAston <none@none> | 2009-04-19 22:21:40 +0200 |
---|---|---|
committer | QAston <none@none> | 2009-04-19 22:21:40 +0200 |
commit | caf9b7d356d49ce8a7a91c77bde6caae2934c580 (patch) | |
tree | 076375761c6096ee74b3aa0ff39010fc838d1412 /src/game/Unit.cpp | |
parent | b1360dc1e82403ba9910cc8b3a88dcd1b31b2ec9 (diff) |
*Prevent crash in EffectDispelMechanic.
--HG--
branch : trunk
Diffstat (limited to 'src/game/Unit.cpp')
-rw-r--r-- | src/game/Unit.cpp | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 764328480b7..4aee8dd99ba 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -499,18 +499,19 @@ void Unit::RemoveSpellbyDamageTaken(uint32 damage, uint32 spell) uint32 max_dmg = getLevel() > 8 ? 25 * getLevel() - 150 : 50; float chance = float(damage) / max_dmg * 100.0f; - // interrupt auras + std::queue < std::pair < uint32, uint64 > > remove_list; + for (AuraList::iterator iter = m_ccAuras.begin(); iter != m_ccAuras.end();) { - Aura * aur = *iter; - ++iter; - if ((!spell || aur->GetId() != spell) && roll_chance_f(chance)) - { - uint32 removedAuras = m_removedAurasCount; - RemoveAura(aur, AURA_REMOVE_BY_ENEMY_SPELL); - if (removedAuras+1 < m_removedAurasCount) - iter=m_ccAuras.begin(); - } + if((!spell || (*iter)->GetId() != spell) && roll_chance_f(chance)) + { + remove_list.push(std::make_pair((*iter)->GetId(), (*iter)->GetCasterGUID() ) ); + } + } + + for(;remove_list.size();remove_list.pop()) + { + RemoveAura(remove_list.front().first, remove_list.front().second, AURA_REMOVE_BY_ENEMY_SPELL); } } @@ -4051,17 +4052,19 @@ void Unit::RemoveAurasByType(AuraType auraType, uint64 casterGUID, Aura * except void Unit::RemoveAurasByTypeWithDispel(AuraType auraType, Spell * spell) { if (auraType >= TOTAL_AURAS) return; + std::queue < std::pair < uint32, uint64 > > remove_list; + for (AuraEffectList::iterator iter = m_modAuras[auraType].begin(); iter != m_modAuras[auraType].end();) { - Aura * aur = (*iter)->GetParentAura(); - ++iter; - if (GetDispelChance(aur->GetCaster(), aur->GetId())) - { - uint32 removedAuras = m_removedAurasCount; - RemoveAura(aur, AURA_REMOVE_BY_ENEMY_SPELL); - if (removedAuras+1<m_removedAurasCount) - iter=m_modAuras[auraType].begin(); - } + if(GetDispelChance((*iter)->GetCaster(), (*iter)->GetId())) + { + remove_list.push(std::make_pair((*iter)->GetId(), (*iter)->GetCasterGUID() ) ); + } + } + + for(;remove_list.size();remove_list.pop()) + { + RemoveAura(remove_list.front().first, remove_list.front().second, AURA_REMOVE_BY_ENEMY_SPELL); } } |