Permalink
Browse files

Core/Misc: Fix some possible issues detected by static code analysis

  • Loading branch information...
kaelima committed Oct 6, 2012
1 parent bb08d42 commit 8c013955ace9c830efed0e353b4dcf606fb8f4f8
@@ -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);
}
}
@@ -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)
@@ -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;
}
}
@@ -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:
@@ -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;
};
@@ -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;
}
@@ -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;
}
@@ -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;
}
@@ -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;
}
@@ -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;
}
@@ -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
@@ -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;
}
}
}
@@ -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;
};
@@ -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)
@@ -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;
@@ -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)
@@ -476,12 +476,12 @@ class misc_commandscript : public CommandScript
}
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 @@ class misc_commandscript : public CommandScript
{
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);
}
}

2 comments on commit 8c01395

+1 thx.

MMRm replied Oct 7, 2012

very nice

Please sign in to comment.