diff options
author | kaelima <kaelima@live.se> | 2012-10-07 01:31:43 +0200 |
---|---|---|
committer | kaelima <kaelima@live.se> | 2012-10-07 01:31:43 +0200 |
commit | 8c013955ace9c830efed0e353b4dcf606fb8f4f8 (patch) | |
tree | b0cbf9f3023a0882cf2a84758c1afdeaa4b6f38a /src | |
parent | bb08d429a3447dabadf456a6062252336c0c5678 (diff) |
Core/Misc: Fix some possible issues detected by static code analysis
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartScript.cpp | 4 | ||||
-rw-r--r-- | src/server/game/Battlefield/Battlefield.cpp | 4 | ||||
-rw-r--r-- | src/server/game/Battlefield/Zones/BattlefieldWG.cpp | 12 | ||||
-rwxr-xr-x | src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp | 2 | ||||
-rwxr-xr-x | src/server/game/Battlegrounds/Zones/BattlegroundAV.h | 6 | ||||
-rwxr-xr-x | src/server/game/Battlegrounds/Zones/BattlegroundBE.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp | 2 | ||||
-rwxr-xr-x | src/server/game/Battlegrounds/Zones/BattlegroundNA.cpp | 2 | ||||
-rwxr-xr-x | src/server/game/Battlegrounds/Zones/BattlegroundRL.cpp | 2 | ||||
-rwxr-xr-x | src/server/game/Battlegrounds/Zones/BattlegroundRV.cpp | 2 | ||||
-rwxr-xr-x | src/server/game/Entities/Player/Player.cpp | 17 | ||||
-rwxr-xr-x | src/server/game/Globals/ObjectMgr.cpp | 2 | ||||
-rwxr-xr-x | src/server/game/Movement/Waypoints/WaypointManager.h | 2 | ||||
-rwxr-xr-x | src/server/game/Spells/SpellMgr.cpp | 2 | ||||
-rwxr-xr-x | src/server/game/Spells/SpellMgr.h | 2 | ||||
-rwxr-xr-x | src/server/game/Spells/SpellScript.h | 2 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_misc.cpp | 8 |
17 files changed, 35 insertions, 38 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 32b9f8b5903..f37ae4fa60e 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -130,12 +130,10 @@ void SmartScript::ProcessEventsFor(SMART_EVENT e, Unit* unit, uint32 var0, uint3 if (eventType == e/* && (!(*i).event.event_phase_mask || IsInPhase((*i).event.event_phase_mask)) && !((*i).event.event_flags & SMART_EVENT_FLAG_NOT_REPEATABLE && (*i).runOnce)*/) { - bool meets = true; ConditionList conds = sConditionMgr->GetConditionsForSmartEvent((*i).entryOrGuid, (*i).event_id, (*i).source_type); ConditionSourceInfo info = ConditionSourceInfo(unit, GetBaseObject()); - meets = sConditionMgr->IsObjectMeetToConditions(info, conds); - if (meets) + if (sConditionMgr->IsObjectMeetToConditions(info, conds)) ProcessEvent(*i, unit, var0, var1, bvar, spell, gob); } } diff --git a/src/server/game/Battlefield/Battlefield.cpp b/src/server/game/Battlefield/Battlefield.cpp index ae58f3504b4..1c99934bafc 100644 --- a/src/server/game/Battlefield/Battlefield.cpp +++ b/src/server/game/Battlefield/Battlefield.cpp @@ -999,7 +999,7 @@ bool BfCapturePoint::Update(uint32 diff) // get the difference of numbers float fact_diff = ((float) m_activePlayers[0].size() - (float) m_activePlayers[1].size()) * diff / BATTLEFIELD_OBJECTIVE_UPDATE_INTERVAL; - if (!fact_diff) + if (G3D::fuzzyEq(fact_diff, 0.0f)) return false; uint32 Challenger = 0; @@ -1069,7 +1069,7 @@ bool BfCapturePoint::Update(uint32 diff) m_team = TEAM_NEUTRAL; } - if (m_value != oldValue) + if (G3D::fuzzyNe(m_value, oldValue)) SendChangePhase(); if (m_OldState != m_State) diff --git a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp index de1ee1785d8..119880bae8d 100644 --- a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp +++ b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp @@ -528,12 +528,12 @@ void BattlefieldWG::OnCreatureCreate(Creature* creature) case NPC_WINTERGRASP_CATAPULT: case NPC_WINTERGRASP_DEMOLISHER: { - if (!creature->ToTempSummon()->GetSummonerGUID() || !sObjectAccessor->FindPlayer(creature->ToTempSummon()->GetSummonerGUID())) + if (!creature->ToTempSummon() || !creature->ToTempSummon()->GetSummonerGUID() || !sObjectAccessor->FindPlayer(creature->ToTempSummon()->GetSummonerGUID())) { - creature->setDeathState(DEAD); - creature->RemoveFromWorld(); + creature->DespawnOrUnsummon(); return; } + Player* creator = sObjectAccessor->FindPlayer(creature->ToTempSummon()->GetSummonerGUID()); TeamId team = creator->GetTeamId(); @@ -548,8 +548,7 @@ void BattlefieldWG::OnCreatureCreate(Creature* creature) } else { - creature->setDeathState(DEAD); - creature->RemoveFromWorld(); + creature->DespawnOrUnsummon(); return; } } @@ -564,8 +563,7 @@ void BattlefieldWG::OnCreatureCreate(Creature* creature) } else { - creature->setDeathState(DEAD); - creature->RemoveFromWorld(); + creature->DespawnOrUnsummon(); return; } } diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp index c57eeff9911..a348ec69b8a 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp @@ -177,7 +177,7 @@ void BattlegroundAV::HandleQuestComplete(uint32 questid, Player* player) case AV_QUEST_H_COMMANDER3: m_Team_QuestStatus[team][3]++; RewardReputationToTeam(team, 1, player->GetTeam()); - if (m_Team_QuestStatus[team][1] == 120) + if (m_Team_QuestStatus[team][3] == 120) sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BG_AV Quest %i completed (need to implement some events here", questid); break; case AV_QUEST_A_BOSS1: diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAV.h b/src/server/game/Battlegrounds/Zones/BattlegroundAV.h index 28d524977fc..dab67fe3258 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAV.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAV.h @@ -1514,12 +1514,12 @@ enum BG_AV_Objectives struct BG_AV_NodeInfo { - uint16 TotalOwner; - uint16 Owner; - uint16 PrevOwner; BG_AV_States State; BG_AV_States PrevState; uint32 Timer; + uint16 TotalOwner; + uint16 Owner; + uint16 PrevOwner; bool Tower; }; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundBE.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundBE.cpp index d4086b2e48e..402406f7fd0 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundBE.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundBE.cpp @@ -96,7 +96,7 @@ void BattlegroundBE::HandleKillPlayer(Player* player, Player* killer) bool BattlegroundBE::HandlePlayerUnderMap(Player* player) { - player->TeleportTo(GetMapId(), 6238.930176f, 262.963470f, 0.889519f, player->GetOrientation(), false); + player->TeleportTo(GetMapId(), 6238.930176f, 262.963470f, 0.889519f, player->GetOrientation()); return true; } diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp index d8f1883cbda..a64184261c7 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp @@ -202,7 +202,7 @@ void BattlegroundDS::HandleAreaTrigger(Player* player, uint32 trigger) bool BattlegroundDS::HandlePlayerUnderMap(Player* player) { - player->TeleportTo(GetMapId(), 1299.046f, 784.825f, 9.338f, 2.422f, false); + player->TeleportTo(GetMapId(), 1299.046f, 784.825f, 9.338f, 2.422f); return true; } diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundNA.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundNA.cpp index deb2e565b07..6677d665290 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundNA.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundNA.cpp @@ -93,7 +93,7 @@ void BattlegroundNA::HandleKillPlayer(Player* player, Player* killer) bool BattlegroundNA::HandlePlayerUnderMap(Player* player) { - player->TeleportTo(GetMapId(), 4055.504395f, 2919.660645f, 13.611241f, player->GetOrientation(), false); + player->TeleportTo(GetMapId(), 4055.504395f, 2919.660645f, 13.611241f, player->GetOrientation()); return true; } diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundRL.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundRL.cpp index 14c1052ed64..2c715193a3b 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundRL.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundRL.cpp @@ -93,7 +93,7 @@ void BattlegroundRL::HandleKillPlayer(Player* player, Player* killer) bool BattlegroundRL::HandlePlayerUnderMap(Player* player) { - player->TeleportTo(GetMapId(), 1285.810547f, 1667.896851f, 39.957642f, player->GetOrientation(), false); + player->TeleportTo(GetMapId(), 1285.810547f, 1667.896851f, 39.957642f, player->GetOrientation()); return true; } diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundRV.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundRV.cpp index 80018bce0a2..130ba4f3290 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundRV.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundRV.cpp @@ -137,7 +137,7 @@ void BattlegroundRV::HandleKillPlayer(Player* player, Player* killer) bool BattlegroundRV::HandlePlayerUnderMap(Player* player) { - player->TeleportTo(GetMapId(), 763.5f, -284, 28.276f, 2.422f, false); + player->TeleportTo(GetMapId(), 763.5f, -284, 28.276f, 2.422f); return true; } diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 0ebb0c54a24..50f5fd4c978 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -7620,21 +7620,19 @@ void Player::DuelComplete(DuelCompleteType type) break; case DUEL_WON: UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOSE_DUEL, 1); - if (duel->opponent) - { - duel->opponent->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_DUEL, 1); + duel->opponent->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_DUEL, 1); + + // Credit for quest Death's Challenge + if (getClass() == CLASS_DEATH_KNIGHT && duel->opponent->GetQuestStatus(12733) == QUEST_STATUS_INCOMPLETE) + duel->opponent->CastSpell(duel->opponent, 52994, true); - //Credit for quest Death's Challenge - if (getClass() == CLASS_DEATH_KNIGHT && duel->opponent->GetQuestStatus(12733) == QUEST_STATUS_INCOMPLETE) - duel->opponent->CastSpell(duel->opponent, 52994, true); - } break; default: break; } // Victory emote spell - if (type != DUEL_INTERRUPTED && duel->opponent) + if (type != DUEL_INTERRUPTED) duel->opponent->CastSpell(duel->opponent, 52852, true); //Remove Duel Flag object @@ -20845,6 +20843,9 @@ void Player::ContinueTaxiFlight() sLog->outDebug(LOG_FILTER_UNITS, "WORLD: Restart character %u taxi flight", GetGUIDLow()); uint32 mountDisplayId = sObjectMgr->GetTaxiMountDisplayId(sourceNode, GetTeam(), true); + if (!mountDisplayId) + return; + uint32 path = m_taxi.GetCurrentTaxiPath(); // search appropriate start path node diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index fd2a2fe143a..95a27fd14e1 100755 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -5531,7 +5531,7 @@ uint32 ObjectMgr::GetTaxiMountDisplayId(uint32 id, uint32 team, bool allowed_alt if (!mount_id) { sLog->outError(LOG_FILTER_SQL, "No displayid found for the taxi mount with the entry %u! Can't load it!", mount_entry); - return false; + return 0; } } } diff --git a/src/server/game/Movement/Waypoints/WaypointManager.h b/src/server/game/Movement/Waypoints/WaypointManager.h index 73d611e0419..df20c513c90 100755 --- a/src/server/game/Movement/Waypoints/WaypointManager.h +++ b/src/server/game/Movement/Waypoints/WaypointManager.h @@ -27,9 +27,9 @@ struct WaypointData { uint32 id; float x, y, z, orientation; - bool run; uint32 delay; uint32 event_id; + bool run; uint8 event_chance; }; diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index edce89a1a5b..ec7359a7ba4 100755 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -645,7 +645,7 @@ SpellSpellGroupMapBounds SpellMgr::GetSpellSpellGroupMapBounds(uint32 spell_id) return SpellSpellGroupMapBounds(mSpellSpellGroup.lower_bound(spell_id), mSpellSpellGroup.upper_bound(spell_id)); } -uint32 SpellMgr::IsSpellMemberOfSpellGroup(uint32 spellid, SpellGroup groupid) const +bool SpellMgr::IsSpellMemberOfSpellGroup(uint32 spellid, SpellGroup groupid) const { SpellSpellGroupMapBounds spellGroup = GetSpellSpellGroupMapBounds(spellid); for (SpellSpellGroupMap::const_iterator itr = spellGroup.first; itr != spellGroup.second; ++itr) diff --git a/src/server/game/Spells/SpellMgr.h b/src/server/game/Spells/SpellMgr.h index 9423ebf2893..9646bc9dabf 100755 --- a/src/server/game/Spells/SpellMgr.h +++ b/src/server/game/Spells/SpellMgr.h @@ -643,7 +643,7 @@ class SpellMgr // Spell Groups table SpellSpellGroupMapBounds GetSpellSpellGroupMapBounds(uint32 spell_id) const; - uint32 IsSpellMemberOfSpellGroup(uint32 spellid, SpellGroup groupid) const; + bool IsSpellMemberOfSpellGroup(uint32 spellid, SpellGroup groupid) const; SpellGroupSpellMapBounds GetSpellGroupSpellMapBounds(SpellGroup group_id) const; void GetSetOfSpellsInSpellGroup(SpellGroup group_id, std::set<uint32>& foundSpells) const; diff --git a/src/server/game/Spells/SpellScript.h b/src/server/game/Spells/SpellScript.h index a5d77806739..c8126f8aaf3 100755 --- a/src/server/game/Spells/SpellScript.h +++ b/src/server/game/Spells/SpellScript.h @@ -582,8 +582,8 @@ class AuraScript : public _SpellScript class ScriptStateStore { public: - uint8 _currentScriptState; AuraApplication const* _auraApplication; + uint8 _currentScriptState; bool _defaultActionPrevented; ScriptStateStore(uint8 currentScriptState, AuraApplication const* auraApplication, bool defaultActionPrevented) : _currentScriptState(currentScriptState), _auraApplication(auraApplication), _defaultActionPrevented(defaultActionPrevented) diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index 2c9623b23a6..f7280cf906e 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -476,12 +476,12 @@ public: } else if (map->IsDungeon()) { - Map* map = target->GetMap(); + Map* destMap = target->GetMap(); - if (map->Instanceable() && map->GetInstanceId() != map->GetInstanceId()) + if (destMap->Instanceable() && destMap->GetInstanceId() != map->GetInstanceId()) target->UnbindInstance(map->GetInstanceId(), target->GetDungeonDifficulty(), true); - // we are in instance, and can summon only player in our group with us as lead + // we are in an instance, and can only summon players in our group with us as leader if (!handler->GetSession()->GetPlayer()->GetGroup() || !target->GetGroup() || (target->GetGroup()->GetLeaderGUID() != handler->GetSession()->GetPlayer()->GetGUID()) || (handler->GetSession()->GetPlayer()->GetGroup()->GetLeaderGUID() != handler->GetSession()->GetPlayer()->GetGUID())) @@ -2568,7 +2568,7 @@ public: { pet->SavePetToDB(PET_SAVE_AS_CURRENT); // not let dismiss dead pet - if (pet && pet->isAlive()) + if (pet->isAlive()) player->RemovePet(pet, PET_SAVE_NOT_IN_SLOT); } } |