fix(Core/Spells): add several missing null checks for the DamageInfo struct to fix a crash (#8322)

This commit is contained in:
Skjalf
2021-10-10 11:07:14 -03:00
committed by GitHub
parent 66809383d1
commit 1e57b6fb99
13 changed files with 146 additions and 22 deletions

View File

@@ -101,8 +101,13 @@ public:
bool CheckProc(ProcEventInfo& eventInfo)
{
if (const SpellInfo* procSpell = eventInfo.GetSpellInfo())
{
if (procSpell->SpellIconID == 3025) // Righteous Vengeance, should not proc SoC
{
return false;
}
}
return true;
}
@@ -111,8 +116,12 @@ public:
PreventDefaultAction();
int32 targets = 3;
if (const SpellInfo* procSpell = eventInfo.GetSpellInfo())
{
if (procSpell->IsAffectingArea())
{
targets = 1;
}
}
if (Unit* target = eventInfo.GetActionTarget())
{
@@ -261,11 +270,24 @@ public:
if (eventInfo.GetTypeMask() & PROC_FLAG_TAKEN_SPELL_MAGIC_DMG_CLASS_POS)
{
Unit* caster = eventInfo.GetActor();
const SpellInfo* procSpell = eventInfo.GetSpellInfo();
DamageInfo* damageInfo = eventInfo.GetDamageInfo();
if (!damageInfo || !damageInfo->GetDamage())
{
return;
}
const SpellInfo* procSpell = damageInfo->GetSpellInfo();
if (!procSpell)
{
return;
}
if (caster && procSpell->SpellFamilyName == SPELLFAMILY_PALADIN &&
procSpell->SpellFamilyFlags.HasFlag(0x40000000) && caster->GetAuraEffect(SPELL_AURA_PROC_TRIGGER_SPELL, SPELLFAMILY_PALADIN, 3021, 0)) // need infusion of light
{
int32 basepoints = int32(float(eventInfo.GetDamageInfo()->GetDamage()) / 12.0f);
int32 basepoints = int32(float(damageInfo->GetDamage()) / 12.0f);
// Item - Paladin T9 Holy 4P Bonus (Flash of Light)
if (AuraEffect const* aurEffect = caster->GetAuraEffect(67191, EFFECT_0))
AddPct(basepoints, aurEffect->GetAmount());
@@ -755,8 +777,16 @@ public:
void OnProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
DamageInfo* damageInfo = eventInfo.GetDamageInfo();
if (!damageInfo || !damageInfo->GetDamage())
{
return;
}
// return damage % to attacker but < 50% own total health
int32 damage = int32(std::min(CalculatePct(eventInfo.GetDamageInfo()->GetDamage(), aurEff->GetAmount()), GetTarget()->GetMaxHealth() / 2));
int32 damage = std::min(CalculatePct(static_cast<int32>(damageInfo->GetDamage()), aurEff->GetAmount()), static_cast<int32>(GetTarget()->GetMaxHealth()) / 2);
GetTarget()->CastCustomSpell(SPELL_PALADIN_EYE_FOR_AN_EYE_DAMAGE, SPELLVALUE_BASE_POINT0, damage, eventInfo.GetProcTarget(), true, nullptr, aurEff);
}
@@ -1262,7 +1292,14 @@ public:
if (!target)
return false;
return target->IsAlive() && !eventInfo.GetTriggerAuraSpell() && (eventInfo.GetDamageInfo()->GetDamage() || (eventInfo.GetHitMask() & PROC_EX_ABSORB));
DamageInfo* damageInfo = eventInfo.GetDamageInfo();
if (!damageInfo || !damageInfo->GetDamage())
{
return false;
}
return target->IsAlive() && !eventInfo.GetTriggerAuraSpell() && (damageInfo->GetDamage() || (eventInfo.GetHitMask() & PROC_EX_ABSORB));
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)