* In case of a 'for' loop, don't declare the iterator of a type that has a larger value range when the iterator can take a maximum value of a more efficient data type. (int to uint8 in most cases).
* Other minor cleanups, Null pointer checks etc. --HG-- branch : trunk
This commit is contained in:
@@ -276,7 +276,7 @@ void ArenaTeam::DelMember(uint64 guid)
|
||||
player->SetInArenaTeam(0, GetSlot());
|
||||
player->GetSession()->SendArenaTeamCommandResult(ERR_ARENA_TEAM_QUIT_S, GetName(), "", 0);
|
||||
// delete all info regarding this team
|
||||
for(int i = 0; i < 6; ++i)
|
||||
for(uint8 i = 0; i < 6; ++i)
|
||||
{
|
||||
player->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * 6) + i, 0);
|
||||
}
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ Bag::Bag( ): Item()
|
||||
|
||||
Bag::~Bag()
|
||||
{
|
||||
for(int i = 0; i < MAX_BAG_SIZE; ++i)
|
||||
for(uint8 i = 0; i < MAX_BAG_SIZE; ++i)
|
||||
if (m_bagslot[i])
|
||||
delete m_bagslot[i];
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ m_creatureInfo(NULL), m_reactState(REACT_AGGRESSIVE), m_formation(NULL), m_summo
|
||||
m_regenTimer = 200;
|
||||
m_valuesCount = UNIT_END;
|
||||
|
||||
for(int i =0; i<CREATURE_MAX_SPELLS; ++i)
|
||||
for(uint8 i =0; i<CREATURE_MAX_SPELLS; ++i)
|
||||
m_spells[i] = 0;
|
||||
|
||||
m_CreatureSpellCooldowns.clear();
|
||||
@@ -333,7 +333,7 @@ bool Creature::InitEntry(uint32 Entry, uint32 team, const CreatureData *data )
|
||||
if(!m_respawnradius && m_defaultMovementType==RANDOM_MOTION_TYPE)
|
||||
m_defaultMovementType = IDLE_MOTION_TYPE;
|
||||
|
||||
for(int i=0; i < CREATURE_MAX_SPELLS; ++i)
|
||||
for(uint8 i=0; i < CREATURE_MAX_SPELLS; ++i)
|
||||
m_spells[i] = GetCreatureInfo()->spells[i];
|
||||
|
||||
return true;
|
||||
|
||||
@@ -27,7 +27,7 @@ template<class T>
|
||||
inline
|
||||
const T& RAND(const T& v1, const T& v2)
|
||||
{
|
||||
return rand()%2 ? v1 : v2;
|
||||
return (rand()%2) ? v1 : v2;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
|
||||
@@ -1373,7 +1373,7 @@ void GameObject::CastSpell(Unit* target, uint32 spellId)
|
||||
return;
|
||||
|
||||
bool self = false;
|
||||
for(int i = 0; i < 3; ++i)
|
||||
for(uint8 i = 0; i < 3; ++i)
|
||||
{
|
||||
if(spellInfo->EffectImplicitTargetA[i] == TARGET_UNIT_CASTER)
|
||||
{
|
||||
|
||||
+1
-1
@@ -1096,7 +1096,7 @@ void Guild::DisplayGuildBankTabsInfo(WorldSession *session)
|
||||
|
||||
data << uint8(purchased_tabs); // here is the number of tabs
|
||||
|
||||
for(int i = 0; i < purchased_tabs; ++i)
|
||||
for(uint8 i = 0; i < purchased_tabs; ++i)
|
||||
{
|
||||
data << m_TabListMap[i]->Name.c_str();
|
||||
data << m_TabListMap[i]->Icon.c_str();
|
||||
|
||||
+1
-1
@@ -266,7 +266,7 @@ bool Item::Create( uint32 guidlow, uint32 itemid, Player const* owner)
|
||||
SetUInt32Value(ITEM_FIELD_MAXDURABILITY, itemProto->MaxDurability);
|
||||
SetUInt32Value(ITEM_FIELD_DURABILITY, itemProto->MaxDurability);
|
||||
|
||||
for(int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
|
||||
for(uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
|
||||
SetSpellCharges(i,itemProto->Spells[i].SpellCharges);
|
||||
|
||||
SetUInt32Value(ITEM_FIELD_FLAGS, itemProto->Flags);
|
||||
|
||||
+1
-1
@@ -1074,7 +1074,7 @@ bool ChatHandler::HandleModifyKnownTitlesCommand(const char* args)
|
||||
|
||||
uint64 titles2 = titles;
|
||||
|
||||
for(int i = 1; i < sCharTitlesStore.GetNumRows(); ++i)
|
||||
for(uint32 i = 1; i < sCharTitlesStore.GetNumRows(); ++i)
|
||||
if(CharTitlesEntry const* tEntry = sCharTitlesStore.LookupEntry(i))
|
||||
titles2 &= ~(uint64(1) << tEntry->bit_index);
|
||||
|
||||
|
||||
+4
-4
@@ -2421,7 +2421,7 @@ bool ChatHandler::HandleLearnAllMyTalentsCommand(const char* /*args*/)
|
||||
// search highest talent rank
|
||||
uint32 spellid = 0;
|
||||
|
||||
for(int rank = MAX_TALENT_RANK-1; rank >= 0; --rank)
|
||||
for(uint8 rank = MAX_TALENT_RANK-1; rank >= 0; --rank)
|
||||
{
|
||||
if(talentInfo->RankID[rank]!=0)
|
||||
{
|
||||
@@ -2497,7 +2497,7 @@ bool ChatHandler::HandleLearnAllMyPetTalentsCommand(const char* /*args*/)
|
||||
// search highest talent rank
|
||||
uint32 spellid = 0;
|
||||
|
||||
for(int rank = MAX_TALENT_RANK-1; rank >= 0; --rank)
|
||||
for(uint8 rank = MAX_TALENT_RANK-1; rank >= 0; --rank)
|
||||
{
|
||||
if(talentInfo->RankID[rank]!=0)
|
||||
{
|
||||
@@ -2524,7 +2524,7 @@ bool ChatHandler::HandleLearnAllMyPetTalentsCommand(const char* /*args*/)
|
||||
bool ChatHandler::HandleLearnAllLangCommand(const char* /*args*/)
|
||||
{
|
||||
// skipping UNIVERSAL language (0)
|
||||
for(int i = 1; i < LANGUAGES_COUNT; ++i)
|
||||
for(uint8 i = 1; i < LANGUAGES_COUNT; ++i)
|
||||
m_session->GetPlayer()->learnSpell(lang_description[i].spell_id,false);
|
||||
|
||||
SendSysMessage(LANG_COMMAND_LEARN_ALL_LANG);
|
||||
@@ -6391,7 +6391,7 @@ bool ChatHandler::HandleMovegensCommand(const char* /*args*/)
|
||||
PSendSysMessage(LANG_MOVEGENS_LIST,(unit->GetTypeId()==TYPEID_PLAYER ? "Player" : "Creature" ),unit->GetGUIDLow());
|
||||
|
||||
MotionMaster* mm = unit->GetMotionMaster();
|
||||
for(int i = 0; i < MAX_MOTION_SLOT; ++i)
|
||||
for(uint8 i = 0; i < MAX_MOTION_SLOT; ++i)
|
||||
{
|
||||
MovementGenerator* mg = mm->GetMotionSlot(i);
|
||||
if(!mg)
|
||||
|
||||
@@ -89,7 +89,7 @@ class TRINITY_DLL_SPEC MotionMaster //: private std::stack<MovementGenerator *>
|
||||
|
||||
explicit MotionMaster(Unit *unit) : i_owner(unit), m_expList(NULL), m_cleanFlag(MMCF_NONE), i_top(-1)
|
||||
{
|
||||
for(int i = 0; i < MAX_MOTION_SLOT; ++i)
|
||||
for(uint8 i = 0; i < MAX_MOTION_SLOT; ++i)
|
||||
{
|
||||
Impl[i] = NULL;
|
||||
needInit[i] = true;
|
||||
|
||||
@@ -170,7 +170,7 @@ typedef std::pair<ItemRequiredTargetMap::const_iterator, ItemRequiredTargetMap::
|
||||
|
||||
struct PetLevelInfo
|
||||
{
|
||||
PetLevelInfo() : health(0), mana(0) { for(int i=0; i < MAX_STATS; ++i ) stats[i] = 0; }
|
||||
PetLevelInfo() : health(0), mana(0) { for(uint8 i=0; i < MAX_STATS; ++i ) stats[i] = 0; }
|
||||
|
||||
uint16 stats[MAX_STATS];
|
||||
uint16 health;
|
||||
|
||||
+5
-5
@@ -332,7 +332,7 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool
|
||||
|
||||
m_declinedname = new DeclinedName;
|
||||
Field *fields2 = result->Fetch();
|
||||
for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
|
||||
for(uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
|
||||
{
|
||||
m_declinedname->name[i] = fields2[i].GetCppString();
|
||||
}
|
||||
@@ -856,7 +856,7 @@ bool Guardian::InitStatsForLevel(uint32 petlevel)
|
||||
if(pInfo->armor > 0)
|
||||
SetModifierValue(UNIT_MOD_ARMOR, BASE_VALUE, float(pInfo->armor));
|
||||
|
||||
for(int stat = 0; stat < MAX_STATS; ++stat)
|
||||
for(uint8 stat = 0; stat < MAX_STATS; ++stat)
|
||||
SetCreateStat(Stats(stat), float(pInfo->stats[stat]));
|
||||
}
|
||||
else // not exist in DB, use some default fake data
|
||||
@@ -1275,7 +1275,7 @@ bool Pet::addSpell(uint32 spell_id,ActiveStates active /*= ACT_DECIDE*/, PetSpel
|
||||
{
|
||||
if(TalentEntry const *talentInfo = sTalentStore.LookupEntry( talentPos->talent_id ))
|
||||
{
|
||||
for(int i=0; i < MAX_TALENT_RANK; ++i)
|
||||
for(uint8 i=0; i < MAX_TALENT_RANK; ++i)
|
||||
{
|
||||
// skip learning spell and no rank spell case
|
||||
uint32 rankSpellId = talentInfo->RankID[i];
|
||||
@@ -1377,7 +1377,7 @@ void Pet::InitLevelupSpellsForLevel()
|
||||
// default spells (can be not learned if pet level (as owner level decrease result for example) less first possible in normal game)
|
||||
if(PetDefaultSpellsEntry const *defSpells = spellmgr.GetPetDefaultSpellsEntry(petSpellsId))
|
||||
{
|
||||
for(int i = 0; i < MAX_CREATURE_SPELL_DATA_SLOT; ++i)
|
||||
for(uint8 i = 0; i < MAX_CREATURE_SPELL_DATA_SLOT; ++i)
|
||||
{
|
||||
SpellEntry const* spellEntry = sSpellStore.LookupEntry(defSpells->spellid[i]);
|
||||
if(!spellEntry)
|
||||
@@ -1462,7 +1462,7 @@ bool Pet::removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab)
|
||||
|
||||
void Pet::CleanupActionBar()
|
||||
{
|
||||
for(int i = 0; i < MAX_UNIT_ACTION_BAR_INDEX; ++i)
|
||||
for(uint8 i = 0; i < MAX_UNIT_ACTION_BAR_INDEX; ++i)
|
||||
if(UnitActionBarEntry const* ab = m_charmInfo->GetActionBarEntry(i))
|
||||
if(ab->SpellOrAction && ab->IsActionBarForSpell())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user