From f4e46db38a110c62013740df6e3feac28d22576c Mon Sep 17 00:00:00 2001 From: QAston Date: Sun, 26 Dec 2010 00:14:13 +0100 Subject: Core/Auras: Add some asserions to hunt down reason of a crash in Aura::UpdateTargetMap. Thanks to Shauren for inspiration. --HG-- branch : trunk --- src/server/game/Entities/GameObject/GameObject.cpp | 2 +- src/server/game/Entities/Unit/Unit.cpp | 3 +++ src/server/game/Spells/Auras/SpellAuras.cpp | 8 +++++--- 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 73499dad5bb..809f394a2f8 100755 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -1321,7 +1321,7 @@ void GameObject::Use(Unit* user) if (user->GetTypeId() != TYPEID_PLAYER) return; - Player* player = (Player*)user; + Player* player = user->ToPlayer(); Unit* owner = GetOwner(); diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index ab0dca5510f..226baa73ab5 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -3468,6 +3468,9 @@ AuraApplication * Unit::_CreateAuraApplication(Aura * aura, uint8 effMask) // aura musn't be removed ASSERT(!aura->IsRemoved()); + // aura mustn't be already applied on target + ASSERT (!aura->IsAppliedOnTarget(GetGUID()) && "Unit::_CreateAuraApplication: aura musn't be applied on target"); + SpellEntry const* aurSpellInfo = aura->GetSpellProto(); uint32 aurId = aurSpellInfo->Id; diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index aada5edc5fc..4a7ec595f28 100755 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -402,8 +402,8 @@ void Aura::_ApplyForTarget(Unit * target, Unit * caster, AuraApplication * auraA { ASSERT(target); ASSERT(auraApp); - // aura mustn't be already applied - ASSERT (m_applications.find(target->GetGUID()) == m_applications.end()); + // aura mustn't be already applied on target + ASSERT (!IsAppliedOnTarget(target->GetGUID()) && "Aura::_ApplyForTarget: aura musn't be already applied on target"); m_applications[target->GetGUID()] = auraApp; @@ -502,6 +502,9 @@ void Aura::UpdateTargetMap(Unit * caster, bool apply) // register auras for units for (std::map::iterator itr = targets.begin(); itr!= targets.end();) { + // aura mustn't be already applied on target + ASSERT (!IsAppliedOnTarget(itr->first->GetGUID()) && "Aura::UpdateTargetMap: aura musn't be applied on target"); + bool addUnit = true; // check target immunities if (itr->first->IsImmunedToSpell(GetSpellProto()) @@ -570,7 +573,6 @@ void Aura::UpdateTargetMap(Unit * caster, bool apply) // targets have to be registered and not have effect applied yet to use this function void Aura::_ApplyEffectForTargets(uint8 effIndex) { - //Unit * caster = GetCaster(); // prepare list of aura targets UnitList targetList; for (ApplicationMap::iterator appIter = m_applications.begin(); appIter != m_applications.end(); ++appIter) -- cgit v1.2.3