* Fix some freezes.

* Fix freeze in HandleModMechanicImmunity- thanks for megamage for pointing this.

--HG--
branch : trunk
This commit is contained in:
QAston
2009-04-07 20:09:15 +02:00
parent 69657cad7c
commit 5e565cd777
6 changed files with 9301 additions and 9294 deletions
+1 -2
View File
@@ -7448,8 +7448,7 @@ bool ChatHandler::HandleUnFreezeCommand(const char *args)
player->RemoveFlag (UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
//allow movement and spells
uint32 spellID = 9454;
player->RemoveAurasDueToSpell(spellID);
player->RemoveAurasDueToSpell(9454);
//save player
player->SaveToDB();
+2 -1
View File
@@ -4063,7 +4063,7 @@ void AuraEffect::HandleModMechanicImmunity(bool apply, bool Real)
if(apply && GetSpellProto()->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY)
{
Unit::AuraMap& Auras = m_target->GetAuras();
for(Unit::AuraMap::iterator iter = Auras.begin(), next; iter != Auras.end();)
for(Unit::AuraMap::iterator iter = Auras.begin(); iter != Auras.end();)
{
SpellEntry const *spell = iter->second->GetSpellProto();
if (!( spell->Attributes & SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY) && // spells unaffected by invulnerability
@@ -4077,6 +4077,7 @@ void AuraEffect::HandleModMechanicImmunity(bool apply, bool Real)
else
++iter;
}
else
++iter;
}
}
+1 -1
View File
@@ -92,7 +92,7 @@ class TRINITY_DLL_SPEC Aura
void SetNegative() { m_positive = false; }
void SetPositive() { m_positive = true; }
bool IsPermanent() const { return m_permanent; }
void RemoveAura() { m_permanent = false; m_duration=0; m_removeMode = AURA_REMOVE_BY_DEFAULT; }
void RemoveAura(AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT) { m_permanent = false; m_duration=0; m_removeMode = mode; }
bool IsPassive() const { return m_isPassive; }
bool IsDeathPersistent() const { return m_isDeathPersist; }
+7 -10
View File
@@ -2059,8 +2059,7 @@ void Spell::EffectTriggerSpell(uint32 i)
// ignore positive and passive auras
&& !iter->second->IsPositive() && !iter->second->IsPassive())
{
m_caster->RemoveAurasDueToSpell(spell->Id);
iter = Auras.begin();
m_caster->RemoveAura(iter->second);
}
}
return;
@@ -4533,23 +4532,21 @@ void Spell::EffectScriptEffect(uint32 effIndex)
// Removes snares and roots.
uint32 mechanic_mask = (1<<MECHANIC_ROOT) | (1<<MECHANIC_SNARE);
Unit::AuraMap& Auras = unitTarget->GetAuras();
for(Unit::AuraMap::iterator iter = Auras.begin(), next; iter != Auras.end(); iter = next)
for(Unit::AuraMap::iterator iter = Auras.begin(), next; iter != Auras.end();)
{
next = iter;
++next;
Aura *aur = iter->second;
if (!aur->IsPositive()) //only remove negative spells
{
// check for mechanic mask
if(GetAllSpellMechanicMask(aur->GetSpellProto()) & mechanic_mask)
{
unitTarget->RemoveAurasDueToSpell(aur->GetId());
if(Auras.empty())
break;
unitTarget->RemoveAura(iter);
}
else
next = Auras.begin();
}
iter++;
}
else
iter++;
}
break;
}
+49 -40
View File
@@ -466,25 +466,13 @@ void Unit::RemoveAurasWithInterruptFlags(uint32 flag, uint32 except)
return;
// interrupt auras
AuraList::iterator iter, next;
for (iter = m_interruptableAuras.begin(); iter != m_interruptableAuras.end(); iter = next)
for (AuraList::iterator iter = m_interruptableAuras.begin(); iter != m_interruptableAuras.end();)
{
next = iter;
++next;
//sLog.outDetail("auraflag:%u flag:%u = %u",(*iter)->GetSpellProto()->AuraInterruptFlags,flag,(*iter)->GetSpellProto()->AuraInterruptFlags & flag);
if(*iter && ((*iter)->GetSpellProto()->AuraInterruptFlags & flag))
Aura * aur = *iter;
++iter;
if ((aur->GetSpellProto()->AuraInterruptFlags & flag) && (!except || aur->GetId() != except))
{
if((*iter)->IsInUse())
sLog.outError("Aura %u is trying to remove itself! Flag %u. May cause crash!", (*iter)->GetId(), flag);
else if(!except || (*iter)->GetId() != except)
{
RemoveAurasDueToSpell((*iter)->GetId(), NULL, AURA_REMOVE_BY_CANCEL);
if (!m_interruptableAuras.empty())
next = m_interruptableAuras.begin();
else
break;
}
RemoveAura(aur);
}
}
@@ -518,19 +506,14 @@ void Unit::RemoveSpellbyDamageTaken(uint32 damage, uint32 spell)
uint32 max_dmg = getLevel() > 8 ? 25 * getLevel() - 150 : 50;
float chance = float(damage) / max_dmg * 100.0f;
AuraList::iterator i, next;
for(i = m_ccAuras.begin(); i != m_ccAuras.end(); i = next)
// interrupt auras
for (AuraList::iterator iter = m_ccAuras.begin(); iter != m_ccAuras.end();)
{
next = i;
++next;
if(*i && (!spell || (*i)->GetId() != spell) && roll_chance_f(chance))
Aura * aur = *iter;
++iter;
if ((!spell || aur->GetId() != spell) && roll_chance_f(chance))
{
RemoveAurasDueToSpell((*i)->GetId());
if (!m_ccAuras.empty())
next = m_ccAuras.begin();
else
return;
RemoveAura(aur);
}
}
}
@@ -2095,13 +2078,13 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe
{
for(AuraEffectList::const_iterator i = vSchoolAbsorb.begin(); i != vSchoolAbsorb.end();)
{
if ((*i)->GetAmount()<=0)
{
pVictim->RemoveAurasDueToSpell((*i)->GetId(), (*i)->GetCasterGUID(), AURA_REMOVE_BY_ENEMY_SPELL);
i = vSchoolAbsorb.begin();
}
else
Aura *aura=(*i)->GetParentAura();
AuraEffect *auraeff =(*i);
++i;
if (auraeff->GetAmount()<=0)
{
pVictim->RemoveAura(aura);
}
}
}
// Cast back reflect damage spell
@@ -3889,6 +3872,26 @@ void Unit::RemoveAura(uint32 spellId, uint64 caster ,AuraRemoveMode removeMode)
}
}
void Unit::RemoveAura(Aura * aur ,AuraRemoveMode mode)
{
if (aur->IsInUse())
{
if (!aur->GetRemoveMode())
aur->RemoveAura(mode);
return;
}
for(AuraMap::iterator iter = m_Auras.lower_bound(aur->GetId()); iter != m_Auras.upper_bound(aur->GetId());)
{
if (aur == iter->second)
{
RemoveAura(iter, mode);
return;
}
else
++iter;
}
}
void Unit::RemoveAurasDueToSpell(uint32 spellId, uint64 caster ,AuraRemoveMode removeMode)
{
for(AuraMap::iterator iter = m_Auras.lower_bound(spellId); iter != m_Auras.upper_bound(spellId);)
@@ -4002,11 +4005,11 @@ void Unit::RemoveAurasByType(AuraType auraType, uint64 casterGUID, Aura * except
if (auraType >= TOTAL_AURAS) return;
for (AuraEffectList::iterator iter = m_modAuras[auraType].begin(); iter != m_modAuras[auraType].end();)
{
Aura const * aur = (*iter)->GetParentAura();
Aura * aur = (*iter)->GetParentAura();
++iter;
if (aur != except && (!casterGUID || aur->GetCasterGUID()==casterGUID))
{
RemoveAura(aur->GetId(), aur->GetCasterGUID(), AURA_REMOVE_BY_ENEMY_SPELL);
RemoveAura(aur);
}
}
}
@@ -4016,11 +4019,11 @@ void Unit::RemoveAurasByTypeWithDispel(AuraType auraType, Spell * spell)
if (auraType >= TOTAL_AURAS) return;
for (AuraEffectList::iterator iter = m_modAuras[auraType].begin(); iter != m_modAuras[auraType].end();)
{
Aura const* aur = (*iter)->GetParentAura();
Aura * aur = (*iter)->GetParentAura();
++iter;
if (GetDispelChance(spell, aur->GetCaster(), aur->GetId()))
{
RemoveAura(aur->GetId(), aur->GetCasterGUID(), AURA_REMOVE_BY_ENEMY_SPELL);
RemoveAura(aur, AURA_REMOVE_BY_ENEMY_SPELL);
}
}
}
@@ -4057,7 +4060,8 @@ void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode)
//aura can be during update when removing, set it to remove at next update
if (Aur->IsInUse())
{
Aur->RemoveAura();
if (!Aur->GetRemoveMode())
Aur->RemoveAura(mode);
i++;
return;
}
@@ -4111,7 +4115,6 @@ void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode)
{
caster->m_currentSpells[CURRENT_CHANNELED_SPELL]->cancel();
caster->m_currentSpells[CURRENT_CHANNELED_SPELL]=NULL;
}
}
@@ -11621,6 +11624,11 @@ void Unit::ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag
}
if (!inuse)
parentAura->SetInUse(false);
if ( !parentAura->GetAuraDuration() && !(parentAura->IsPermanent() || (parentAura->IsPassive())) )
RemoveAura(parentAura);
else
{
// Remove charge (aura can be removed by triggers)
if(useCharges && takeCharges)
{
@@ -11628,6 +11636,7 @@ void Unit::ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag
RemoveAura(parentAura->GetId(),parentAura->GetCasterGUID());
}
}
}
}
SpellSchoolMask Unit::GetMeleeDamageSchoolMask() const
+1
View File
@@ -1234,6 +1234,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
void RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT);
void RemoveAura(uint32 spellId, uint64 caster = 0 ,AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
void RemoveAura(Aura * aur, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT);
void RemoveAurasDueToSpell(uint32 spellId, uint64 caster = NULL ,AuraRemoveMode removeMode= AURA_REMOVE_BY_DEFAULT);
void RemoveAuraFromStack(uint32 spellId, uint64 caster = NULL ,AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
inline void RemoveAuraFromStack(AuraMap::iterator &iter,AuraRemoveMode removeMode);