summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSkjalf <47818697+Nyeriah@users.noreply.github.com>2021-10-10 11:07:14 -0300
committerGitHub <noreply@github.com>2021-10-10 16:07:14 +0200
commit1e57b6fb99af5533c3d5acd0ece730a7c0293539 (patch)
treef4d1064bb0bff13a325eb7b069652e5e60ad0e20 /src
parent66809383d15507ee51c97ff5dd27367d0f0849be (diff)
fix(Core/Spells): add several missing null checks for the DamageInfo struct to fix a crash (#8322)
Diffstat (limited to 'src')
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp10
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp10
-rw-r--r--src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp10
-rw-r--r--src/server/scripts/Northrend/Ulduar/Ulduar/boss_yoggsaron.cpp11
-rw-r--r--src/server/scripts/Spells/spell_dk.cpp10
-rw-r--r--src/server/scripts/Spells/spell_generic.cpp2
-rw-r--r--src/server/scripts/Spells/spell_item.cpp12
-rw-r--r--src/server/scripts/Spells/spell_mage.cpp13
-rw-r--r--src/server/scripts/Spells/spell_paladin.cpp45
-rw-r--r--src/server/scripts/Spells/spell_rogue.cpp5
-rw-r--r--src/server/scripts/Spells/spell_shaman.cpp2
-rw-r--r--src/server/scripts/Spells/spell_warlock.cpp24
-rw-r--r--src/server/scripts/Spells/spell_warrior.cpp14
13 files changed, 146 insertions, 22 deletions
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp
index 3f68e4cef3..57876fef3c 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp
@@ -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);
}
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp
index 9abdfc30c6..a81d408304 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp
@@ -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);
}
diff --git a/src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp b/src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp
index b611f64b29..8a965432ba 100644
--- a/src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp
+++ b/src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp
@@ -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)
diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yoggsaron.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yoggsaron.cpp
index ac4cd1ff93..0c1cc248cd 100644
--- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yoggsaron.cpp
+++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yoggsaron.cpp
@@ -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
diff --git a/src/server/scripts/Spells/spell_dk.cpp b/src/server/scripts/Spells/spell_dk.cpp
index d2dbaed262..a152a5a758 100644
--- a/src/server/scripts/Spells/spell_dk.cpp
+++ b/src/server/scripts/Spells/spell_dk.cpp
@@ -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);
}
diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp
index 387ca1420d..6ee43093fc 100644
--- a/src/server/scripts/Spells/spell_generic.cpp
+++ b/src/server/scripts/Spells/spell_generic.cpp
@@ -2146,7 +2146,9 @@ public:
bool CheckProc(ProcEventInfo& eventInfo)
{
if (eventInfo.GetSpellInfo())
+ {
return false;
+ }
if (GetFirstSchoolInMask(eventInfo.GetSchoolMask()) == SPELL_SCHOOL_NORMAL)
return false;
diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp
index bf60da6792..adadfd8e2c 100644
--- a/src/server/scripts/Spells/spell_item.cpp
+++ b/src/server/scripts/Spells/spell_item.cpp
@@ -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);
}
diff --git a/src/server/scripts/Spells/spell_mage.cpp b/src/server/scripts/Spells/spell_mage.cpp
index 9d8c2797f7..ad81ab742b 100644
--- a/src/server/scripts/Spells/spell_mage.cpp
+++ b/src/server/scripts/Spells/spell_mage.cpp
@@ -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;
}
diff --git a/src/server/scripts/Spells/spell_paladin.cpp b/src/server/scripts/Spells/spell_paladin.cpp
index f4a208adbb..4fe7831ca6 100644
--- a/src/server/scripts/Spells/spell_paladin.cpp
+++ b/src/server/scripts/Spells/spell_paladin.cpp
@@ -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)
diff --git a/src/server/scripts/Spells/spell_rogue.cpp b/src/server/scripts/Spells/spell_rogue.cpp
index b5eeb0ada0..063017b2e8 100644
--- a/src/server/scripts/Spells/spell_rogue.cpp
+++ b/src/server/scripts/Spells/spell_rogue.cpp
@@ -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);
diff --git a/src/server/scripts/Spells/spell_shaman.cpp b/src/server/scripts/Spells/spell_shaman.cpp
index b57601594f..7f7a7e62e4 100644
--- a/src/server/scripts/Spells/spell_shaman.cpp
+++ b/src/server/scripts/Spells/spell_shaman.cpp
@@ -1120,7 +1120,7 @@ public:
bool CheckProc(ProcEventInfo& eventInfo)
{
- return eventInfo.GetSpellInfo();
+ return eventInfo.GetSpellInfo() != nullptr;
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
diff --git a/src/server/scripts/Spells/spell_warlock.cpp b/src/server/scripts/Spells/spell_warlock.cpp
index a44cc42461..67ef1ae9d7 100644
--- a/src/server/scripts/Spells/spell_warlock.cpp
+++ b/src/server/scripts/Spells/spell_warlock.cpp
@@ -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
}
diff --git a/src/server/scripts/Spells/spell_warrior.cpp b/src/server/scripts/Spells/spell_warrior.cpp
index 1d1d646aee..98c816dc22 100644
--- a/src/server/scripts/Spells/spell_warrior.cpp
+++ b/src/server/scripts/Spells/spell_warrior.cpp
@@ -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);
}
}