[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.
This commit is contained in:
VladimirMangos 2009-08-02 10:51:30 +04:00
parent 4841fae910
commit 822a34e2c7
3 changed files with 22 additions and 5 deletions

View file

@ -3878,13 +3878,24 @@ void Unit::RemoveAurasWithInterruptFlags(uint32 flags)
} }
} }
void Unit::RemoveNotOwnSingleTargetAuras() void Unit::RemoveNotOwnSingleTargetAuras(uint32 newPhase)
{ {
// single target auras from other casters // single target auras from other casters
for (AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end(); ) for (AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end(); )
{ {
if (iter->second->GetCasterGUID()!=GetGUID() && IsSingleTargetSpell(iter->second->GetSpellProto())) 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 else
++iter; ++iter;
} }
@ -3894,7 +3905,7 @@ void Unit::RemoveNotOwnSingleTargetAuras()
for (AuraList::iterator iter = scAuras.begin(); iter != scAuras.end(); ) for (AuraList::iterator iter = scAuras.begin(); iter != scAuras.end(); )
{ {
Aura* aura = *iter; 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 scAuras.erase(iter); // explicitly remove, instead waiting remove in RemoveAura
aura->GetTarget()->RemoveAura(aura); aura->GetTarget()->RemoveAura(aura);
@ -11823,6 +11834,12 @@ void Unit::RemoveAurasAtChanneledTarget(SpellEntry const* spellInfo)
void Unit::SetPhaseMask(uint32 newPhaseMask, bool update) 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); WorldObject::SetPhaseMask(newPhaseMask,update);
if(IsInWorld()) if(IsInWorld())

View file

@ -1209,7 +1209,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
void RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit *stealer); void RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit *stealer);
void RemoveAurasDueToSpellByCancel(uint32 spellId); void RemoveAurasDueToSpellByCancel(uint32 spellId);
void RemoveAurasAtChanneledTarget(SpellEntry const* spellInfo); void RemoveAurasAtChanneledTarget(SpellEntry const* spellInfo);
void RemoveNotOwnSingleTargetAuras(); void RemoveNotOwnSingleTargetAuras(uint32 newPhase = 0x0);
void RemoveSpellsCausingAura(AuraType auraType); void RemoveSpellsCausingAura(AuraType auraType);
void RemoveRankAurasDueToSpell(uint32 spellId); void RemoveRankAurasDueToSpell(uint32 spellId);

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "8294" #define REVISION_NR "8295"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__