From b86150352da0b8111b5c4fd52a0a18165d13b5d8 Mon Sep 17 00:00:00 2001 From: ariel- Date: Sat, 8 Oct 2016 22:20:49 -0300 Subject: Core/Scripts: added missing null checks for DamageInfo struct (cherry picked from commit 666422d82751439aaf3ddd05dae086900dffcbf2) # Conflicts: # src/server/scripts/Spells/spell_dk.cpp # src/server/scripts/Spells/spell_mage.cpp # src/server/scripts/Spells/spell_paladin.cpp # src/server/scripts/Spells/spell_priest.cpp # src/server/scripts/Spells/spell_rogue.cpp # src/server/scripts/Spells/spell_shaman.cpp # src/server/scripts/Spells/spell_warlock.cpp # src/server/scripts/Spells/spell_warrior.cpp --- .../Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp | 6 +++++- .../Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp | 8 ++++++-- .../scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp | 8 ++++++-- src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp | 5 ++++- src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp | 8 ++++++-- 5 files changed, 27 insertions(+), 8 deletions(-) (limited to 'src/server/scripts/Northrend') diff --git a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp index b00ee7ff6d6..62c649f97c8 100644 --- a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp @@ -405,7 +405,11 @@ class spell_devourer_of_souls_mirrored_soul_proc : public SpellScriptLoader void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo) { PreventDefaultAction(); - int32 damage = int32(CalculatePct(eventInfo.GetDamageInfo()->GetDamage(), 45)); + DamageInfo* damageInfo = eventInfo.GetDamageInfo(); + if (!damageInfo || !damageInfo->GetDamage()) + return; + + int32 damage = CalculatePct(static_cast(damageInfo->GetDamage()), 45); GetTarget()->CastCustomSpell(SPELL_MIRRORED_SOUL_DAMAGE, SPELLVALUE_BASE_POINT0, damage, GetCaster(), true); } 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 1b2212d9ddc..b5de16670bc 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 @@ -729,8 +729,12 @@ class spell_blood_queen_essence_of_the_blood_queen : public SpellScriptLoader void OnProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) { PreventDefaultAction(); - int32 heal = CalculatePct(int32(eventInfo.GetDamageInfo()->GetDamage()), aurEff->GetAmount()); - GetTarget()->CastCustomSpell(SPELL_ESSENCE_OF_THE_BLOOD_QUEEN_HEAL, SPELLVALUE_BASE_POINT0, heal, GetTarget(), TRIGGERED_FULL_MASK, NULL, aurEff); + DamageInfo* damageInfo = eventInfo.GetDamageInfo(); + if (!damageInfo || !damageInfo->GetDamage()) + return; + + int32 heal = CalculatePct(static_cast(damageInfo->GetDamage()), aurEff->GetAmount()); + GetTarget()->CastCustomSpell(SPELL_ESSENCE_OF_THE_BLOOD_QUEEN_HEAL, SPELLVALUE_BASE_POINT0, heal, GetTarget(), TRIGGERED_FULL_MASK, nullptr, aurEff); } void Register() override 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 75d4e8dda85..e6c56e9c38b 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp @@ -2968,8 +2968,12 @@ class spell_the_lich_king_dark_hunger : public SpellScriptLoader void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) { PreventDefaultAction(); - int32 heal = int32(eventInfo.GetDamageInfo()->GetDamage() / 2); - GetTarget()->CastCustomSpell(SPELL_DARK_HUNGER_HEAL, SPELLVALUE_BASE_POINT0, heal, GetTarget(), true, NULL, aurEff); + DamageInfo* damageInfo = eventInfo.GetDamageInfo(); + if (!damageInfo || !damageInfo->GetDamage()) + return; + + int32 heal = static_cast(damageInfo->GetDamage()) / 2; + GetTarget()->CastCustomSpell(SPELL_DARK_HUNGER_HEAL, SPELLVALUE_BASE_POINT0, heal, GetTarget(), true, nullptr, aurEff); } void Register() override diff --git a/src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp b/src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp index ed6c7c459bf..70ed4a83556 100644 --- a/src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp +++ b/src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp @@ -600,8 +600,11 @@ class spell_oculus_temporal_rift : public SpellScriptLoader 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(); if (amount >= 15000) { if (Unit* caster = GetCaster()) diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp index 3846a69595b..fefec61a8de 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp @@ -2730,8 +2730,12 @@ class spell_yogg_saron_grim_reprisal : public SpellScriptLoader // 63305 void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) { PreventDefaultAction(); - int32 damage = CalculatePct(int32(eventInfo.GetDamageInfo()->GetDamage()), 60); - GetTarget()->CastCustomSpell(SPELL_GRIM_REPRISAL_DAMAGE, SPELLVALUE_BASE_POINT0, damage, eventInfo.GetDamageInfo()->GetAttacker(), true, NULL, aurEff); + DamageInfo* damageInfo = eventInfo.GetDamageInfo(); + if (!damageInfo || !damageInfo->GetDamage()) + return; + + int32 damage = CalculatePct(static_cast(damageInfo->GetDamage()), 60); + GetTarget()->CastCustomSpell(SPELL_GRIM_REPRISAL_DAMAGE, SPELLVALUE_BASE_POINT0, damage, damageInfo->GetAttacker(), true, nullptr, aurEff); } void Register() override -- cgit v1.2.3