diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 6a19f9a5b..8053542a1 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -6952,9 +6952,7 @@ void Aura::UnregisterSingleCastAura() { if (IsSingleTarget()) { - Unit* caster = NULL; - caster = GetCaster(); - if(caster) + if(Unit* caster = GetCaster()) { caster->GetSingleCastAuras().remove(this); } diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 39ba61708..bbbd91486 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -3892,10 +3892,10 @@ void Unit::RemoveNotOwnSingleTargetAuras() for (AuraList::iterator iter = scAuras.begin(); iter != scAuras.end(); ) { Aura* aura = *iter; - if (aura->GetTarget()!=this) + if (aura->GetTarget() != this) { scAuras.erase(iter); // explicitly remove, instead waiting remove in RemoveAura - aura->GetTarget()->RemoveAura(aura->GetId(),aura->GetEffIndex()); + aura->GetTarget()->RemoveAura(aura); iter = scAuras.begin(); } else @@ -3904,6 +3904,21 @@ void Unit::RemoveNotOwnSingleTargetAuras() } +void Unit::RemoveAura(Aura* aura) +{ + AuraMap::iterator i = m_Auras.lower_bound(spellEffectPair(aura->GetId(), aura->GetEffIndex())); + AuraMap::iterator upperBound = m_Auras.upper_bound(spellEffectPair(aura->GetId(), aura->GetEffIndex())); + for (; i != upperBound; ++i) + { + if (i->second == aura) + { + RemoveAura(i); + return; + } + } + sLog.outDebug("Trying to remove aura id %u effect %u by pointer but aura not found on target", aura->GetId(), aura->GetEffIndex()); +} + void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode) { Aura* Aur = i->second; diff --git a/src/game/Unit.h b/src/game/Unit.h index 0dd34089b..7abb97e6b 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1196,6 +1196,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject bool AddAura(Aura *aur); + void RemoveAura(Aura* aura); void RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); void RemoveAura(uint32 spellId, uint32 effindex, Aura* except = NULL); void RemoveSingleSpellAurasFromStack(uint32 spellId); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 82f30409c..d889aa33a 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 "8235" + #define REVISION_NR "8236" #endif // __REVISION_NR_H__