From 822a34e2c701089c52c395fac23f9b8632cca3fe Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Sun, 2 Aug 2009 10:51:30 +0400 Subject: [PATCH] [8295] Remove single target auras at caster/target shift to not accessable phase. This must fix another source of "Couldn't find the caster of the single target aura" errors. --- src/game/Unit.cpp | 23 ++++++++++++++++++++--- src/game/Unit.h | 2 +- src/shared/revision_nr.h | 2 +- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 0e055b1da..f5c300e79 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -3878,13 +3878,24 @@ void Unit::RemoveAurasWithInterruptFlags(uint32 flags) } } -void Unit::RemoveNotOwnSingleTargetAuras() +void Unit::RemoveNotOwnSingleTargetAuras(uint32 newPhase) { // single target auras from other casters for (AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end(); ) { if (iter->second->GetCasterGUID()!=GetGUID() && IsSingleTargetSpell(iter->second->GetSpellProto())) - RemoveAura(iter); + { + if(!newPhase) + RemoveAura(iter); + else + { + Unit* caster = iter->second->GetCaster(); + if(!caster || !caster->InSamePhase(newPhase)) + RemoveAura(iter); + else + ++iter; + } + } else ++iter; } @@ -3894,7 +3905,7 @@ void Unit::RemoveNotOwnSingleTargetAuras() for (AuraList::iterator iter = scAuras.begin(); iter != scAuras.end(); ) { Aura* aura = *iter; - if (aura->GetTarget() != this) + if (aura->GetTarget() != this && !aura->GetTarget()->InSamePhase(newPhase)) { scAuras.erase(iter); // explicitly remove, instead waiting remove in RemoveAura aura->GetTarget()->RemoveAura(aura); @@ -11823,6 +11834,12 @@ void Unit::RemoveAurasAtChanneledTarget(SpellEntry const* spellInfo) void Unit::SetPhaseMask(uint32 newPhaseMask, bool update) { + if(newPhaseMask==GetPhaseMask()) + return; + + if(IsInWorld()) + RemoveNotOwnSingleTargetAuras(newPhaseMask); // we can lost access to caster or target + WorldObject::SetPhaseMask(newPhaseMask,update); if(IsInWorld()) diff --git a/src/game/Unit.h b/src/game/Unit.h index 386f5181f..d59551093 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1209,7 +1209,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject void RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit *stealer); void RemoveAurasDueToSpellByCancel(uint32 spellId); void RemoveAurasAtChanneledTarget(SpellEntry const* spellInfo); - void RemoveNotOwnSingleTargetAuras(); + void RemoveNotOwnSingleTargetAuras(uint32 newPhase = 0x0); void RemoveSpellsCausingAura(AuraType auraType); void RemoveRankAurasDueToSpell(uint32 spellId); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 5a6dbd95c..56f454570 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8294" + #define REVISION_NR "8295" #endif // __REVISION_NR_H__