diff options
| author | jackpoz <giacomopoz@gmail.com> | 2014-04-19 21:48:22 +0200 |
|---|---|---|
| committer | jackpoz <giacomopoz@gmail.com> | 2014-04-19 21:48:22 +0200 |
| commit | 8ca63717932ae6db48d74e866e8d379c4f5a5920 (patch) | |
| tree | 0ebd6fa6ded2af7c4becaae1bb372be427235c6d /src/server/scripts/Outland | |
| parent | fac3f445b12ee9ab484a2c229cdd49ca68120cea (diff) | |
Core/Misc: Ensure GetVictim() returns a valid reference when expected
Add a new method EnsureVictim() which asserts a valid not NULL reference will be returned to the caller. Use this whenever the GetVictim() would be dereferenced .
Diffstat (limited to 'src/server/scripts/Outland')
5 files changed, 12 insertions, 12 deletions
diff --git a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp index d74aecb9b25..957471216d8 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp @@ -2077,12 +2077,12 @@ public: if (!UpdateVictim()) return; - if (me->GetVictim()->GetTypeId() != TYPEID_PLAYER) + if (me->EnsureVictim()->GetTypeId() != TYPEID_PLAYER) return; // Only cast the below on players. - if (!me->GetVictim()->HasAura(SPELL_PARALYZE)) + if (!me->EnsureVictim()->HasAura(SPELL_PARALYZE)) { - TargetGUID = me->GetVictim()->GetGUID(); + TargetGUID = me->EnsureVictim()->GetGUID(); me->AddThreat(me->GetVictim(), 10000000.0f); DoCastVictim(SPELL_PURPLE_BEAM, true); DoCastVictim(SPELL_PARALYZE, true); @@ -2154,8 +2154,8 @@ public: { if (me->isAttackReady() && me->IsWithinMeleeRange(me->GetVictim())) { - if (!me->GetVictim()->HasAura(SPELL_PARASITIC_SHADOWFIEND) - && !me->GetVictim()->HasAura(SPELL_PARASITIC_SHADOWFIEND2)) + if (!me->EnsureVictim()->HasAura(SPELL_PARASITIC_SHADOWFIEND) + && !me->EnsureVictim()->HasAura(SPELL_PARASITIC_SHADOWFIEND2)) { if (Creature* illidan = Unit::GetCreature((*me), IllidanGUID))// summon only in 1. phase if (CAST_AI(boss_illidan_stormrage::boss_illidan_stormrageAI, illidan->AI())->Phase == PHASE_NORMAL) diff --git a/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp b/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp index d92d8aaf5db..d86d94088da 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp @@ -673,17 +673,17 @@ public: if (!CheckedAggro) { - AggroTargetGUID = me->GetVictim()->GetGUID(); + AggroTargetGUID = me->EnsureVictim()->GetGUID(); CheckedAggro = true; } if (CheckTankTimer <= diff) { - if (me->GetVictim()->GetGUID() != AggroTargetGUID) + if (me->EnsureVictim()->GetGUID() != AggroTargetGUID) { Talk(ANGER_SAY_BEFORE); DoCast(me, SPELL_SELF_SEETHE, true); - AggroTargetGUID = me->GetVictim()->GetGUID(); + AggroTargetGUID = me->EnsureVictim()->GetGUID(); } CheckTankTimer = 2000; } else CheckTankTimer -= diff; diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp index 9055bb1862d..490bfaa16fc 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp @@ -626,7 +626,7 @@ public: { DoCastVictim(SPELL_TIDAL_SURGE); // Hacky way to do it - won't trigger elseways - me->GetVictim()->CastSpell(me->GetVictim(), SPELL_TIDAL_SURGE_FREEZE, true); + me->EnsureVictim()->CastSpell(me->GetVictim(), SPELL_TIDAL_SURGE_FREEZE, true); TidalSurge_Timer = 15000+rand()%5000; } else TidalSurge_Timer -= diff; diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp index f9370b44c20..73da4f62a23 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp @@ -138,7 +138,7 @@ public: if (!UpdateVictim()) return; - if (me->GetVictim()->GetGUID() != victimGUID) + if (me->EnsureVictim()->GetGUID() != victimGUID) { DoModifyThreatPercent(me->GetVictim(), -100); Unit* owner = Unit::GetUnit(*me, victimGUID); @@ -519,7 +519,7 @@ public: for (ThreatContainer::StorageType::const_iterator itr = ThreatList.begin(); itr != ThreatList.end(); ++itr) { Unit* tempTarget = Unit::GetUnit(*me, (*itr)->getUnitGuid()); - if (tempTarget && tempTarget->GetTypeId() == TYPEID_PLAYER && tempTarget->GetGUID() != me->GetVictim()->GetGUID() && TargetList.size()<5) + if (tempTarget && tempTarget->GetTypeId() == TYPEID_PLAYER && tempTarget->GetGUID() != me->EnsureVictim()->GetGUID() && TargetList.size()<5) TargetList.push_back(tempTarget); } //SpellInfo* spell = GET_SPELL(SPELL_INSIDIOUS_WHISPER); diff --git a/src/server/scripts/Outland/TempestKeep/botanica/boss_warp_splinter.cpp b/src/server/scripts/Outland/TempestKeep/botanica/boss_warp_splinter.cpp index 7b83fa7009d..500bcd1ed8f 100644 --- a/src/server/scripts/Outland/TempestKeep/botanica/boss_warp_splinter.cpp +++ b/src/server/scripts/Outland/TempestKeep/botanica/boss_warp_splinter.cpp @@ -115,7 +115,7 @@ class npc_warp_splinter_treant : public CreatureScript return; } - if (me->GetVictim()->GetGUID() != WarpGuid) + if (me->EnsureVictim()->GetGUID() != WarpGuid) DoMeleeAttackIfReady(); } }; |
