aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2023-10-14 16:55:12 +0200
committerShauren <shauren.trinity@gmail.com>2023-10-14 16:55:38 +0200
commita85dcb6fc1e8008fe6808117ba474da8dee32787 (patch)
treee53c59eeaceac3efa0feae73eb9b06c544341bde /src
parent2df1bc3ec12d4a3ed7bac1274d8810ca3538607d (diff)
Core/Auras: Registering a new owned aura will now search existing owned auras instead of applied auras to check for unstackable one
Closes #22234 (cherry picked from commit dc661a34b1d1e099e2c1854e8fa9446115e30c96)
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp27
-rw-r--r--src/server/game/Entities/Unit/Unit.h2
2 files changed, 8 insertions, 21 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 1e515b48582..e0c3a42dedf 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -3269,7 +3269,7 @@ void Unit::_AddAura(UnitAura* aura, Unit* caster)
ASSERT(!m_cleanupDone);
m_ownedAuras.emplace(aura->GetId(), aura);
- _RemoveNoStackAurasDueToAura(aura);
+ _RemoveNoStackAurasDueToAura(aura, true);
if (aura->IsRemoved())
return;
@@ -3363,7 +3363,7 @@ void Unit::_ApplyAura(AuraApplication* aurApp, uint8 effMask)
{
Aura* aura = aurApp->GetBase();
- _RemoveNoStackAurasDueToAura(aura);
+ _RemoveNoStackAurasDueToAura(aura, false);
if (aurApp->GetRemoveMode())
return;
@@ -3517,7 +3517,7 @@ void Unit::_UnapplyAura(AuraApplication* aurApp, AuraRemoveMode removeMode)
ABORT();
}
-void Unit::_RemoveNoStackAurasDueToAura(Aura* aura)
+void Unit::_RemoveNoStackAurasDueToAura(Aura* aura, bool owned)
{
SpellInfo const* spellProto = aura->GetSpellInfo();
@@ -3531,23 +3531,10 @@ void Unit::_RemoveNoStackAurasDueToAura(Aura* aura)
return;
}
- bool remove = false;
- for (AuraApplicationMap::iterator i = m_appliedAuras.begin(); i != m_appliedAuras.end(); ++i)
- {
- if (remove)
- {
- remove = false;
- i = m_appliedAuras.begin();
- }
-
- if (aura->CanStackWith(i->second->GetBase()))
- continue;
-
- RemoveAura(i, AURA_REMOVE_BY_DEFAULT);
- if (i == m_appliedAuras.end())
- break;
- remove = true;
- }
+ if (owned)
+ RemoveOwnedAuras([aura](Aura const* ownedAura) { return !aura->CanStackWith(ownedAura); }, AURA_REMOVE_BY_DEFAULT);
+ else
+ RemoveAppliedAuras([aura](AuraApplication const* appliedAura) { return !aura->CanStackWith(appliedAura->GetBase()); }, AURA_REMOVE_BY_DEFAULT);
}
void Unit::_RegisterAuraEffect(AuraEffect* aurEff, bool apply)
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index 99fb781cef8..1e2753842f2 100644
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -1320,7 +1320,7 @@ class TC_GAME_API Unit : public WorldObject
void _ApplyAura(AuraApplication* aurApp, uint8 effMask);
void _UnapplyAura(AuraApplicationMap::iterator& i, AuraRemoveMode removeMode);
void _UnapplyAura(AuraApplication* aurApp, AuraRemoveMode removeMode);
- void _RemoveNoStackAurasDueToAura(Aura* aura);
+ void _RemoveNoStackAurasDueToAura(Aura* aura, bool owned);
void _RegisterAuraEffect(AuraEffect* aurEff, bool apply);
// m_ownedAuras container management