Core/Auras: Recheck aura presence on target after calling linked events in aura effect handlers. Prevents undefined behavious when aura effect remove handler is called before apply handler is finished.

This commit is contained in:
QAston
2010-12-31 14:39:18 +01:00
parent c220fbbc45
commit 4eccbb81af

View File

@@ -988,8 +988,11 @@ void AuraEffect::HandleEffect(AuraApplication const * aurApp, uint8 mode, bool a
else
prevented = GetBase()->CallScriptEffectRemoveHandlers(const_cast<AuraEffect const *>(this), aurApp, (AuraEffectHandleModes)mode);
if (!prevented)
(*this.*AuraEffectHandler [GetAuraType()])(aurApp, mode, apply);
// check if script events have removed the aura or if default effect prevention was requested
if ((apply && aurApp->GetRemoveMode()) || prevented)
return;
(*this.*AuraEffectHandler [GetAuraType()])(aurApp, mode, apply);
}
void AuraEffect::HandleEffect(Unit * target, uint8 mode, bool apply)
@@ -2828,6 +2831,10 @@ void AuraEffect::HandleModStealth(AuraApplication const * aurApp, uint8 mode, bo
target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION);
}
// stop handling the effect if it was removed by linked event
if (aurApp->GetRemoveMode())
return;
target->m_stealth.AddFlag( type);
target->m_stealth.AddValue(type, GetAmount());
@@ -2953,6 +2960,10 @@ void AuraEffect::HandlePhase(AuraApplication const * aurApp, uint8 mode, bool ap
if (Battleground *bg = player->GetBattleground())
bg->EventPlayerDroppedFlag(player);
// stop handling the effect if it was removed by linked event
if (aurApp->GetRemoveMode())
return;
// GM-mode have mask 0xFFFFFFFF
if (player->isGameMaster())
newPhase = 0xFFFFFFFF;
@@ -3071,6 +3082,10 @@ void AuraEffect::HandleAuraModShapeshift(AuraApplication const * aurApp, uint8 m
// remove other shapeshift before applying a new one
target->RemoveAurasByType(SPELL_AURA_MOD_SHAPESHIFT, 0, GetBase());
// stop handling the effect if it was removed by linked event
if (aurApp->GetRemoveMode())
return;
if (modelid > 0)
target->SetDisplayId(modelid);
@@ -3117,6 +3132,9 @@ void AuraEffect::HandleAuraModShapeshift(AuraApplication const * aurApp, uint8 m
break;
}
}
// stop handling the effect if it was removed by linked event
if (aurApp->GetRemoveMode())
return;
target->SetShapeshiftForm(form);
}
@@ -3221,6 +3239,10 @@ void AuraEffect::HandleAuraModShapeshift(AuraApplication const * aurApp, uint8 m
}
}
// stop handling the effect if it was removed by linked event
if (apply && aurApp->GetRemoveMode())
return;
if (target->GetTypeId() == TYPEID_PLAYER)
{
SpellShapeshiftEntry const *shapeInfo = sSpellShapeshiftStore.LookupEntry(form);
@@ -3485,14 +3507,6 @@ void AuraEffect::HandleFeignDeath(AuraApplication const * aurApp, uint8 mode, bo
}
}
}
// blizz like 2.0.x
target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_29);
// blizz like 2.0.x
target->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH);
// blizz like 2.0.x
target->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD);
target->AddUnitState(UNIT_STAT_DIED);
target->CombatStop();
target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION);
@@ -3501,6 +3515,18 @@ void AuraEffect::HandleFeignDeath(AuraApplication const * aurApp, uint8 mode, bo
target->FinishSpell(CURRENT_GENERIC_SPELL, false);
target->InterruptNonMeleeSpells(true);
target->getHostileRefManager().deleteReferences();
// stop handling the effect if it was removed by linked event
if (aurApp->GetRemoveMode())
return;
// blizz like 2.0.x
target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_29);
// blizz like 2.0.x
target->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH);
// blizz like 2.0.x
target->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD);
target->AddUnitState(UNIT_STAT_DIED);
}
else
{
@@ -3535,6 +3561,9 @@ void AuraEffect::HandleModUnattackable(AuraApplication const * aurApp, uint8 mod
target->CombatStop();
target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION);
}
// stop handling the effect if it was removed by linked event
if (aurApp->GetRemoveMode())
return;
}
// do not remove unit flag if there are more than this auraEffect of that kind on unit on unit
else if (target->HasAuraType(SPELL_AURA_MOD_UNATTACKABLE))
@@ -3600,8 +3629,6 @@ void AuraEffect::HandleAuraModDisarm(AuraApplication const * aurApp, uint8 mode,
}
}
if (target->GetTypeId() == TYPEID_UNIT && target->ToCreature()->GetCurrentEquipmentId())
target->UpdateDamagePhysical(attType);
}
@@ -4476,6 +4503,9 @@ void AuraEffect::HandleAuraModEffectImmunity(AuraApplication const * aurApp, uin
sOutdoorPvPMgr->HandleDropFlag((Player*)target,GetSpellProto()->Id);
}
}
// stop handling the effect if it was removed by linked event
if (apply && aurApp->GetRemoveMode())
return;
target->ApplySpellImmune(GetId(),IMMUNITY_EFFECT,GetMiscValue(),apply);
}
@@ -4491,6 +4521,9 @@ void AuraEffect::HandleAuraModStateImmunity(AuraApplication const * aurApp, uint
{
target->RemoveAurasByType(AuraType(GetMiscValue()), NULL , GetBase());
}
// stop handling the effect if it was removed by linked event
if (apply && aurApp->GetRemoveMode())
return;
target->ApplySpellImmune(GetId(), IMMUNITY_STATE, GetMiscValue(), apply);
}
@@ -4505,6 +4538,10 @@ void AuraEffect::HandleAuraModSchoolImmunity(AuraApplication const * aurApp, uin
if ((apply) && GetMiscValue() == SPELL_SCHOOL_MASK_NORMAL)
target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION);
// stop handling the effect if it was removed by linked event
if (apply && aurApp->GetRemoveMode())
return;
target->ApplySpellImmune(GetId(),IMMUNITY_SCHOOL,GetMiscValue(),(apply));
// remove all flag auras (they are positive, but they must be removed when you are immune)
@@ -4533,6 +4570,11 @@ void AuraEffect::HandleAuraModSchoolImmunity(AuraApplication const * aurApp, uin
++iter;
}
}
// stop handling the effect if it was removed by linked event
if (apply && aurApp->GetRemoveMode())
return;
if (GetSpellProto()->Mechanic == MECHANIC_BANISH)
{
if (apply)
@@ -6200,6 +6242,10 @@ void AuraEffect::HandleAuraDummy(AuraApplication const * aurApp, uint8 mode, boo
break;
}
// stop handling the effect if it was removed by linked event
if (apply && aurApp->GetRemoveMode())
return;
if (mode & AURA_EFFECT_HANDLE_REAL)
{
// pet auras
@@ -6405,7 +6451,6 @@ void AuraEffect::HandleAuraConvertRune(AuraApplication const * aurApp, uint8 mod
continue;
if (!plr->GetRuneCooldown(i))
{
// ConvertRune(i,
plr->AddRuneByAuraEffect(i, RuneType(GetMiscValueB()), this);
--runes;
}