Core/Misc: Fix some static analysis issues

Add some asserts and additional NULL checks as sanity checks.
This commit is contained in:
jackpoz
2014-03-21 22:47:58 +01:00
parent ada0598bb0
commit 9e99db035f
11 changed files with 47 additions and 23 deletions

View File

@@ -250,8 +250,9 @@ public:
target->CastSpell(target, SPELL_SNAKE_WRAP, true);
if (TempSummon* _me = me->ToTempSummon())
if (Creature* sladran = _me->GetSummoner()->ToCreature())
sladran->AI()->SetGUID(target->GetGUID(), DATA_SNAKES_WHYD_IT_HAVE_TO_BE_SNAKES);
if (Unit* summoner = _me->GetSummoner())
if (Creature* sladran = summoner->ToCreature())
sladran->AI()->SetGUID(target->GetGUID(), DATA_SNAKES_WHYD_IT_HAVE_TO_BE_SNAKES);
me->DespawnOrUnsummon();
}

View File

@@ -295,13 +295,13 @@ public:
Timer = 1000;
if (Phase == 3)
{
if (!Essence->IsAlive())
if (Essence && !Essence->IsAlive())
DoCast(me, 7, true);
else return;
}
else
{
if (Essence->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE))
if (Essence && Essence->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE))
{
MergeThreatList(Essence);
Essence->RemoveAllAuras();
@@ -312,31 +312,37 @@ public:
break;
case 4:
Timer = 1500;
if (Essence->IsWithinDistInMap(me, 10))
if (Essence)
{
Essence->SetUInt32Value(UNIT_NPC_EMOTESTATE, 374); //rotate and disappear
Timer = 2000;
me->RemoveAurasDueToSpell(SPELL_SUBMERGE);
}
else
{
MergeThreatList(Essence);
Essence->RemoveAllAuras();
Essence->DeleteThreatList();
Essence->GetMotionMaster()->MoveFollow(me, 0, 0);
return;
if (Essence->IsWithinDistInMap(me, 10))
{
Essence->SetUInt32Value(UNIT_NPC_EMOTESTATE, 374); //rotate and disappear
Timer = 2000;
me->RemoveAurasDueToSpell(SPELL_SUBMERGE);
}
else
{
MergeThreatList(Essence);
Essence->RemoveAllAuras();
Essence->DeleteThreatList();
Essence->GetMotionMaster()->MoveFollow(me, 0, 0);
return;
}
}
break;
case 5:
if (Phase == 1)
if (Essence)
{
Essence->AI()->Talk(SUFF_SAY_AFTER);
if (Phase == 1)
{
Essence->AI()->Talk(SUFF_SAY_AFTER);
}
else
{
Essence->AI()->Talk(DESI_SAY_AFTER);
}
Essence->DespawnOrUnsummon();
}
else
{
Essence->AI()->Talk(DESI_SAY_AFTER);
}
Essence->DespawnOrUnsummon();
me->SetUInt32Value(UNIT_NPC_EMOTESTATE, 0);
EssenceGUID = 0;
SoulCount = 0;

View File

@@ -941,6 +941,7 @@ public:
if (itr != pet->ToPet()->m_spells.end()) // If pet has Wild Hunt
{
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itr->first); // Then get the SpellProto and add the dummy effect value
ASSERT(spellInfo);
mod += CalculatePct(1.0f, spellInfo->Effects[EFFECT_1].CalcValue());
}
@@ -971,6 +972,7 @@ public:
if (itr != pet->ToPet()->m_spells.end()) // If pet has Wild Hunt
{
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itr->first); // Then get the SpellProto and add the dummy effect value
ASSERT(spellInfo);
mod += CalculatePct(1.0f, spellInfo->Effects[EFFECT_1].CalcValue());
}

View File

@@ -237,6 +237,7 @@ class spell_pri_glyph_of_prayer_of_healing : public SpellScriptLoader
PreventDefaultAction();
SpellInfo const* triggeredSpellInfo = sSpellMgr->GetSpellInfo(SPELL_PRIEST_GLYPH_OF_PRAYER_OF_HEALING_HEAL);
ASSERT(triggeredSpellInfo);
int32 heal = int32(CalculatePct(int32(eventInfo.GetHealInfo()->GetHeal()), aurEff->GetAmount()) / triggeredSpellInfo->GetMaxTicks());
GetTarget()->CastCustomSpell(SPELL_PRIEST_GLYPH_OF_PRAYER_OF_HEALING_HEAL, SPELLVALUE_BASE_POINT0, heal, eventInfo.GetProcTarget(), true, NULL, aurEff);
}

View File

@@ -429,6 +429,7 @@ class spell_rog_preparation : public SpellScriptLoader
for (SpellCooldowns::const_iterator itr = cm.begin(); itr != cm.end();)
{
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itr->first);
ASSERT(spellInfo);
if (spellInfo->SpellFamilyName == SPELLFAMILY_ROGUE)
{

View File

@@ -271,6 +271,7 @@ class spell_warl_demonic_circle_summon : public SpellScriptLoader
// If not in range remove the WARLOCK_DEMONIC_CIRCLE_ALLOW_CAST.
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(SPELL_WARLOCK_DEMONIC_CIRCLE_TELEPORT);
ASSERT(spellInfo);
if (GetTarget()->IsWithinDist(circle, spellInfo->GetMaxRange(true)))
{
@@ -353,6 +354,7 @@ class spell_warl_demonic_empowerment : public SpellScriptLoader
if (targetCreature->IsPet())
{
CreatureTemplate const* ci = sObjectMgr->GetCreatureTemplate(targetCreature->GetEntry());
ASSERT(ci);
switch (ci->family)
{
case CREATURE_FAMILY_SUCCUBUS:
@@ -361,6 +363,7 @@ class spell_warl_demonic_empowerment : public SpellScriptLoader
case CREATURE_FAMILY_VOIDWALKER:
{
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(SPELL_WARLOCK_DEMONIC_EMPOWERMENT_VOIDWALKER);
ASSERT(spellInfo);
int32 hp = int32(targetCreature->CountPctFromMaxHealth(GetCaster()->CalculateSpellDamage(targetCreature, spellInfo, 0)));
targetCreature->CastCustomSpell(targetCreature, SPELL_WARLOCK_DEMONIC_EMPOWERMENT_VOIDWALKER, &hp, NULL, NULL, true);
//unitTarget->CastSpell(unitTarget, 54441, true);

View File

@@ -274,6 +274,7 @@ class spell_warr_deep_wounds : public SpellScriptLoader
damage = target->SpellDamageBonusTaken(caster, GetSpellInfo(), damage, SPELL_DIRECT_DAMAGE);
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(SPELL_WARRIOR_DEEP_WOUNDS_RANK_PERIODIC);
ASSERT(spellInfo);
uint32 ticks = spellInfo->GetDuration() / spellInfo->Effects[EFFECT_0].Amplitude;
// Add remaining ticks to damage done