aboutsummaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authorMachiavelli <none@none>2009-06-18 17:21:25 +0200
committerMachiavelli <none@none>2009-06-18 17:21:25 +0200
commit3a309abfab3762d1c3bc2f90b961582e83d5971a (patch)
treeb04ae4230e1d2b67f78e4ce74b0ed6038c62be6d /src/game
parent85e59ecd578159a049295071f456c52e9d124de6 (diff)
* 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
Diffstat (limited to 'src/game')
-rw-r--r--src/game/ArenaTeam.cpp2
-rw-r--r--src/game/Bag.cpp2
-rw-r--r--src/game/Creature.cpp4
-rw-r--r--src/game/CreatureAIImpl.h2
-rw-r--r--src/game/GameObject.cpp2
-rw-r--r--src/game/Guild.cpp2
-rw-r--r--src/game/Item.cpp2
-rw-r--r--src/game/Level1.cpp2
-rw-r--r--src/game/Level3.cpp8
-rw-r--r--src/game/MotionMaster.h2
-rw-r--r--src/game/ObjectMgr.h2
-rw-r--r--src/game/Pet.cpp10
12 files changed, 20 insertions, 20 deletions
diff --git a/src/game/ArenaTeam.cpp b/src/game/ArenaTeam.cpp
index 3c3fc160f74..7c3c44d2bbe 100644
--- a/src/game/ArenaTeam.cpp
+++ b/src/game/ArenaTeam.cpp
@@ -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);
}
diff --git a/src/game/Bag.cpp b/src/game/Bag.cpp
index 86befec7550..223c40848b2 100644
--- a/src/game/Bag.cpp
+++ b/src/game/Bag.cpp
@@ -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];
}
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp
index 65dc188063c..56c7ce8ef75 100644
--- a/src/game/Creature.cpp
+++ b/src/game/Creature.cpp
@@ -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;
diff --git a/src/game/CreatureAIImpl.h b/src/game/CreatureAIImpl.h
index e211c50043a..f6653ce40f7 100644
--- a/src/game/CreatureAIImpl.h
+++ b/src/game/CreatureAIImpl.h
@@ -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>
diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp
index 1169cc780f4..d6aa162b50a 100644
--- a/src/game/GameObject.cpp
+++ b/src/game/GameObject.cpp
@@ -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)
{
diff --git a/src/game/Guild.cpp b/src/game/Guild.cpp
index 205277be2d0..811fc4b2b66 100644
--- a/src/game/Guild.cpp
+++ b/src/game/Guild.cpp
@@ -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();
diff --git a/src/game/Item.cpp b/src/game/Item.cpp
index bffd3c0d335..bc1c1eeeaab 100644
--- a/src/game/Item.cpp
+++ b/src/game/Item.cpp
@@ -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);
diff --git a/src/game/Level1.cpp b/src/game/Level1.cpp
index 1451e66b04a..43e7fb74660 100644
--- a/src/game/Level1.cpp
+++ b/src/game/Level1.cpp
@@ -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);
diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp
index 959e5dec7d3..6f98244a811 100644
--- a/src/game/Level3.cpp
+++ b/src/game/Level3.cpp
@@ -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)
diff --git a/src/game/MotionMaster.h b/src/game/MotionMaster.h
index be2960624cd..d23b6351955 100644
--- a/src/game/MotionMaster.h
+++ b/src/game/MotionMaster.h
@@ -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;
diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h
index 125e807da08..8bbfeaa596e 100644
--- a/src/game/ObjectMgr.h
+++ b/src/game/ObjectMgr.h
@@ -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;
diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp
index 1332a444438..6e5bb98833a 100644
--- a/src/game/Pet.cpp
+++ b/src/game/Pet.cpp
@@ -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())
{