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

@@ -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))