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
This commit is contained in:
Nay
2012-08-30 22:44:03 +01:00
parent 5f1977cb1d
commit abbb896cfb
16 changed files with 70 additions and 93 deletions

View File

@@ -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;

View File

@@ -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();

View File

@@ -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,

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;
}
}

View File

@@ -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;

View File

@@ -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)

View File

@@ -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() &&

View File

@@ -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;
}

View File

@@ -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);
}
}

View File

@@ -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;

View File

@@ -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())

View File

@@ -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;
}
};