mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Auras: Fixed possible iterator invalidation crashes caused by calling UpdateTargetMap inside loops iterating m_appliedAuras
Closes #28609
This commit is contained in:
@@ -4074,7 +4074,8 @@ void Unit::RemoveMovementImpairingAuras(bool withRoot)
|
||||
|
||||
void Unit::RemoveAurasWithMechanic(uint32 mechanicMaskToRemove, AuraRemoveMode removeMode, uint32 exceptSpellId, bool withEffectMechanics)
|
||||
{
|
||||
RemoveAppliedAuras([=](AuraApplication const* aurApp)
|
||||
std::vector<Aura*> aurasToUpdateTargets;
|
||||
RemoveAppliedAuras([=, &aurasToUpdateTargets](AuraApplication const* aurApp)
|
||||
{
|
||||
Aura* aura = aurApp->GetBase();
|
||||
if (exceptSpellId && aura->GetId() == exceptSpellId)
|
||||
@@ -4089,9 +4090,12 @@ void Unit::RemoveAurasWithMechanic(uint32 mechanicMaskToRemove, AuraRemoveMode r
|
||||
return true;
|
||||
|
||||
// effect mechanic matches required mask for removal - don't remove, only update targets
|
||||
aura->UpdateTargetMap(aura->GetCaster());
|
||||
aurasToUpdateTargets.push_back(aura);
|
||||
return false;
|
||||
}, removeMode);
|
||||
|
||||
for (Aura* aura : aurasToUpdateTargets)
|
||||
aura->UpdateTargetMap(aura->GetCaster());
|
||||
}
|
||||
|
||||
void Unit::RemoveAurasByShapeShift()
|
||||
|
||||
@@ -2861,15 +2861,19 @@ void SpellInfo::ApplyAllSpellImmunitiesTo(Unit* target, uint8 effIndex, bool app
|
||||
target->RemoveAurasWithMechanic(mechanicImmunity, AURA_REMOVE_BY_DEFAULT, Id);
|
||||
else
|
||||
{
|
||||
target->RemoveAppliedAuras([mechanicImmunity](AuraApplication const* aurApp)
|
||||
std::vector<Aura*> aurasToUpdateTargets;
|
||||
target->RemoveAppliedAuras([mechanicImmunity, &aurasToUpdateTargets](AuraApplication const* aurApp)
|
||||
{
|
||||
Aura* aura = aurApp->GetBase();
|
||||
if (aura->GetSpellInfo()->GetAllEffectsMechanicMask() & mechanicImmunity)
|
||||
aura->UpdateTargetMap(aura->GetCaster());
|
||||
aurasToUpdateTargets.push_back(aura);
|
||||
|
||||
// only update targets, don't remove anything
|
||||
return false;
|
||||
});
|
||||
|
||||
for (Aura* aura : aurasToUpdateTargets)
|
||||
aura->UpdateTargetMap(aura->GetCaster());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user