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 | |
parent | b1360dc1e82403ba9910cc8b3a88dcd1b31b2ec9 (diff) |
*Prevent crash in EffectDispelMechanic.
--HG--
branch : trunk
-rw-r--r-- | src/game/SpellEffects.cpp | 11 | ||||
-rw-r--r-- | src/game/Unit.cpp | 41 |
2 files changed, 26 insertions, 26 deletions
diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index cd1471055cb..f69bc3db828 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -5902,23 +5902,20 @@ void Spell::EffectDispelMechanic(uint32 i) uint32 mechanic = m_spellInfo->EffectMiscValue[i]; - std::queue < Aura * > dispel_list; + std::queue < std::pair < uint32, uint64 > > dispel_list; Unit::AuraMap& Auras = unitTarget->GetAuras(); for(Unit::AuraMap::iterator iter = Auras.begin(); iter != Auras.end(); iter++) { - if(GetAllSpellMechanicMask(iter->second->GetSpellProto()) & (1<<(mechanic))) + if((GetAllSpellMechanicMask(iter->second->GetSpellProto()) & (1<<(mechanic))) && GetDispelChance(iter->second->GetCaster(), iter->second->GetId())) { - dispel_list.push(iter->second); + dispel_list.push(std::make_pair(iter->second->GetId(), iter->second->GetCasterGUID() ) ); } } for(;dispel_list.size();dispel_list.pop()) { - if (GetDispelChance(dispel_list.front()->GetCaster(), dispel_list.front()->GetId())) - { - unitTarget->RemoveAura(dispel_list.front(), AURA_REMOVE_BY_ENEMY_SPELL); - } + unitTarget->RemoveAura(dispel_list.front().first, dispel_list.front().second, AURA_REMOVE_BY_ENEMY_SPELL); } } 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); } } |