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

@@ -824,7 +824,15 @@ public:
void OnProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
int32 heal = CalculatePct(int32(eventInfo.GetDamageInfo()->GetDamage()), aurEff->GetAmount());
DamageInfo* damageInfo = eventInfo.GetDamageInfo();
if (!damageInfo || !damageInfo->GetDamage())
{
return;
}
int32 heal = CalculatePct(static_cast<int32>(damageInfo->GetDamage()), aurEff->GetAmount());
GetTarget()->CastCustomSpell(SPELL_ESSENCE_OF_THE_BLOOD_QUEEN_HEAL, SPELLVALUE_BASE_POINT0, heal, GetTarget(), TRIGGERED_FULL_MASK, nullptr, aurEff);
}

View File

@@ -3536,7 +3536,15 @@ public:
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
int32 heal = int32(eventInfo.GetDamageInfo()->GetDamage() / 2);
DamageInfo* damageInfo = eventInfo.GetDamageInfo();
if (!damageInfo || !damageInfo->GetDamage())
{
return;
}
int32 heal = static_cast<int32>(damageInfo->GetDamage() / 2);
GetTarget()->CastCustomSpell(SPELL_DARK_HUNGER_HEAL, SPELLVALUE_BASE_POINT0, heal, GetTarget(), true, nullptr, aurEff);
}

View File

@@ -657,7 +657,15 @@ public:
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
int32 amount = aurEff->GetAmount() + eventInfo.GetDamageInfo()->GetDamage();
DamageInfo* damageInfo = eventInfo.GetDamageInfo();
if (!damageInfo || !damageInfo->GetDamage())
{
return;
}
int32 amount = aurEff->GetAmount() + damageInfo->GetDamage();
uint8 num = amount / 15000;
if (amount >= 15000)

View File

@@ -2971,8 +2971,15 @@ public:
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
int32 damage = CalculatePct(int32(eventInfo.GetDamageInfo()->GetDamage()), 60);
GetTarget()->CastCustomSpell(SPELL_GRIM_REPRISAL_DAMAGE, SPELLVALUE_BASE_POINT0, damage, eventInfo.GetDamageInfo()->GetAttacker(), true, nullptr, aurEff);
DamageInfo* damageInfo = eventInfo.GetDamageInfo();
if (!damageInfo || !damageInfo->GetDamage())
{
return;
}
int32 damage = CalculatePct(static_cast<int32>(damageInfo->GetDamage()), 60);
GetTarget()->CastCustomSpell(SPELL_GRIM_REPRISAL_DAMAGE, SPELLVALUE_BASE_POINT0, damage, damageInfo->GetAttacker(), true, nullptr, aurEff);
}
void Register() override

View File

@@ -1305,7 +1305,15 @@ public:
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
int32 bp = int32(eventInfo.GetDamageInfo()->GetDamage() * 1.5f);
DamageInfo* damageInfo = eventInfo.GetDamageInfo();
if (!damageInfo || !damageInfo->GetDamage())
{
return;
}
int32 bp = static_cast<int32>(damageInfo->GetDamage() * 1.5f);
GetTarget()->CastCustomSpell(SPELL_DK_BLOOD_GORGED_HEAL, SPELLVALUE_BASE_POINT0, bp, _procTarget, true, nullptr, aurEff);
}

View File

@@ -2146,7 +2146,9 @@ public:
bool CheckProc(ProcEventInfo& eventInfo)
{
if (eventInfo.GetSpellInfo())
{
return false;
}
if (GetFirstSchoolInMask(eventInfo.GetSchoolMask()) == SPELL_SCHOOL_NORMAL)
return false;

View File

@@ -670,7 +670,9 @@ public:
{
SpellInfo const* spellInfo = eventInfo.GetSpellInfo();
if (!spellInfo || !spellInfo->HasEffect(SPELL_EFFECT_HEAL))
{
return false;
}
return spellInfo->ManaCost > 0 || spellInfo->ManaCostPercentage > 0 || (spellInfo->SpellFamilyName == SPELLFAMILY_PALADIN && spellInfo->SpellIconID == 156);
}
@@ -2418,7 +2420,15 @@ public:
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
int32 bp = CalculatePct(int32(eventInfo.GetDamageInfo()->GetDamage()), aurEff->GetAmount());
DamageInfo* damageInfo = eventInfo.GetDamageInfo();
if (!damageInfo || !damageInfo->GetDamage())
{
return;
}
int32 bp = CalculatePct(static_cast<int32>(damageInfo->GetDamage()), aurEff->GetAmount());
GetTarget()->CastCustomSpell(SPELL_ITEM_NECROTIC_TOUCH_PROC, SPELLVALUE_BASE_POINT0, bp, eventInfo.GetProcTarget(), true, nullptr, aurEff);
}

View File

@@ -262,7 +262,7 @@ public:
bool CheckProc(ProcEventInfo& eventInfo)
{
return eventInfo.GetSpellInfo();
return eventInfo.GetSpellInfo() != nullptr;
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
@@ -864,10 +864,21 @@ public:
if (!eventInfo.GetActor() || !eventInfo.GetProcTarget())
return false;
DamageInfo* damageInfo = eventInfo.GetDamageInfo();
if (!damageInfo || !damageInfo->GetSpellInfo())
{
return false;
}
// Molten Armor
if (SpellInfo const* spellInfo = eventInfo.GetSpellInfo())
{
if (spellInfo->SpellFamilyFlags[1] & 0x8)
{
return false;
}
}
return true;
}

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)

View File

@@ -144,9 +144,10 @@ public:
// Xinef: no _procTarget but checkproc passed??
// Unit::CalculateAOEDamageReduction (this=0x0, damage=4118, schoolMask=1, caster=0x7ffdad089000)
Unit* procTarget = ObjectAccessor::GetUnit(*GetTarget(), _procTargetGUID);
if (procTarget && eventInfo.GetDamageInfo())
DamageInfo* damageInfo = eventInfo.GetDamageInfo();
if (procTarget && damageInfo)
{
int32 damage = eventInfo.GetDamageInfo()->GetUnmitigatedDamage();
int32 damage = damageInfo->GetUnmitigatedDamage();
CustomSpellValues values;
values.AddSpellMod(SPELLVALUE_BASE_POINT0, damage);

View File

@@ -1120,7 +1120,7 @@ public:
bool CheckProc(ProcEventInfo& eventInfo)
{
return eventInfo.GetSpellInfo();
return eventInfo.GetSpellInfo() != nullptr;
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)

View File

@@ -890,14 +890,22 @@ public:
bool CheckProc(ProcEventInfo& eventInfo)
{
return eventInfo.GetDamageInfo()->GetDamage() && GetTarget()->IsAlive();
DamageInfo* damageInfo = eventInfo.GetDamageInfo();
if (!damageInfo || !damageInfo->GetDamage())
{
return false;
}
return GetTarget()->IsAlive();
}
void OnProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
int32 amount = int32(CalculatePct(eventInfo.GetDamageInfo()->GetDamage(), aurEff->GetAmount()));
int32 amount = CalculatePct(static_cast<int32>(eventInfo.GetDamageInfo()->GetDamage()), aurEff->GetAmount());
// Glyph of Siphon Life
if (AuraEffect const* glyph = GetTarget()->GetAuraEffect(SPELL_WARLOCK_GLYPH_OF_SIPHON_LIFE, EFFECT_0))
AddPct(amount, glyph->GetAmount());
@@ -1094,14 +1102,22 @@ public:
bool CheckProc(ProcEventInfo& eventInfo)
{
// Xinef: Added charm check
return (GetTarget()->GetGuardianPet() || GetTarget()->GetCharm()) && eventInfo.GetDamageInfo()->GetDamage();
DamageInfo* damageInfo = eventInfo.GetDamageInfo();
if (!damageInfo || !damageInfo->GetDamage())
{
return false;
}
return (GetTarget()->GetGuardianPet() || GetTarget()->GetCharm()) && damageInfo->GetDamage();
}
void OnProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
int32 heal = CalculatePct(int32(eventInfo.GetDamageInfo()->GetDamage()), aurEff->GetAmount());
int32 heal = CalculatePct(static_cast<int32>(eventInfo.GetDamageInfo()->GetDamage()), aurEff->GetAmount());
GetTarget()->CastCustomSpell(SPELL_WARLOCK_FEL_SYNERGY_HEAL, SPELLVALUE_BASE_POINT0, heal, (Unit*)nullptr, true, nullptr, aurEff); // TARGET_UNIT_PET
}

View File

@@ -812,15 +812,23 @@ public:
bool CheckProc(ProcEventInfo& eventInfo)
{
_procTarget = eventInfo.GetActor()->SelectNearbyNoTotemTarget(eventInfo.GetProcTarget());
return _procTarget && !eventInfo.GetDamageInfo()->GetSpellInfo();
DamageInfo* damageInfo = eventInfo.GetDamageInfo();
if (!damageInfo || !damageInfo->GetSpellInfo())
{
return false;
}
return _procTarget && !damageInfo->GetSpellInfo();
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
if (eventInfo.GetDamageInfo())
if (DamageInfo* damageInfo = eventInfo.GetDamageInfo())
{
int32 damage = eventInfo.GetDamageInfo()->GetUnmitigatedDamage();
int32 damage = damageInfo->GetUnmitigatedDamage();
GetTarget()->CastCustomSpell(_procTarget, SPELL_WARRIOR_SWEEPING_STRIKES_EXTRA_ATTACK, &damage, 0, 0, true, nullptr, aurEff);
}
}