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 dc661a34b1)
This commit is contained in:
Shauren
2023-10-14 16:55:12 +02:00
parent 2df1bc3ec1
commit a85dcb6fc1
2 changed files with 8 additions and 21 deletions

View File

@@ -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)

View File

@@ -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