From dca6d6bb01cbaaec5ba15c885401cc3e120a5ed6 Mon Sep 17 00:00:00 2001 From: QAston Date: Thu, 16 Apr 2009 22:53:52 +0200 Subject: *Use safer method to check if any auras were removed while aura update --HG-- branch : trunk --- src/game/Unit.cpp | 44 ++++++++++++++++++++++++-------------------- src/game/Unit.h | 1 + 2 files changed, 25 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 267ef583f5e..da197ec7f5c 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -79,7 +79,7 @@ static bool procPrepared = InitTriggerAuraData(); Unit::Unit() : WorldObject(), i_motionMaster(this), m_ThreatManager(this), m_HostilRefManager(this) , m_IsInNotifyList(false), m_Notified(false), IsAIEnabled(false), NeedChangeAI(false) -, i_AI(NULL), i_disabledAI(NULL) +, i_AI(NULL), i_disabledAI(NULL), m_removedAurasCount(0) { m_objectType |= TYPEMASK_UNIT; m_objectTypeId = TYPEID_UNIT; @@ -461,9 +461,9 @@ void Unit::RemoveAurasWithInterruptFlags(uint32 flag, uint32 except) ++iter; if ((aur->GetSpellProto()->AuraInterruptFlags & flag) && (!except || aur->GetId() != except)) { - uint32 removedAuras = m_removedAuras.size(); - RemoveAura(aur, AURA_REMOVE_BY_EXPIRE); - if (removedAuras+1GetId() != spell) && roll_chance_f(chance)) { - uint32 removedAuras = m_removedAuras.size(); - RemoveAura(aur); - if (removedAuras+1 alreadyDone; - uint32 removedAuras = pVictim->m_removedAuras.size(); + uint32 removedAuras = pVictim->m_removedAurasCount; AuraEffectList const& vDamageShields = pVictim->GetAurasByType(SPELL_AURA_DAMAGE_SHIELD); for(AuraEffectList::const_iterator i = vDamageShields.begin(), next = vDamageShields.begin(); i != vDamageShields.end(); i = next) { @@ -1665,9 +1665,9 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss) pVictim->DealDamage(this, damage, 0, SPELL_DIRECT_DAMAGE, GetSpellSchoolMask(spellProto), spellProto, true); - if (pVictim->m_removedAuras.size() > removedAuras) + if (pVictim->m_removedAurasCount > removedAuras) { - removedAuras = pVictim->m_removedAuras.size(); + removedAuras = pVictim->m_removedAurasCount; next = vDamageShields.begin(); } } @@ -2060,9 +2060,9 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe ++i; if (auraeff->GetAmount()<=0) { - uint32 removedAuras = pVictim->m_removedAuras.size(); + uint32 removedAuras = pVictim->m_removedAurasCount; pVictim->RemoveAura(aura, AURA_REMOVE_BY_ENEMY_SPELL); - if (removedAuras+1m_removedAuras.size()) + if (removedAuras+1m_removedAurasCount) i=vSchoolAbsorb.begin(); } } @@ -3267,12 +3267,15 @@ void Unit::_UpdateSpells( uint32 time ) aur->SetUpdated(true); - uint32 removedAuras = m_removedAuras.size(); + m_removedAurasCount = 0; aur->Update( time ); // several auras can be deleted due to update - if(removedAuras < m_removedAuras.size()) + if(m_removedAurasCount) + { + m_removedAurasCount = 0; i = m_Auras.begin(); + } else ++i; } @@ -4025,9 +4028,9 @@ void Unit::RemoveAurasByType(AuraType auraType, uint64 casterGUID, Aura * except ++iter; if (aur != except && (!casterGUID || aur->GetCasterGUID()==casterGUID)) { - uint32 removedAuras = m_removedAuras.size(); + uint32 removedAuras = m_removedAurasCount; RemoveAura(aur); - if (removedAuras+1GetCaster(), aur->GetId())) { - uint32 removedAuras = m_removedAuras.size(); + uint32 removedAuras = m_removedAurasCount; RemoveAura(aur, AURA_REMOVE_BY_ENEMY_SPELL); - if (removedAuras+1GetTarget()!=this) { - uint32 removedAuras = m_removedAuras.size(); + uint32 removedAuras = m_removedAurasCount; aur->GetTarget()->RemoveAura(aur->GetId(),aur->GetCasterGUID()); - if (removedAuras+1UnregisterSingleCastAura(); diff --git a/src/game/Unit.h b/src/game/Unit.h index 3e7a93bad1f..d768ea28254 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1582,6 +1582,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject DeathState m_deathState; AuraMap m_Auras; + uint32 m_removedAurasCount; typedef std::list DynObjectGUIDs; DynObjectGUIDs m_dynObjGUIDs; -- cgit v1.2.3