diff options
author | Nay <dnpd.dd@gmail.com> | 2012-08-30 22:44:03 +0100 |
---|---|---|
committer | Nay <dnpd.dd@gmail.com> | 2012-08-30 22:44:03 +0100 |
commit | abbb896cfb73017cf1c313d597984a9ce0a9dcab (patch) | |
tree | 58cd6165976448c3cdec18c4e4c6381c6bfba936 | |
parent | 5f1977cb1d690d2e60a1f5355244ec472e014278 (diff) |
Core: Fix many "errors"/warnings and coding style (2)
Scripts; also reverted a change to AuthSocket
Errors were found using Cppcheck, open-source static analysis tool
16 files changed, 70 insertions, 93 deletions
diff --git a/src/server/authserver/Server/AuthSocket.cpp b/src/server/authserver/Server/AuthSocket.cpp index ee3a9677130..d55d2cf02b3 100755 --- a/src/server/authserver/Server/AuthSocket.cpp +++ b/src/server/authserver/Server/AuthSocket.cpp @@ -869,7 +869,7 @@ bool AuthSocket::_HandleRealmList() flag &= ~REALM_FLAG_SPECIFYBUILD; std::string name = i->first; - if (buildInfo && (_expversion & PRE_BC_EXP_FLAG && flag & REALM_FLAG_SPECIFYBUILD)) + if (_expversion & PRE_BC_EXP_FLAG && flag & REALM_FLAG_SPECIFYBUILD) { std::ostringstream ss; ss << name << " (" << buildInfo->MajorVersion << '.' << buildInfo->MinorVersion << '.' << buildInfo->BugfixVersion << ')'; @@ -902,15 +902,10 @@ bool AuthSocket::_HandleRealmList() if (_expversion & POST_BC_EXP_FLAG && flag & REALM_FLAG_SPECIFYBUILD) { - if (buildInfo) - { - pkt << uint8(buildInfo->MajorVersion); - pkt << uint8(buildInfo->MinorVersion); - pkt << uint8(buildInfo->BugfixVersion); - pkt << uint16(buildInfo->Build); - } - else - pkt << uint8(0) << uint8(0) << uint8(0) << uint16(0); + pkt << uint8(buildInfo->MajorVersion); + pkt << uint8(buildInfo->MinorVersion); + pkt << uint8(buildInfo->BugfixVersion); + pkt << uint16(buildInfo->Build); } ++RealmListSize; diff --git a/src/server/scripts/Commands/cs_wp.cpp b/src/server/scripts/Commands/cs_wp.cpp index 99ec263b8f9..e3cd185e4a3 100644 --- a/src/server/scripts/Commands/cs_wp.cpp +++ b/src/server/scripts/Commands/cs_wp.cpp @@ -642,19 +642,13 @@ public: { handler->PSendSysMessage("|cff00ff00DEBUG: wp modify del, PathID: |r|cff00ffff%u|r", pathid); - // wpCreature - Creature* wpCreature = NULL; - if (wpGuid != 0) - { - wpCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT)); - if (wpCreature) + if (Creature* wpCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT))) { wpCreature->CombatStop(); wpCreature->DeleteFromDB(); wpCreature->AddObjectToRemoveList(); } - } PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_WAYPOINT_DATA); @@ -681,15 +675,12 @@ public: Player* chr = handler->GetSession()->GetPlayer(); Map* map = chr->GetMap(); { - // wpCreature - Creature* wpCreature = NULL; // What to do: // Move the visual spawnpoint // Respawn the owner of the waypoints if (wpGuid != 0) { - wpCreature = map->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT)); - if (wpCreature) + if (Creature* wpCreature = map->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT))) { wpCreature->CombatStop(); wpCreature->DeleteFromDB(); diff --git a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_chromaggus.cpp b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_chromaggus.cpp index 204fbe5223b..25c3f2e41e3 100644 --- a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_chromaggus.cpp +++ b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_chromaggus.cpp @@ -243,11 +243,9 @@ public: std::list<HostileReference*> threatlist = me->getThreatManager().getThreatList(); for (std::list<HostileReference*>::const_iterator i = threatlist.begin(); i != threatlist.end(); ++i) { - Unit* unit; if ((*i) && (*i)->getSource()) { - unit = Unit::GetUnit(*me, (*i)->getUnitGuid()); - if (unit) + if (Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid())) { //Cast affliction DoCast(unit, RAND(SPELL_BROODAF_BLUE, SPELL_BROODAF_BLACK, diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp index 06c1243645c..533a1aac2f0 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp @@ -201,12 +201,11 @@ public: { for (uint8 i = 0; i < 4; ++i) { - Creature* Temp = NULL; if (AddGUID[i]) { - Temp = Creature::GetCreature((*me), AddGUID[i]); - if (Temp && Temp->isAlive()) - Temp->DisappearAndDie(); + Creature* temp = Creature::GetCreature((*me), AddGUID[i]); + if (temp && temp->isAlive()) + temp->DisappearAndDie(); } } } @@ -215,14 +214,13 @@ public: { for (uint8 i = 0; i < 4; ++i) { - Creature* Temp = NULL; if (AddGUID[i]) { - Temp = Creature::GetCreature((*me), AddGUID[i]); - if (Temp && Temp->isAlive()) + Creature* temp = Creature::GetCreature((*me), AddGUID[i]); + if (temp && temp->isAlive()) { - Temp->AI()->AttackStart(me->getVictim()); - DoZoneInCombat(Temp); + temp->AI()->AttackStart(me->getVictim()); + DoZoneInCombat(temp); } else EnterEvadeMode(); } @@ -250,13 +248,12 @@ public: { for (uint8 i = 0; i < 4; ++i) { - Creature* Temp = NULL; if (AddGUID[i]) { - Temp = Unit::GetCreature((*me), AddGUID[i]); - if (Temp && Temp->isAlive()) - if (!Temp->getVictim()) - Temp->AI()->AttackStart(me->getVictim()); + Creature* temp = Unit::GetCreature((*me), AddGUID[i]); + if (temp && temp->isAlive()) + if (!temp->getVictim()) + temp->AI()->AttackStart(me->getVictim()); } } CheckAdds_Timer = 5000; diff --git a/src/server/scripts/EasternKingdoms/ShadowfangKeep/instance_shadowfang_keep.cpp b/src/server/scripts/EasternKingdoms/ShadowfangKeep/instance_shadowfang_keep.cpp index d4c037d45c3..b405f9eba85 100644 --- a/src/server/scripts/EasternKingdoms/ShadowfangKeep/instance_shadowfang_keep.cpp +++ b/src/server/scripts/EasternKingdoms/ShadowfangKeep/instance_shadowfang_keep.cpp @@ -240,7 +240,6 @@ public: return; Creature* pArchmage = instance->GetCreature(uiArchmageArugalGUID); - Creature* summon = NULL; if (!pArchmage || !pArchmage->isAlive()) return; @@ -252,7 +251,8 @@ public: switch (uiPhase) { case 1: - summon = pArchmage->SummonCreature(pArchmage->GetEntry(), SpawnLocation[4], TEMPSUMMON_TIMED_DESPAWN, 10000); + { + Creature* summon = pArchmage->SummonCreature(pArchmage->GetEntry(), SpawnLocation[4], TEMPSUMMON_TIMED_DESPAWN, 10000); summon->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); summon->SetReactState(REACT_DEFENSIVE); summon->CastSpell(summon, SPELL_ASHCROMBE_TELEPORT, true); @@ -260,13 +260,16 @@ public: uiTimer = 2000; uiPhase = 2; break; + } case 2: + { pArchmage->SummonCreature(NPC_ARUGAL_VOIDWALKER, SpawnLocation[0], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000); pArchmage->SummonCreature(NPC_ARUGAL_VOIDWALKER, SpawnLocation[1], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000); pArchmage->SummonCreature(NPC_ARUGAL_VOIDWALKER, SpawnLocation[2], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000); pArchmage->SummonCreature(NPC_ARUGAL_VOIDWALKER, SpawnLocation[3], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000); uiPhase = 0; break; + } } } else uiTimer -= uiDiff; diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_zuljin.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_zuljin.cpp index 1009d3e0a0a..8fb3dd55077 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/boss_zuljin.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_zuljin.cpp @@ -315,14 +315,12 @@ class boss_zuljin : public CreatureScript { for (uint8 i = 0; i < 4; ++i) { - Unit* Temp = NULL; if (SpiritGUID[i]) { - Temp = Unit::GetUnit(*me, SpiritGUID[i]); - if (Temp) + if (Unit* temp = Unit::GetUnit(*me, SpiritGUID[i])) { - Temp->SetVisible(false); - Temp->setDeathState(DEAD); + temp->SetVisible(false); + temp->setDeathState(DEAD); } } SpiritGUID[i] = 0; diff --git a/src/server/scripts/EasternKingdoms/silverpine_forest.cpp b/src/server/scripts/EasternKingdoms/silverpine_forest.cpp index 870cb29c28d..c52e69787d4 100644 --- a/src/server/scripts/EasternKingdoms/silverpine_forest.cpp +++ b/src/server/scripts/EasternKingdoms/silverpine_forest.cpp @@ -230,13 +230,11 @@ public: { if (Creature* summoned = me->SummonCreature(creatureId, PyrewoodSpawnPoints[position][0], PyrewoodSpawnPoints[position][1], PyrewoodSpawnPoints[position][2], PyrewoodSpawnPoints[position][3], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 15000)) { - Player* player = NULL; Unit* target = NULL; if (PlayerGUID) { - player = Unit::GetPlayer(*me, PlayerGUID); - if (player) - target = RAND((Unit*)me, (Unit*)player); + if (Unit* player = Unit::GetPlayer(*me, PlayerGUID)->ToUnit()) + target = RAND((Unit*)me, player); } else target = me; diff --git a/src/server/scripts/EasternKingdoms/wetlands.cpp b/src/server/scripts/EasternKingdoms/wetlands.cpp index fac8fb51c2d..34e6e7c9ddf 100644 --- a/src/server/scripts/EasternKingdoms/wetlands.cpp +++ b/src/server/scripts/EasternKingdoms/wetlands.cpp @@ -60,12 +60,12 @@ public: { npc_tapoke_slim_jahnAI(Creature* creature) : npc_escortAI(creature) { } - bool m_bFriendSummoned; + bool IsFriendSummoned; void Reset() { if (!HasEscortState(STATE_ESCORT_ESCORTING)) - m_bFriendSummoned = false; + IsFriendSummoned = false; } void WaypointReached(uint32 waypointId) @@ -83,14 +83,12 @@ public: void EnterCombat(Unit* /*who*/) { - Player* player = GetPlayerForEscort(); - - if (HasEscortState(STATE_ESCORT_ESCORTING) && !m_bFriendSummoned && player) + if (HasEscortState(STATE_ESCORT_ESCORTING) && !IsFriendSummoned && GetPlayerForEscort()) { for (uint8 i = 0; i < 3; ++i) DoCast(me, SPELL_CALL_FRIENDS, true); - m_bFriendSummoned = true; + IsFriendSummoned = true; } } diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal.cpp index 5b6dc784113..ee7ef383603 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal.cpp @@ -222,11 +222,9 @@ public: ItemPosCountVec dest; uint8 msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, ITEM_TEAR_OF_GODDESS, 1); if (msg == EQUIP_ERR_OK) - { - Item* item = player->StoreNewItem(dest, ITEM_TEAR_OF_GODDESS, true); - if (item && player) + if (Item* item = player->StoreNewItem(dest, ITEM_TEAR_OF_GODDESS, true)) player->SendNewItem(item, 1, true, false, true); - } + player->SEND_GOSSIP_MENU(907, creature->GetGUID()); } return true; diff --git a/src/server/scripts/Kalimdor/silithus.cpp b/src/server/scripts/Kalimdor/silithus.cpp index 639de3dc3b2..bad278f51c7 100644 --- a/src/server/scripts/Kalimdor/silithus.cpp +++ b/src/server/scripts/Kalimdor/silithus.cpp @@ -537,7 +537,6 @@ public: if (!Fandral || !Arygos || !Caelestrasz || !Merithra) return; - Unit* mob = NULL; AnimationTimer = EventAnim[AnimationCount].Timer; if (eventEnd == false) { @@ -720,6 +719,7 @@ public: case 51: { uint32 entries[4] = { 15423, 15424, 15414, 15422 }; + Unit* mob = NULL; for (uint8 i = 0; i < 4; ++i) { mob = player->FindNearestCreature(entries[i], 50, me); @@ -844,9 +844,6 @@ public: void UpdateAI(const uint32 diff) { - Unit* target = NULL; - //Player* player = me->GetPlayer(PlayerGUID); - if (!Timers) { if (me->GetEntry() == 15424 || me->GetEntry() == 15422 || me->GetEntry() == 15414) //all but Kaldorei Soldiers @@ -890,6 +887,7 @@ public: } if (!hasTarget) { + Unit* target = NULL; if (me->GetEntry() == 15424 || me->GetEntry() == 15422 || me->GetEntry() == 15414) target = me->FindNearestCreature(15423, 20, true); if (me->GetEntry() == 15423) diff --git a/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp b/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp index 2ea234775c0..d335d36e112 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp @@ -314,15 +314,14 @@ class boss_gothik : public CreatureScript bool CheckGroupSplitted() { - bool checklife = false; - bool checkdead = false; - Map* map = me->GetMap(); if (map && map->IsDungeon()) { Map::PlayerList const &PlayerList = map->GetPlayers(); if (!PlayerList.isEmpty()) { + bool checklife = false; + bool checkdead = false; for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) { if (i->getSource() && i->getSource()->isAlive() && diff --git a/src/server/scripts/Outland/BlackTemple/boss_mother_shahraz.cpp b/src/server/scripts/Outland/BlackTemple/boss_mother_shahraz.cpp index 1b2fe61e87c..ec25a8f9f60 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_mother_shahraz.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_mother_shahraz.cpp @@ -248,11 +248,9 @@ public: { for (uint8 i = 0; i < 3; ++i) { - Unit* unit = NULL; if (TargetGUID[i]) { - unit = Unit::GetUnit(*me, TargetGUID[i]); - if (unit) + if (Unit* unit = Unit::GetUnit(*me, TargetGUID[i])) unit->CastSpell(unit, SPELL_ATTRACTION, true); TargetGUID[i] = 0; } diff --git a/src/server/scripts/Outland/BlackTemple/illidari_council.cpp b/src/server/scripts/Outland/BlackTemple/illidari_council.cpp index 710f5c82fab..673d4bcc96f 100644 --- a/src/server/scripts/Outland/BlackTemple/illidari_council.cpp +++ b/src/server/scripts/Outland/BlackTemple/illidari_council.cpp @@ -299,12 +299,11 @@ public: for (uint8 i = 0; i < 4; ++i) { - Unit* Member = NULL; if (Council[i]) { - Member = Unit::GetUnit(*me, Council[i]); - if (Member && Member->isAlive()) - CAST_CRE(Member)->AI()->AttackStart(target); + Unit* member = Unit::GetUnit(*me, Council[i]); + if (member && member->isAlive()) + CAST_CRE(member)->AI()->AttackStart(target); } } diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 242dc9d613b..5153010c0cc 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -1911,16 +1911,18 @@ class spell_gen_break_shield: public SpellScriptLoader Unit::AuraApplicationMap const& auras = target->GetAppliedAuras(); for (Unit::AuraApplicationMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) { - Aura* aura = itr->second->GetBase(); - SpellInfo const* auraInfo = aura->GetSpellInfo(); - if (aura && auraInfo->SpellIconID == 2007 && aura->HasEffectType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN)) + if (Aura* aura = itr->second->GetBase()) { - aura->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL); - // Remove dummys from rider (Necessary for updating visual shields) - if (Unit* rider = target->GetCharmer()) - if (Aura* defend = rider->GetAura(aura->GetId())) - defend->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL); - break; + SpellInfo const* auraInfo = aura->GetSpellInfo(); + if (auraInfo && auraInfo->SpellIconID == 2007 && aura->HasEffectType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN)) + { + aura->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL); + // Remove dummys from rider (Necessary for updating visual shields) + if (Unit* rider = target->GetCharmer()) + if (Aura* defend = rider->GetAura(aura->GetId())) + defend->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL); + break; + } } } break; @@ -2039,16 +2041,18 @@ class spell_gen_mounted_charge: public SpellScriptLoader Unit::AuraApplicationMap const& auras = target->GetAppliedAuras(); for (Unit::AuraApplicationMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) { - Aura* aura = itr->second->GetBase(); - SpellInfo const* auraInfo = aura->GetSpellInfo(); - if (aura && auraInfo->SpellIconID == 2007 && aura->HasEffectType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN)) + if (Aura* aura = itr->second->GetBase()) { - aura->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL); - // Remove dummys from rider (Necessary for updating visual shields) - if (Unit* rider = target->GetCharmer()) - if (Aura* defend = rider->GetAura(aura->GetId())) - defend->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL); - break; + SpellInfo const* auraInfo = aura->GetSpellInfo(); + if (auraInfo && auraInfo->SpellIconID == 2007 && aura->HasEffectType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN)) + { + aura->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL); + // Remove dummys from rider (Necessary for updating visual shields) + if (Unit* rider = target->GetCharmer()) + if (Aura* defend = rider->GetAura(aura->GetId())) + defend->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL); + break; + } } } break; diff --git a/src/server/scripts/Spells/spell_quest.cpp b/src/server/scripts/Spells/spell_quest.cpp index 3cb2300cadf..cbf45910495 100644 --- a/src/server/scripts/Spells/spell_quest.cpp +++ b/src/server/scripts/Spells/spell_quest.cpp @@ -1291,7 +1291,7 @@ class spell_q12372_destabilize_azure_dragonshrine_dummy : public SpellScriptLoad class spell_q12372_destabilize_azure_dragonshrine_dummy_SpellScript : public SpellScript { PrepareSpellScript(spell_q12372_destabilize_azure_dragonshrine_dummy_SpellScript); - + void HandleDummy(SpellEffIndex /*effIndex*/) { if (GetHitCreature()) diff --git a/src/server/scripts/World/achievement_scripts.cpp b/src/server/scripts/World/achievement_scripts.cpp index 60572ee3e6a..a6f4f7f64f9 100755 --- a/src/server/scripts/World/achievement_scripts.cpp +++ b/src/server/scripts/World/achievement_scripts.cpp @@ -278,6 +278,9 @@ class achievement_tilted : public AchievementCriteriaScript bool OnCheck(Player* player, Unit* /*target*/) { + if (!player) + return false; + bool checkArea = player->GetAreaId() == AREA_ARGENT_TOURNAMENT_FIELDS || player->GetAreaId() == AREA_RING_OF_ASPIRANTS || player->GetAreaId() == AREA_RING_OF_ARGENT_VALIANTS || @@ -285,7 +288,7 @@ class achievement_tilted : public AchievementCriteriaScript player->GetAreaId() == AREA_RING_OF_HORDE_VALIANTS || player->GetAreaId() == AREA_RING_OF_CHAMPIONS; - return player && checkArea && player->duel && player->duel->isMounted; + return checkArea && player->duel && player->duel->isMounted; } }; |