feat(Core/Unit): Optimize AuraEffectList container (#22584)

This commit is contained in:
Takenbacon
2025-07-29 05:10:13 -07:00
committed by GitHub
parent cb580b9865
commit f31643c72c
4 changed files with 9 additions and 9 deletions

View File

@@ -1944,8 +1944,8 @@ bool WorldObject::CanDetectInvisibilityOf(WorldObject const* obj) const
bool isPermInvisibleCreature = false;
if (Creature const* baseObj = ToCreature())
{
auto auraEffects = baseObj->GetAuraEffectsByType(SPELL_AURA_MOD_INVISIBILITY);
for (auto const effect : auraEffects)
Unit::AuraEffectList const& auraEffects = baseObj->GetAuraEffectsByType(SPELL_AURA_MOD_INVISIBILITY);
for (AuraEffect* const effect : auraEffects)
{
if (SpellInfo const* spell = effect->GetSpellInfo())
{

View File

@@ -2256,7 +2256,7 @@ void Unit::CalcAbsorbResist(DamageInfo& dmgInfo, bool Splited)
// We're going to call functions which can modify content of the list during iteration over it's elements
// Let's copy the list so we can prevent iterator invalidation
AuraEffectList vSchoolAbsorbCopy(victim->GetAuraEffectsByType(SPELL_AURA_SCHOOL_ABSORB));
vSchoolAbsorbCopy.sort(Acore::AbsorbAuraOrderPred());
std::sort(vSchoolAbsorbCopy.begin(), vSchoolAbsorbCopy.end(), Acore::AbsorbAuraOrderPred());
// absorb without mana cost
for (AuraEffectList::iterator itr = vSchoolAbsorbCopy.begin(); (itr != vSchoolAbsorbCopy.end()) && (dmgInfo.GetDamage() > 0); ++itr)
@@ -2439,7 +2439,7 @@ void Unit::CalcAbsorbResist(DamageInfo& dmgInfo, bool Splited)
// We're going to call functions which can modify content of the list during iteration over it's elements
// Let's copy the list so we can prevent iterator invalidation
AuraEffectList vSplitDamagePctCopy(victim->GetAuraEffectsByType(SPELL_AURA_SPLIT_DAMAGE_PCT));
for (AuraEffectList::iterator itr = vSplitDamagePctCopy.begin(), next; (itr != vSplitDamagePctCopy.end()) && (dmgInfo.GetDamage() > 0); ++itr)
for (AuraEffectList::iterator itr = vSplitDamagePctCopy.begin(); (itr != vSplitDamagePctCopy.end()) && (dmgInfo.GetDamage() > 0); ++itr)
{
// Check if aura was removed during iteration - we don't need to work on such auras
AuraApplication const* aurApp = (*itr)->GetBase()->GetApplicationOfTarget(victim->GetGUID());
@@ -2565,7 +2565,7 @@ void Unit::CalcHealAbsorb(HealInfo& healInfo)
{
uint32 removedAuras = healInfo.GetTarget()->m_removedAurasCount;
auraEff->GetBase()->Remove(AURA_REMOVE_BY_ENEMY_SPELL);
if (removedAuras + 1 < healInfo.GetTarget()->m_removedAurasCount)
if (healInfo.GetTarget()->m_removedAurasCount > removedAuras)
i = vHealAbsorb.begin();
}
}
@@ -4732,7 +4732,7 @@ void Unit::_RegisterAuraEffect(AuraEffect* aurEff, bool apply)
if (apply)
m_modAuras[aurEff->GetAuraType()].push_back(aurEff);
else
m_modAuras[aurEff->GetAuraType()].remove(aurEff);
m_modAuras[aurEff->GetAuraType()].erase(std::remove(m_modAuras[aurEff->GetAuraType()].begin(), m_modAuras[aurEff->GetAuraType()].end(), aurEff), m_modAuras[aurEff->GetAuraType()].end());
}
// All aura base removes should go threw this function!
@@ -5158,7 +5158,7 @@ void Unit::RemoveAurasByType(AuraType auraType, ObjectGuid casterGUID, Aura* exc
{
uint32 removedAuras = m_removedAurasCount;
RemoveAura(aurApp);
if (m_removedAurasCount > removedAuras + 1)
if (m_removedAurasCount > removedAuras)
iter = m_modAuras[auraType].begin();
}
}

View File

@@ -633,7 +633,7 @@ public:
typedef std::multimap<AuraStateType, AuraApplication*> AuraStateAurasMap;
typedef std::pair<AuraStateAurasMap::const_iterator, AuraStateAurasMap::const_iterator> AuraStateAurasMapBounds;
typedef std::list<AuraEffect*> AuraEffectList;
typedef std::vector<AuraEffect*> AuraEffectList;
typedef std::list<Aura*> AuraList;
typedef std::list<AuraApplication*> AuraApplicationList;
typedef std::list<DiminishingReturn> Diminishing;

View File

@@ -910,7 +910,7 @@ class spell_warr_heroic_strike : public SpellScript
Unit* target = GetHitUnit();
if (!target)
return;
std::list<AuraEffect*> AuraEffectList = target->GetAuraEffectsByType(SPELL_AURA_MOD_DECREASE_SPEED);
Unit::AuraEffectList const& AuraEffectList = target->GetAuraEffectsByType(SPELL_AURA_MOD_DECREASE_SPEED);
bool bonusDamage = false;
for (AuraEffect* eff : AuraEffectList)
{