aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSubv <s.v.h21@hotmail.com>2013-05-17 21:11:18 -0500
committerSubv <s.v.h21@hotmail.com>2013-05-17 21:11:18 -0500
commit25acef257240edb7763eac043554ca7c7ac767eb (patch)
treee574a1a4936201d811a06eb132720eef68d99d99 /src
parent7c18bbb95f896fa320e4f8a2b7808714b8ba270c (diff)
* Batch of fixes for issues found by static analysis.
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Player/Player.cpp1
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp6
-rw-r--r--src/server/game/Groups/Group.cpp144
-rw-r--r--src/server/game/Spells/Auras/SpellAuras.cpp4
-rw-r--r--src/server/scripts/Commands/cs_account.cpp2
-rw-r--r--src/server/scripts/Commands/cs_wp.cpp2
-rw-r--r--src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp2
-rw-r--r--src/server/scripts/Kalimdor/zone_winterspring.cpp6
-rw-r--r--src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp4
-rw-r--r--src/server/scripts/World/npcs_special.cpp2
10 files changed, 86 insertions, 87 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 83118e6ded7..b1abf028262 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -4149,6 +4149,7 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank)
// learnSpell(prev_id, false);
}
// if ranked non-stackable spell: need activate lesser rank and update dendence state
+ /// No need to check for spellInfo != NULL here because if cur_active is true, then that means that the spell was already in m_spells, and only valid spells can be pushed there.
else if (cur_active && !spellInfo->IsStackableWithRanks() && spellInfo->IsRanked())
{
// need manually update dependence state (learn spell ignore like attempts)
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 3872f9154b9..5fb106b4913 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -7478,7 +7478,7 @@ bool Unit::HandleAuraProc(Unit* victim, uint32 damage, Aura* triggeredByAura, Sp
case SPELLFAMILY_PALADIN:
{
// Infusion of Light
- if (dummySpell->SpellIconID == 3021)
+ if (procSpell && dummySpell->SpellIconID == 3021)
{
// Flash of Light HoT on Flash of Light when Sacred Shield active
if (procSpell->SpellFamilyFlags[0] & 0x40000000 && procSpell->SpellIconID == 242)
@@ -7509,6 +7509,8 @@ bool Unit::HandleAuraProc(Unit* victim, uint32 damage, Aura* triggeredByAura, Sp
// Glyph of Divinity
else if (dummySpell->Id == 54939)
{
+ if (!procSpell)
+ return false;
*handled = true;
// Check if we are the target and prevent mana gain
if (victim && triggeredByAura->GetCasterGUID() == victim->GetGUID())
@@ -16837,7 +16839,7 @@ void Unit::_EnterVehicle(Vehicle* vehicle, int8 seatId, AuraApplication const* a
}
}
- if (aurApp && aurApp->GetRemoveMode())
+ if (!aurApp || aurApp->GetRemoveMode())
return;
if (Player* player = ToPlayer())
diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp
index 50c50fd4b1d..c21cc9210dc 100644
--- a/src/server/game/Groups/Group.cpp
+++ b/src/server/game/Groups/Group.cpp
@@ -365,24 +365,21 @@ bool Group::AddMember(Player* player)
SubGroupCounterIncrease(subGroup);
- if (player)
+ player->SetGroupInvite(NULL);
+ if (player->GetGroup())
{
- player->SetGroupInvite(NULL);
- if (player->GetGroup())
- {
- if (isBGGroup() || isBFGroup()) // if player is in group and he is being added to BG raid group, then call SetBattlegroundRaid()
- player->SetBattlegroundOrBattlefieldRaid(this, subGroup);
- else //if player is in bg raid and we are adding him to normal group, then call SetOriginalGroup()
- player->SetOriginalGroup(this, subGroup);
- }
- else //if player is not in group, then call set group
- player->SetGroup(this, subGroup);
-
- // if the same group invites the player back, cancel the homebind timer
- InstanceGroupBind* bind = GetBoundInstance(player);
- if (bind && bind->save->GetInstanceId() == player->GetInstanceId())
- player->m_InstanceValid = true;
+ if (isBGGroup() || isBFGroup()) // if player is in group and he is being added to BG raid group, then call SetBattlegroundRaid()
+ player->SetBattlegroundOrBattlefieldRaid(this, subGroup);
+ else //if player is in bg raid and we are adding him to normal group, then call SetOriginalGroup()
+ player->SetOriginalGroup(this, subGroup);
}
+ else //if player is not in group, then call set group
+ player->SetGroup(this, subGroup);
+
+ // if the same group invites the player back, cancel the homebind timer
+ InstanceGroupBind* bind = GetBoundInstance(player);
+ if (bind && bind->save->GetInstanceId() == player->GetInstanceId())
+ player->m_InstanceValid = true;
if (!isRaidGroup()) // reset targetIcons for non-raid-groups
{
@@ -408,89 +405,86 @@ bool Group::AddMember(Player* player)
SendUpdate();
sScriptMgr->OnGroupAddMember(this, player->GetGUID());
- if (player)
+ if (!IsLeader(player->GetGUID()) && !isBGGroup() && !isBFGroup())
{
- if (!IsLeader(player->GetGUID()) && !isBGGroup() && !isBFGroup())
- {
- // reset the new member's instances, unless he is currently in one of them
- // including raid/heroic instances that they are not permanently bound to!
- player->ResetInstances(INSTANCE_RESET_GROUP_JOIN, false);
- player->ResetInstances(INSTANCE_RESET_GROUP_JOIN, true);
+ // reset the new member's instances, unless he is currently in one of them
+ // including raid/heroic instances that they are not permanently bound to!
+ player->ResetInstances(INSTANCE_RESET_GROUP_JOIN, false);
+ player->ResetInstances(INSTANCE_RESET_GROUP_JOIN, true);
- if (player->getLevel() >= LEVELREQUIREMENT_HEROIC)
+ if (player->getLevel() >= LEVELREQUIREMENT_HEROIC)
+ {
+ if (player->GetDungeonDifficulty() != GetDungeonDifficulty())
{
- if (player->GetDungeonDifficulty() != GetDungeonDifficulty())
- {
- player->SetDungeonDifficulty(GetDungeonDifficulty());
- player->SendDungeonDifficulty(true);
- }
- if (player->GetRaidDifficulty() != GetRaidDifficulty())
- {
- player->SetRaidDifficulty(GetRaidDifficulty());
- player->SendRaidDifficulty(true);
- }
+ player->SetDungeonDifficulty(GetDungeonDifficulty());
+ player->SendDungeonDifficulty(true);
+ }
+ if (player->GetRaidDifficulty() != GetRaidDifficulty())
+ {
+ player->SetRaidDifficulty(GetRaidDifficulty());
+ player->SendRaidDifficulty(true);
}
}
- player->SetGroupUpdateFlag(GROUP_UPDATE_FULL);
- UpdatePlayerOutOfRange(player);
+ }
+ player->SetGroupUpdateFlag(GROUP_UPDATE_FULL);
+ UpdatePlayerOutOfRange(player);
- // quest related GO state dependent from raid membership
- if (isRaidGroup())
- player->UpdateForQuestWorldObjects();
+ // quest related GO state dependent from raid membership
+ if (isRaidGroup())
+ player->UpdateForQuestWorldObjects();
- {
- // Broadcast new player group member fields to rest of the group
- player->SetFieldNotifyFlag(UF_FLAG_PARTY_MEMBER);
+ {
+ // Broadcast new player group member fields to rest of the group
+ player->SetFieldNotifyFlag(UF_FLAG_PARTY_MEMBER);
- UpdateData groupData;
- WorldPacket groupDataPacket;
+ UpdateData groupData;
+ WorldPacket groupDataPacket;
- // Broadcast group members' fields to player
- for (GroupReference* itr = GetFirstMember(); itr != NULL; itr = itr->next())
- {
- if (itr->getSource() == player)
- continue;
+ // Broadcast group members' fields to player
+ for (GroupReference* itr = GetFirstMember(); itr != NULL; itr = itr->next())
+ {
+ if (itr->getSource() == player)
+ continue;
- if (Player* member = itr->getSource())
+ if (Player* member = itr->getSource())
+ {
+ if (player->HaveAtClient(member))
{
- if (player->HaveAtClient(member))
- {
- member->SetFieldNotifyFlag(UF_FLAG_PARTY_MEMBER);
- member->BuildValuesUpdateBlockForPlayer(&groupData, player);
- member->RemoveFieldNotifyFlag(UF_FLAG_PARTY_MEMBER);
- }
+ member->SetFieldNotifyFlag(UF_FLAG_PARTY_MEMBER);
+ member->BuildValuesUpdateBlockForPlayer(&groupData, player);
+ member->RemoveFieldNotifyFlag(UF_FLAG_PARTY_MEMBER);
+ }
- if (member->HaveAtClient(player))
+ if (member->HaveAtClient(player))
+ {
+ UpdateData newData;
+ WorldPacket newDataPacket;
+ player->BuildValuesUpdateBlockForPlayer(&newData, member);
+ if (newData.HasData())
{
- UpdateData newData;
- WorldPacket newDataPacket;
- player->BuildValuesUpdateBlockForPlayer(&newData, member);
- if (newData.HasData())
- {
- newData.BuildPacket(&newDataPacket);
- member->SendDirectMessage(&newDataPacket);
- }
+ newData.BuildPacket(&newDataPacket);
+ member->SendDirectMessage(&newDataPacket);
}
}
}
+ }
- if (groupData.HasData())
- {
- groupData.BuildPacket(&groupDataPacket);
- player->SendDirectMessage(&groupDataPacket);
- }
-
- player->RemoveFieldNotifyFlag(UF_FLAG_PARTY_MEMBER);
+ if (groupData.HasData())
+ {
+ groupData.BuildPacket(&groupDataPacket);
+ player->SendDirectMessage(&groupDataPacket);
}
- if (m_maxEnchantingLevel < player->GetSkillValue(SKILL_ENCHANTING))
- m_maxEnchantingLevel = player->GetSkillValue(SKILL_ENCHANTING);
+ player->RemoveFieldNotifyFlag(UF_FLAG_PARTY_MEMBER);
}
+ if (m_maxEnchantingLevel < player->GetSkillValue(SKILL_ENCHANTING))
+ m_maxEnchantingLevel = player->GetSkillValue(SKILL_ENCHANTING);
+
return true;
}
-bool Group::RemoveMember(uint64 guid, const RemoveMethod &method /*= GROUP_REMOVEMETHOD_DEFAULT*/, uint64 kicker /*= 0*/, const char* reason /*= NULL*/)
+bool Group::RemoveMember(uint64 guid, const RemoveMethod& method /*= GROUP_REMOVEMETHOD_DEFAULT*/, uint64 kicker /*= 0*/, const char* reason /*= NULL*/)
{
BroadcastGroupUpdate();
diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp
index 732cb50e274..e9c456c4c7b 100644
--- a/src/server/game/Spells/Auras/SpellAuras.cpp
+++ b/src/server/game/Spells/Auras/SpellAuras.cpp
@@ -1600,6 +1600,9 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b
switch (GetId())
{
case 19746:
+ if (!caster)
+ break;
+
// Improved concentration aura - linked aura
if (caster->HasAura(20254) || caster->HasAura(20255) || caster->HasAura(20256))
{
@@ -1608,6 +1611,7 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b
else
target->RemoveAura(63510);
}
+ break;
case 31821:
// Aura Mastery Triggered Spell Handler
// If apply Concentration Aura -> trigger -> apply Aura Mastery Immunity
diff --git a/src/server/scripts/Commands/cs_account.cpp b/src/server/scripts/Commands/cs_account.cpp
index 9aa68e0892c..c347648abab 100644
--- a/src/server/scripts/Commands/cs_account.cpp
+++ b/src/server/scripts/Commands/cs_account.cpp
@@ -482,7 +482,7 @@ public:
char* arg3 = strtok(NULL, " ");
bool isAccountNameGiven = true;
- if (arg1 && !arg3)
+ if (!arg3)
{
if (!handler->getSelectedPlayer())
return false;
diff --git a/src/server/scripts/Commands/cs_wp.cpp b/src/server/scripts/Commands/cs_wp.cpp
index bb48e94f744..b7a89ceb325 100644
--- a/src/server/scripts/Commands/cs_wp.cpp
+++ b/src/server/scripts/Commands/cs_wp.cpp
@@ -796,7 +796,7 @@ public:
if (show == "info")
{
// Check if the user did specify a visual waypoint
- if (target->GetEntry() != VISUAL_WAYPOINT)
+ if (target && target->GetEntry() != VISUAL_WAYPOINT)
{
handler->PSendSysMessage(LANG_WAYPOINT_VP_SELECT);
handler->SetSentErrorMessage(true);
diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp
index 630c379e71e..87a09749724 100644
--- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp
+++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp
@@ -773,7 +773,7 @@ public:
void JustSummoned(Creature* summon)
{
Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 30, true);
- if (target && summon)
+ if (target)
summon->Attack(target, false);
summons.Summon(summon);
}
diff --git a/src/server/scripts/Kalimdor/zone_winterspring.cpp b/src/server/scripts/Kalimdor/zone_winterspring.cpp
index 2b68c0a2cb6..c523cfba952 100644
--- a/src/server/scripts/Kalimdor/zone_winterspring.cpp
+++ b/src/server/scripts/Kalimdor/zone_winterspring.cpp
@@ -182,10 +182,8 @@ public:
}
if (!found)
- {
return;
- }
-
+
DoNextDialogueStep();
}
@@ -210,7 +208,7 @@ private:
void DoNextDialogueStep()
{
// Last Dialogue Entry done?
- if (_currentEntry && !_currentEntry->TextEntry)
+ if (!_currentEntry || !_currentEntry->TextEntry)
{
_actionTimer = 0;
return;
diff --git a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp
index d861343116f..b85c24a22eb 100644
--- a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp
+++ b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp
@@ -754,7 +754,7 @@ public:
void UpdateAI(uint32 diff)
{
- if (!UpdateVictim() && _phase != PHASE_NOT_STARTED && _phase != PHASE_TWO)
+ if (!instance || (!UpdateVictim() && _phase != PHASE_NOT_STARTED && _phase != PHASE_TWO))
return;
events.Update(diff);
@@ -854,7 +854,7 @@ public:
}
}
- if (_arcaneReinforcements && instance)
+ if (_arcaneReinforcements)
{
for (uint8 rangeDisks = 0; rangeDisks < (GetDifficulty() == RAID_DIFFICULTY_10MAN_NORMAL ? 4 : 5); rangeDisks++)
{
diff --git a/src/server/scripts/World/npcs_special.cpp b/src/server/scripts/World/npcs_special.cpp
index b5f66fcc25e..56841fcdaa1 100644
--- a/src/server/scripts/World/npcs_special.cpp
+++ b/src/server/scripts/World/npcs_special.cpp
@@ -1751,7 +1751,7 @@ public:
{
me->HandleEmoteCommand(emote);
Unit* owner = me->GetOwner();
- if (emote != TEXT_EMOTE_KISS || owner || owner->GetTypeId() != TYPEID_PLAYER ||
+ if (emote != TEXT_EMOTE_KISS || !owner || owner->GetTypeId() != TYPEID_PLAYER ||
owner->ToPlayer()->GetTeam() != player->GetTeam())
{
return;