fix(Core/Spells): Potential crashes in spell_generic and spell_item (#8810)

This commit is contained in:
Nefertumm
2021-11-09 07:10:03 -03:00
committed by GitHub
parent 12e92b5808
commit 4cad90be86
2 changed files with 61 additions and 13 deletions

View File

@@ -1993,7 +1993,10 @@ public:
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
eventInfo.GetActionTarget()->CastSpell((Unit*)nullptr, SPELL_FALL_DOWN, true, nullptr, aurEff);
if (eventInfo.GetActionTarget())
{
eventInfo.GetActionTarget()->CastSpell((Unit*)nullptr, SPELL_FALL_DOWN, true, nullptr, aurEff);
}
}
void Register() override
@@ -2674,7 +2677,10 @@ public:
void HandleScriptEffect(SpellEffIndex effIndex)
{
PreventHitDefaultEffect(effIndex);
GetHitUnit()->CastSpell(GetCaster(), uint32(GetEffectValue()), true);
if (GetHitUnit())
{
GetHitUnit()->CastSpell(GetCaster(), uint32(GetEffectValue()), true);
}
}
void Register() override
@@ -2719,7 +2725,10 @@ public:
void HandleScriptEffect(SpellEffIndex effIndex)
{
PreventHitDefaultEffect(effIndex);
GetHitUnit()->CastSpell(GetCaster(), uint32(GetEffectValue()), true);
if (GetHitUnit())
{
GetHitUnit()->CastSpell(GetCaster(), uint32(GetEffectValue()), true);
}
}
void Register() override
@@ -4601,6 +4610,11 @@ public:
Unit* caster = eventInfo.GetActionTarget();
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(SPELL_GEN_BLADE_WARDING_TRIGGERED);
if (!caster)
{
return;
}
uint8 stacks = GetStackAmount();
int32 bp = 0;
@@ -4656,8 +4670,10 @@ public:
void AfterRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
{
// Final heal only on duration end
if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_EXPIRE && GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_ENEMY_SPELL)
if (GetTargetApplication() && GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_EXPIRE && GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_ENEMY_SPELL)
{
return;
}
// final heal
GetTarget()->CastSpell(GetTarget(), _spellId, true, nullptr, aurEff, GetCasterGUID());
@@ -5228,8 +5244,12 @@ public:
void HandleDummy(SpellEffIndex /* effIndex */)
{
if (Creature* vendor = GetCaster()->ToCreature())
if (vendor->GetEntry() == NPC_AMPHITHEATER_VENDOR)
{
if (vendor->GetEntry() == NPC_AMPHITHEATER_VENDOR && vendor->AI())
{
vendor->AI()->Talk(SAY_AMPHITHEATER_VENDOR);
}
}
}
void Register() override
@@ -5294,6 +5314,11 @@ public:
void RemoveVehicleAuras()
{
if (!GetHitUnit())
{
return;
}
Unit* u = nullptr;
if (Vehicle* vehicle = GetHitUnit()->GetVehicleKit())
{
@@ -5345,6 +5370,11 @@ public:
void EjectPassenger(SpellEffIndex /*effIndex*/)
{
if (!GetHitUnit())
{
return;
}
if (Vehicle* vehicle = GetHitUnit()->GetVehicleKit())
{
if (Unit* passenger = vehicle->GetPassenger(GetEffectValue() - 1))

View File

@@ -1281,9 +1281,16 @@ public:
void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
const SpellInfo* spellInfo = sSpellMgr->GetSpellInfo(64442 /*SPELL_BLADE_WARDING*/);
int32 basepoints = spellInfo->Effects[EFFECT_0].CalcValue() * this->GetStackAmount();
eventInfo.GetActionTarget()->CastCustomSpell(spellInfo->Id, SPELLVALUE_BASE_POINT0, basepoints, eventInfo.GetActor(), true);
if (!eventInfo.GetActionTarget())
{
return;
}
if (const SpellInfo* spellInfo = sSpellMgr->GetSpellInfo(64442 /*SPELL_BLADE_WARDING*/))
{
int32 basepoints = spellInfo->Effects[EFFECT_0].CalcValue() * this->GetStackAmount();
eventInfo.GetActionTarget()->CastCustomSpell(spellInfo->Id, SPELLVALUE_BASE_POINT0, basepoints, eventInfo.GetActor(), true);
}
}
void Register() override
@@ -1315,10 +1322,12 @@ public:
return;
}
const SpellInfo* spellInfo = sSpellMgr->GetSpellInfo(64569 /*SPELL_BLOOD_RESERVE*/);
int32 basepoints = spellInfo->Effects[EFFECT_0].CalcValue() * this->GetStackAmount();
eventInfo.GetActionTarget()->CastCustomSpell(spellInfo->Id, SPELLVALUE_BASE_POINT0, basepoints, eventInfo.GetActionTarget(), true);
eventInfo.GetActionTarget()->RemoveAurasDueToSpell(GetSpellInfo()->Id); // Remove rest auras
if (const SpellInfo* spellInfo = sSpellMgr->GetSpellInfo(64569 /*SPELL_BLOOD_RESERVE*/))
{
int32 basepoints = spellInfo->Effects[EFFECT_0].CalcValue() * this->GetStackAmount();
eventInfo.GetActionTarget()->CastCustomSpell(spellInfo->Id, SPELLVALUE_BASE_POINT0, basepoints, eventInfo.GetActionTarget(), true);
eventInfo.GetActionTarget()->RemoveAurasDueToSpell(GetSpellInfo()->Id); // Remove rest auras
}
}
void Register() override
@@ -2887,7 +2896,8 @@ public:
return false;*/
if (const SpellInfo* procSpell = eventInfo.GetSpellInfo())
if (!eventInfo.GetDamageInfo()->GetDamage())
{
if (eventInfo.GetDamageInfo() && !eventInfo.GetDamageInfo()->GetDamage())
{
if (procSpell->SpellFamilyName == SPELLFAMILY_WARRIOR)
{
@@ -2902,6 +2912,7 @@ public:
else
return false;
}
}
return eventInfo.GetProcTarget() && eventInfo.GetActor() != eventInfo.GetProcTarget() && eventInfo.GetProcTarget()->IsAlive();
}
@@ -3916,6 +3927,12 @@ public:
void HandleDummy(SpellEffIndex /* effIndex */)
{
Player* caster = GetCaster()->ToPlayer();
if (!caster)
{
return;
}
if (caster->HasAuraType(SPELL_AURA_MOUNTED))
{
caster->RemoveAurasByType(SPELL_AURA_MOUNTED);
@@ -4205,6 +4222,7 @@ public:
void HandleDummy(SpellEffIndex /* effIndex */)
{
Player* caster = GetCaster()->ToPlayer();
if (Unit* target = GetHitUnit())
{
if (!target->HasAura(SPELL_CHICKEN_NET) && (caster->GetQuestStatus(QUEST_CHICKEN_PARTY) == QUEST_STATUS_INCOMPLETE || caster->GetQuestStatus(QUEST_FLOWN_THE_COOP) == QUEST_STATUS_INCOMPLETE))