aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjackpoz <giacomopoz@gmail.com>2014-03-21 22:47:58 +0100
committerjackpoz <giacomopoz@gmail.com>2014-03-21 22:47:58 +0100
commit9e99db035f554c8f4954e025f599ef752c1f4e01 (patch)
treeaec13f53cd17c7fc3435d6cce35cef29a2eddfeb
parentada0598bb0be0545353ff0e5ed8823b7eb78f66b (diff)
Core/Misc: Fix some static analysis issues
Add some asserts and additional NULL checks as sanity checks.
-rw-r--r--src/server/game/DungeonFinding/LFGMgr.cpp1
-rw-r--r--src/server/game/Entities/GameObject/GameObject.cpp1
-rw-r--r--src/server/game/Entities/Object/Object.cpp2
-rw-r--r--src/server/game/Entities/Player/Player.cpp5
-rw-r--r--src/server/scripts/Northrend/Gundrak/boss_slad_ran.cpp5
-rw-r--r--src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp48
-rw-r--r--src/server/scripts/Spells/spell_pet.cpp2
-rw-r--r--src/server/scripts/Spells/spell_priest.cpp1
-rw-r--r--src/server/scripts/Spells/spell_rogue.cpp1
-rw-r--r--src/server/scripts/Spells/spell_warlock.cpp3
-rw-r--r--src/server/scripts/Spells/spell_warrior.cpp1
11 files changed, 47 insertions, 23 deletions
diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp
index 822ae904ef1..8131be9fa45 100644
--- a/src/server/game/DungeonFinding/LFGMgr.cpp
+++ b/src/server/game/DungeonFinding/LFGMgr.cpp
@@ -968,6 +968,7 @@ void LFGMgr::MakeNewGroup(LfgProposal const& proposal)
player->CastSpell(player, LFG_SPELL_DUNGEON_COOLDOWN, false);
}
+ ASSERT(grp);
grp->SetDungeonDifficulty(Difficulty(dungeon->difficulty));
uint64 gguid = grp->GetGUID();
SetDungeon(gguid, dungeon->Entry());
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp
index 82b4ff3c03d..80171edd715 100644
--- a/src/server/game/Entities/GameObject/GameObject.cpp
+++ b/src/server/game/Entities/GameObject/GameObject.cpp
@@ -1034,6 +1034,7 @@ void GameObject::TriggeringLinkedGameObject(uint32 trapEntry, Unit* target)
if (!trapSpell) // checked at load already
return;
+ ASSERT(GetOwner());
float range = float(target->GetSpellMaxRangeForTarget(GetOwner(), trapSpell));
// search nearest linked GO
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp
index 7241087101d..944498d0fed 100644
--- a/src/server/game/Entities/Object/Object.cpp
+++ b/src/server/game/Entities/Object/Object.cpp
@@ -370,6 +370,7 @@ void Object::BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
{
if (flags & UPDATEFLAG_POSITION)
{
+ ASSERT(object);
Transport* transport = object->GetTransport();
if (transport)
@@ -459,6 +460,7 @@ void Object::BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
// 0x4
if (flags & UPDATEFLAG_HAS_TARGET)
{
+ ASSERT(unit);
if (Unit* victim = unit->GetVictim())
data->append(victim->GetPackGUID());
else
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 6775ef5042b..d96439748e0 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -4205,6 +4205,7 @@ bool Player::Has310Flyer(bool checkAllSpells, uint32 excludeSpellId)
break; // We can break because mount spells belong only to one skillline (at least 310 flyers do)
spellInfo = sSpellMgr->GetSpellInfo(itr->first);
+ ASSERT(spellInfo);
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
if (spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED &&
spellInfo->Effects[i].CalcValue() == 310)
@@ -15743,6 +15744,7 @@ bool Player::SatisfyQuestExclusiveGroup(Quest const* qInfo, bool msg)
// not allow have daily quest if daily quest from exclusive group already recently completed
Quest const* Nquest = sObjectMgr->GetQuestTemplate(exclude_Id);
+ ASSERT(Nquest);
if (!SatisfyQuestDay(Nquest, false) || !SatisfyQuestWeek(Nquest, false) || !SatisfyQuestSeasonal(Nquest, false))
{
if (msg)
@@ -15944,6 +15946,7 @@ bool Player::TakeQuestSourceItem(uint32 questId, bool msg)
return false;
}
+ ASSERT(item);
bool destroyItem = true;
for (uint8 n = 0; n < QUEST_ITEM_OBJECTIVES_COUNT; ++n)
if (item->StartQuest == questId && srcItemId == quest->RequiredItemId[n])
@@ -21330,6 +21333,7 @@ bool Player::ActivateTaxiPathTo(std::vector<uint32> const& nodes, Creature* npc
if (sWorld->getBoolConfig(CONFIG_INSTANT_TAXI))
{
TaxiNodesEntry const* lastPathNode = sTaxiNodesStore.LookupEntry(nodes[nodes.size()-1]);
+ ASSERT(lastPathNode);
m_taxi.ClearTaxiDestinations();
TeleportTo(lastPathNode->map_id, lastPathNode->x, lastPathNode->y, lastPathNode->z, GetOrientation());
return false;
@@ -21550,6 +21554,7 @@ inline bool Player::_StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 c
if (crItem->ExtendedCost) // case for new honor system
{
ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(crItem->ExtendedCost);
+ ASSERT(iece);
if (iece->reqhonorpoints)
ModifyHonorPoints(- int32(iece->reqhonorpoints * count));
diff --git a/src/server/scripts/Northrend/Gundrak/boss_slad_ran.cpp b/src/server/scripts/Northrend/Gundrak/boss_slad_ran.cpp
index 9a83c33890e..0feec20d55f 100644
--- a/src/server/scripts/Northrend/Gundrak/boss_slad_ran.cpp
+++ b/src/server/scripts/Northrend/Gundrak/boss_slad_ran.cpp
@@ -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();
}
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 ca0ea947295..d92d8aaf5db 100644
--- a/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp
+++ b/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp
@@ -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);
- }
- else
- {
- Essence->AI()->Talk(DESI_SAY_AFTER);
+ if (Phase == 1)
+ {
+ Essence->AI()->Talk(SUFF_SAY_AFTER);
+ }
+ else
+ {
+ Essence->AI()->Talk(DESI_SAY_AFTER);
+ }
+ Essence->DespawnOrUnsummon();
}
- Essence->DespawnOrUnsummon();
me->SetUInt32Value(UNIT_NPC_EMOTESTATE, 0);
EssenceGUID = 0;
SoulCount = 0;
diff --git a/src/server/scripts/Spells/spell_pet.cpp b/src/server/scripts/Spells/spell_pet.cpp
index a7742630ccd..e50bc681352 100644
--- a/src/server/scripts/Spells/spell_pet.cpp
+++ b/src/server/scripts/Spells/spell_pet.cpp
@@ -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());
}
diff --git a/src/server/scripts/Spells/spell_priest.cpp b/src/server/scripts/Spells/spell_priest.cpp
index 71e5dac28ec..03d5cbc3f06 100644
--- a/src/server/scripts/Spells/spell_priest.cpp
+++ b/src/server/scripts/Spells/spell_priest.cpp
@@ -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);
}
diff --git a/src/server/scripts/Spells/spell_rogue.cpp b/src/server/scripts/Spells/spell_rogue.cpp
index d1d43684f3e..1773805b671 100644
--- a/src/server/scripts/Spells/spell_rogue.cpp
+++ b/src/server/scripts/Spells/spell_rogue.cpp
@@ -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)
{
diff --git a/src/server/scripts/Spells/spell_warlock.cpp b/src/server/scripts/Spells/spell_warlock.cpp
index 36e63b5a94e..b538d296c3d 100644
--- a/src/server/scripts/Spells/spell_warlock.cpp
+++ b/src/server/scripts/Spells/spell_warlock.cpp
@@ -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);
diff --git a/src/server/scripts/Spells/spell_warrior.cpp b/src/server/scripts/Spells/spell_warrior.cpp
index 5a655a92996..d309051114c 100644
--- a/src/server/scripts/Spells/spell_warrior.cpp
+++ b/src/server/scripts/Spells/spell_warrior.cpp
@@ -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