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
@@ -988,8 +988,11 @@ void AuraEffect::HandleEffect(AuraApplication const * aurApp, uint8 mode, bool a
else else
prevented = GetBase()->CallScriptEffectRemoveHandlers(const_cast<AuraEffect const *>(this), aurApp, (AuraEffectHandleModes)mode); prevented = GetBase()->CallScriptEffectRemoveHandlers(const_cast<AuraEffect const *>(this), aurApp, (AuraEffectHandleModes)mode);
if (!prevented) // check if script events have removed the aura or if default effect prevention was requested
(*this.*AuraEffectHandler [GetAuraType()])(aurApp, mode, apply); if ((apply && aurApp->GetRemoveMode()) || prevented)
return;
(*this.*AuraEffectHandler [GetAuraType()])(aurApp, mode, apply);
} }
void AuraEffect::HandleEffect(Unit * target, uint8 mode, bool 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); 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.AddFlag( type);
target->m_stealth.AddValue(type, GetAmount()); 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()) if (Battleground *bg = player->GetBattleground())
bg->EventPlayerDroppedFlag(player); bg->EventPlayerDroppedFlag(player);
// stop handling the effect if it was removed by linked event
if (aurApp->GetRemoveMode())
return;
// GM-mode have mask 0xFFFFFFFF // GM-mode have mask 0xFFFFFFFF
if (player->isGameMaster()) if (player->isGameMaster())
newPhase = 0xFFFFFFFF; newPhase = 0xFFFFFFFF;
@@ -3071,6 +3082,10 @@ void AuraEffect::HandleAuraModShapeshift(AuraApplication const * aurApp, uint8 m
// remove other shapeshift before applying a new one // remove other shapeshift before applying a new one
target->RemoveAurasByType(SPELL_AURA_MOD_SHAPESHIFT, 0, GetBase()); 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) if (modelid > 0)
target->SetDisplayId(modelid); target->SetDisplayId(modelid);
@@ -3117,6 +3132,9 @@ void AuraEffect::HandleAuraModShapeshift(AuraApplication const * aurApp, uint8 m
break; break;
} }
} }
// stop handling the effect if it was removed by linked event
if (aurApp->GetRemoveMode())
return;
target->SetShapeshiftForm(form); 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) if (target->GetTypeId() == TYPEID_PLAYER)
{ {
SpellShapeshiftEntry const *shapeInfo = sSpellShapeshiftStore.LookupEntry(form); 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->CombatStop();
target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION); 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->FinishSpell(CURRENT_GENERIC_SPELL, false);
target->InterruptNonMeleeSpells(true); target->InterruptNonMeleeSpells(true);
target->getHostileRefManager().deleteReferences(); 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 else
{ {
@@ -3535,6 +3561,9 @@ void AuraEffect::HandleModUnattackable(AuraApplication const * aurApp, uint8 mod
target->CombatStop(); target->CombatStop();
target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION); 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 // 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)) 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()) if (target->GetTypeId() == TYPEID_UNIT && target->ToCreature()->GetCurrentEquipmentId())
target->UpdateDamagePhysical(attType); target->UpdateDamagePhysical(attType);
} }
@@ -4476,6 +4503,9 @@ void AuraEffect::HandleAuraModEffectImmunity(AuraApplication const * aurApp, uin
sOutdoorPvPMgr->HandleDropFlag((Player*)target,GetSpellProto()->Id); 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); target->ApplySpellImmune(GetId(),IMMUNITY_EFFECT,GetMiscValue(),apply);
} }
@@ -4491,6 +4521,9 @@ void AuraEffect::HandleAuraModStateImmunity(AuraApplication const * aurApp, uint
{ {
target->RemoveAurasByType(AuraType(GetMiscValue()), NULL , GetBase()); 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); 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) if ((apply) && GetMiscValue() == SPELL_SCHOOL_MASK_NORMAL)
target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION); 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)); target->ApplySpellImmune(GetId(),IMMUNITY_SCHOOL,GetMiscValue(),(apply));
// remove all flag auras (they are positive, but they must be removed when you are immune) // 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; ++iter;
} }
} }
// stop handling the effect if it was removed by linked event
if (apply && aurApp->GetRemoveMode())
return;
if (GetSpellProto()->Mechanic == MECHANIC_BANISH) if (GetSpellProto()->Mechanic == MECHANIC_BANISH)
{ {
if (apply) if (apply)
@@ -6200,6 +6242,10 @@ void AuraEffect::HandleAuraDummy(AuraApplication const * aurApp, uint8 mode, boo
break; break;
} }
// stop handling the effect if it was removed by linked event
if (apply && aurApp->GetRemoveMode())
return;
if (mode & AURA_EFFECT_HANDLE_REAL) if (mode & AURA_EFFECT_HANDLE_REAL)
{ {
// pet auras // pet auras
@@ -6405,7 +6451,6 @@ void AuraEffect::HandleAuraConvertRune(AuraApplication const * aurApp, uint8 mod
continue; continue;
if (!plr->GetRuneCooldown(i)) if (!plr->GetRuneCooldown(i))
{ {
// ConvertRune(i,
plr->AddRuneByAuraEffect(i, RuneType(GetMiscValueB()), this); plr->AddRuneByAuraEffect(i, RuneType(GetMiscValueB()), this);
--runes; --runes;
} }