*Prevent crash in EffectDispelMechanic.

--HG--
branch : trunk
This commit is contained in:
QAston
2009-04-19 22:21:40 +02:00
parent b1360dc1e8
commit caf9b7d356
2 changed files with 26 additions and 26 deletions

View File

@@ -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);
}
}

View File

@@ -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);
}
}