* 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:
Machiavelli
2009-06-18 17:21:25 +02:00
parent 85e59ecd57
commit 3a309abfab
47 changed files with 98 additions and 93 deletions
+2 -2
View File
@@ -894,7 +894,7 @@ void ScriptsFree()
delete []SpellSummary;
// Free resources before library unload
for(int i=0;i<MAX_SCRIPTS;i++)
for(uint16 i =0;i<MAX_SCRIPTS;i++)
delete m_scripts[i];
num_sc_scripts = 0;
@@ -934,7 +934,7 @@ void ScriptsInit(char const* cfg_file = "trinitycore.conf")
bar.step();
outstring_log("");
for(int i=0;i<MAX_SCRIPTS;i++)
for(uint16 i =0;i<MAX_SCRIPTS;i++)
m_scripts[i]=NULL;
FillSpellSummary();
@@ -145,7 +145,7 @@ struct TRINITY_DLL_DECL boss_ysondreAI : public ScriptedAI
{
// summon 10 druids
Unit* target = NULL;
for(int i = 0; i < 10;i++)
for(uint8 i = 0; i < 10;i++)
{
target = SelectUnit(SELECT_TARGET_RANDOM,0);
SummonDruids(target);
@@ -162,7 +162,7 @@ struct TRINITY_DLL_DECL boss_ysondreAI : public ScriptedAI
{
// summon 10 druids
Unit* target = NULL;
for(int i = 0; i < 10;i++)
for(uint8 i = 0; i < 10;i++)
{
target = SelectUnit(SELECT_TARGET_RANDOM,0);
SummonDruids(target);
@@ -179,7 +179,7 @@ struct TRINITY_DLL_DECL boss_ysondreAI : public ScriptedAI
{
// summon 10 druids
Unit* target = NULL;
for(int i = 0; i < 10;i++)
for(uint8 i = 0; i < 10;i++)
{
target = SelectUnit(SELECT_TARGET_RANDOM,0);
SummonDruids(target);
@@ -224,14 +224,14 @@ bool EquippedOk(Player* player, uint32 spellId)
if( !spell )
return false;
for(int i=0; i<3; i++)
for(uint8 i=0; i<3; i++)
{
uint32 reqSpell = spell->EffectTriggerSpell[i];
if( !reqSpell )
continue;
Item* pItem;
for(int j = EQUIPMENT_SLOT_START; j < EQUIPMENT_SLOT_END; j++)
for(uint8 j = EQUIPMENT_SLOT_START; j < EQUIPMENT_SLOT_END; j++)
{
pItem = player->GetItemByPos( INVENTORY_SLOT_BAG_0, j );
if( pItem )
@@ -1819,7 +1819,7 @@ void boss_illidan_stormrageAI::Reset()
}
MaievGUID = 0;
for(int i = 0; i < 2; ++i)
for(uint8 i = 0; i < 2; ++i)
{
FlameGUID[i] = 0;
GlaiveGUID[i] = 0;
@@ -516,7 +516,6 @@ bool GossipSelect_npc_lokhtos_darkbargainer(Player *player, Creature *_Creature,
#define SAY_DUGHAL_FREE "Thank you, $N! I'm free!!!"
#define GOSSIP_DUGHAL "You're free, Dughal! Get out of here!"
ScriptedInstance *pInstance;
/*
struct TRINITY_DLL_DECL npc_dughal_stormwingAI : public npc_escortAI
{
@@ -688,7 +688,7 @@ struct TRINITY_DLL_DECL boss_fathomguard_caribdisAI : public ScriptedAI
Unit* selectAdvisorUnit()
{
Unit* pUnit;
Unit* pUnit = NULL;
if(pInstance)
{
switch(rand()%4)
@@ -303,7 +303,7 @@ struct TRINITY_DLL_DECL boss_leotheras_the_blindAI : public ScriptedAI
//Despawn all Inner Demon summoned
void DespawnDemon()
{
for(int i=0; i<5; i++)
for(uint8 i=0; i<5; i++)
{
if(InnderDemon[i])
{
@@ -322,7 +322,7 @@ struct TRINITY_DLL_DECL boss_leotheras_the_blindAI : public ScriptedAI
void CastConsumingMadness() //remove this once SPELL_INSIDIOUS_WHISPER is supported by core
{
for(int i=0; i<5; i++)
for(uint8 i=0; i<5; i++)
{
if(InnderDemon[i] > 0 )
{
@@ -184,7 +184,7 @@ struct TRINITY_DLL_DECL instance_serpentshrine_cavern : public ScriptedInstance
{
case DATA_STRANGE_POOL: StrangePool = data;
case DATA_CONTROL_CONSOLE:
if(data = DONE)
if(data == DONE)
{
OpenDoor(BridgePart[0], true);
OpenDoor(BridgePart[1], true);
@@ -212,7 +212,7 @@ struct TRINITY_DLL_DECL instance_serpentshrine_cavern : public ScriptedInstance
case DATA_SHIELDGENERATOR4:ShieldGeneratorDeactivated[3] = (data) ? true : false; break;
}
if(data = DONE)
if(data == DONE)
SaveToDB();
}
@@ -174,7 +174,7 @@ struct TRINITY_DLL_DECL npc_unworthy_initiateAI : public ScriptedAI
void AddEquipp()
{
int model_counter = 0;
for(int i = 0; i< 20; i++)
for(uint8 i = 0; i< 20; i++)
{
if(m_creature->GetDisplayId() == modelid_dk_unworthy[i])
{
@@ -261,7 +261,7 @@ void npc_unworthy_initiateAI::UpdateAI(const uint32 diff)
float dist = 99.0f;
uint64 nearest_prison;
for(int i = 0; i < 12; i++)
for(uint8 i = 0; i < 12; i++)
{
GameObject* temp_prison;
temp_prison = m_creature->FindNearestGameObject(acherus_soul_prison[i],30);
@@ -700,7 +700,7 @@ struct TRINITY_DLL_DECL boss_krosh_firehandAI : public ScriptedAI
//BlastWave_Timer
if(BlastWave_Timer < diff)
{
Unit *target;
Unit *target;
std::list<HostilReference *> t_list = m_creature->getThreatManager().getThreatList();
std::vector<Unit *> target_list;
for(std::list<HostilReference *>::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
@@ -71,7 +71,7 @@ struct TRINITY_DLL_DECL boss_kelidan_the_breakerAI : public ScriptedAI
{
pInstance = c->GetInstanceData();
HeroicMode = c->GetMap()->IsHeroic();
for(int i=0; i<5; ++i)
for(uint8 i=0; i<5; ++i)
Channelers[i] = 0;
}
@@ -134,7 +134,7 @@ struct TRINITY_DLL_DECL boss_kelidan_the_breakerAI : public ScriptedAI
default: DoScriptText(SAY_ADD_AGGRO_3, m_creature); break;
}
}
for(int i=0; i<5; ++i)
for(uint8 i=0; i<5; ++i)
{
Creature *channeler = Unit::GetCreature(*m_creature, Channelers[i]);
if(who && channeler && !channeler->isInCombat())
@@ -144,7 +144,7 @@ struct TRINITY_DLL_DECL boss_kelidan_the_breakerAI : public ScriptedAI
void ChannelerDied(Unit* killer)
{
for(int i=0; i<5; ++i)
for(uint8 i=0; i<5; ++i)
{
Creature *channeler = Unit::GetCreature(*m_creature, Channelers[i]);
if(channeler && channeler->isAlive())
@@ -171,7 +171,7 @@ struct TRINITY_DLL_DECL boss_kelidan_the_breakerAI : public ScriptedAI
void SummonChannelers()
{
for(int i=0; i<5; ++i)
for(uint8 i=0; i<5; ++i)
{
Creature *channeler = Unit::GetCreature(*m_creature, Channelers[i]);
if(!channeler || channeler->isDead())
@@ -256,7 +256,7 @@ struct TRINITY_DLL_DECL boss_warchief_kargath_bladefistAI : public ScriptedAI
{
Unit* target = NULL;
for(int i = 0; i < summoned; i++)
for(uint8 i = 0; i < summoned; i++)
{
switch(rand()%3)
{
@@ -62,7 +62,7 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI
{
boss_moroesAI(Creature *c) : ScriptedAI(c)
{
for(int i = 0; i < 4; i++)
for(uint8 i = 0; i < 4; i++)
{
AddId[i] = 0;
}
@@ -185,7 +185,7 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI
}
}else
{
for(int i = 0; i < 4; i++)
for(uint8 i = 0; i < 4; i++)
{
Creature *pCreature = m_creature->SummonCreature(AddId[i], Locations[i][0], Locations[i][1], POS_Z, Locations[i][2], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000);
if (pCreature)
@@ -198,7 +198,7 @@ struct TRINITY_DLL_DECL boss_moroesAI : public ScriptedAI
bool isAddlistEmpty()
{
for(int i = 0; i < 4; i++)
for(uint8 i = 0; i < 4; i++)
{
if(AddId[i] == 0)
return true;
@@ -188,10 +188,10 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI
InfernalCleanup();
positions.clear();
for(int i =0; i < 5; ++i)
for(uint8 i =0; i < 5; ++i)
enfeeble_targets[i] = 0;
for(int i = 0; i < TOTAL_INFERNAL_POINTS; ++i)
for(uint8 i = 0; i < TOTAL_INFERNAL_POINTS; ++i)
positions.push_back(&InfernalPoints[i]);
EnfeebleTimer = 30000;
@@ -232,7 +232,7 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI
InfernalCleanup();
positions.clear();
for(int i = 0; i < TOTAL_INFERNAL_POINTS; ++i)
for(uint8 i = 0; i < TOTAL_INFERNAL_POINTS; ++i)
positions.push_back(&InfernalPoints[i]);
if(pInstance)
@@ -270,7 +270,7 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI
void AxesCleanup()
{
for(int i=0; i<2;++i)
for(uint8 i=0; i<2;++i)
{
Unit *axe = Unit::GetUnit(*m_creature, axes[i]);
if(axe && axe->isAlive())
@@ -335,7 +335,7 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI
void EnfeebleResetHealth()
{
for(int i = 0; i < 5; ++i)
for(uint8 i = 0; i < 5; ++i)
{
Unit *target = Unit::GetUnit(*m_creature, enfeeble_targets[i]);
if(target && target->isAlive())
@@ -501,7 +501,7 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI
Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0);
if(target)
{
for(int i = 0; i < 2; ++i)
for(uint8 i = 0; i < 2; ++i)
{
Unit *axe = Unit::GetUnit(*m_creature, axes[i]);
if(axe)
@@ -217,7 +217,7 @@ struct TRINITY_DLL_DECL boss_ragnarosAI : public Scripted_NoMovementAI
DoScriptText(SAY_REINFORCEMENTS1, m_creature);
// summon 10 elementals
for(int i = 0; i < 9; ++i)
for(uint8 i = 0; i < 9; ++i)
{
if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM,0))
{
@@ -236,7 +236,7 @@ struct TRINITY_DLL_DECL boss_ragnarosAI : public Scripted_NoMovementAI
{
DoScriptText(SAY_REINFORCEMENTS2, m_creature);
for(int i = 0; i < 9; ++i)
for(uint8 i = 0; i < 9; ++i)
{
if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM,0))
{
@@ -59,7 +59,7 @@ struct TRINITY_DLL_DECL boss_four_horsemenAI : public BossAI
boss_four_horsemenAI(Creature *c) : BossAI(c, BOSS_HORSEMEN)
{
id = Horsemen(0);
for(uint32 i = 1; i < 4; ++i)
for(uint8 i = 1; i < 4; ++i)
if(me->GetEntry() == MOB_HORSEMEN[i])
id = Horsemen(i);
caster = (id == HORSEMEN_LADY || id == HORSEMEN_SIR);
@@ -107,9 +107,9 @@ struct TRINITY_DLL_DECL boss_four_horsemenAI : public BossAI
DoScriptText(SAY_BARON_AGGRO, me);
else
DoScriptText(SAY_AGGRO[id], me);
events.ScheduleEvent(EVENT_MARK, 15000);
events.ScheduleEvent(EVENT_CAST, 20000+rand()%5000);
events.ScheduleEvent(EVENT_BERSERK, 15*100*1000);
events.ScheduleEvent(EVENT_MARK, 15000);
events.ScheduleEvent(EVENT_CAST, 20000+rand()%5000);
events.ScheduleEvent(EVENT_BERSERK, 15*100*1000);
}
void UpdateAI(const uint32 diff)
@@ -96,15 +96,16 @@ struct TRINITY_DLL_DECL boss_anomalusAI : public ScriptedAI
if (m_creature->HasAura(SPELL_RIFT_SHIELD))
{
Unit* Rift;
if (ChaoticRiftGUID)
Rift = Unit::GetUnit((*m_creature), ChaoticRiftGUID);
if (Rift && Rift->isDead())
{
m_creature->RemoveAurasDueToSpell(SPELL_RIFT_SHIELD);
ChaoticRiftGUID = 0;
Unit* Rift = Unit::GetUnit((*m_creature), ChaoticRiftGUID);
if (Rift && Rift->isDead())
{
m_creature->RemoveAurasDueToSpell(SPELL_RIFT_SHIELD);
ChaoticRiftGUID = 0;
}
return;
}
return;
} else
ChaoticRiftGUID = 0;
@@ -85,7 +85,7 @@ struct TRINITY_DLL_DECL boss_keristraszaAI : public ScriptedAI
{
pInstance->SetData(DATA_KERISTRASZA_FREED, DONE);
}
if (pInstance->GetData(DATA_KERISTRASZA_FREED) == DONE)
if (pInstance && pInstance->GetData(DATA_KERISTRASZA_FREED) == DONE)
{
m_creature->RemoveAurasDueToSpell(SPELL_FROZEN_PRISON);
m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_ATTACKABLE_2);
@@ -44,7 +44,7 @@ struct TRINITY_DLL_DECL instance_nexus : public ScriptedInstance
void OnCreatureCreate(Creature* pCreature, bool add)
{
Map::PlayerList const& players = instance->GetPlayers();
uint32 TeamInInstance;
uint32 TeamInInstance = 0;
if (!players.isEmpty())
{
@@ -119,7 +119,7 @@ struct TRINITY_DLL_DECL boss_jandicebarovAI : public ScriptedAI
//Summon 10 Illusions attacking random gamers
Unit* target = NULL;
for(int i = 0; i < 10;i++)
for(uint8 i = 0; i < 10;i++)
{
target = SelectUnit(SELECT_TARGET_RANDOM,0);
if(target)
@@ -303,7 +303,7 @@ struct TRINITY_DLL_DECL boss_sacrolashAI : public ScriptedAI
{
Unit* target = NULL;
Creature* temp = NULL;
for(int i = 0;i<3;i++)
for(uint8 i = 0;i<3;i++)
{
target = SelectUnit(SELECT_TARGET_RANDOM, 0);
temp = DoSpawnCreature(MOB_SHADOW_IMAGE,0,0,0,0,TEMPSUMMON_CORPSE_DESPAWN,10000);
@@ -541,7 +541,6 @@ struct TRINITY_DLL_DECL boss_felmystAI : public ScriptedAI
{
if(entry == MOB_VAPOR_TRAIL && Phase == PHASE_FLIGHT)
{
float x, y, z;
(*i)->GetPosition(x, y, z);
m_creature->SummonCreature(MOB_DEAD, x, y, z, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
}
@@ -131,14 +131,14 @@ struct TRINITY_DLL_DECL boss_kalecgosAI : public ScriptedAI
{
SathGUID = pInstance->GetData64(DATA_SATHROVARR);
DoorGUID = pInstance->GetData64(DATA_GO_FORCEFIELD);
if(GameObject *Door = pInstance->instance->GetGameObject(pInstance->GetData64(DoorGUID)))
Door->SetLootState(GO_JUST_DEACTIVATED);
}
Unit *Sath = Unit::GetUnit(*m_creature,SathGUID);
if(Sath) CAST_CRE(Sath)->AI()->EnterEvadeMode();
if(GameObject *Door = pInstance->instance->GetGameObject(pInstance->GetData64(DoorGUID)))
Door->SetLootState(GO_JUST_DEACTIVATED);
m_creature->setFaction(14);
m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE + UNIT_FLAG_NOT_SELECTABLE);
m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
@@ -151,7 +151,7 @@ struct TRINITY_DLL_DECL boss_warp_splinterAI : public ScriptedAI
void SummonTreants()
{
for(int i = 0; i < 6; ++i)
for(uint8 i = 0; i < 6; ++i)
{
float angle = (M_PI / 3) * i;
@@ -275,7 +275,7 @@ struct TRINITY_DLL_DECL boss_high_astromancer_solarianAI : public ScriptedAI
//After these 50 seconds she portals to the middle of the room and disappears, leaving 3 light portals behind.
m_creature->GetMotionMaster()->Clear();
m_creature->Relocate(SolarianPos[0], SolarianPos[1], SolarianPos[2], SolarianPos[3]);
for(int i=0; i<=2; ++i)
for(uint8 i=0; i<=2; ++i)
{
if (!i)
{
@@ -710,7 +710,10 @@ struct TRINITY_DLL_DECL boss_kaelthasAI : public ScriptedAI
if (Phase_Timer < diff)
{
DoScriptText(SAY_PHASE3_ADVANCE, m_creature);
pInstance->SetData(DATA_KAELTHASEVENT, 3);
if(pInstance)
pInstance->SetData(DATA_KAELTHASEVENT, 3);
Phase = 3;
PhaseSubphase = 0;
}else Phase_Timer -= diff;
@@ -105,7 +105,7 @@ struct TRINITY_DLL_DECL boss_pathaleon_the_calculatorAI : public ScriptedAI
if(Summon_Timer < diff)
{
for(int i = 0; i < 3;i++)
for(uint8 i = 0; i < 3;i++)
{
Unit* target = NULL;
target = SelectUnit(SELECT_TARGET_RANDOM,0);
@@ -235,7 +235,7 @@ struct TRINITY_DLL_DECL boss_yaujAI : public ScriptedAI
pInstance->SetData(DATA_BUG_TRIO_DEATH, 1);
}
for(int i = 0; i < 10;i++)
for(uint8 i = 0; i < 10;i++)
{
Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0);
Creature* Summoned = m_creature->SummonCreature(15621,m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(),0,TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,90000);
@@ -348,16 +348,19 @@ struct TRINITY_DLL_DECL boss_twinemperorsAI : public ScriptedAI
for(std::list<Creature*>::iterator iter = unitList.begin(); iter != unitList.end(); ++iter)
{
Creature *c = *iter;
if (c && c->isDead())
if (c)
{
c->Respawn();
c->setFaction(7);
c->RemoveAllAuras();
}
if (c->IsWithinDistInMap(m_creature, ABUSE_BUG_RANGE))
{
if (!nearb || (rand()%4)==0)
nearb = c;
if(c->isDead())
{
c->Respawn();
c->setFaction(7);
c->RemoveAllAuras();
}
if (c->IsWithinDistInMap(m_creature, ABUSE_BUG_RANGE))
{
if (!nearb || (rand()%4) == 0)
nearb = c;
}
}
}
return nearb;
@@ -108,7 +108,7 @@ struct TRINITY_DLL_DECL npc_dragonflayer_forge_masterAI : public ScriptedAI
float diff = 30.0f;
int near_f = 0;
for(int i = 0; i < 3 ; i++)
for(uint8 i = 0; i < 3 ; i++)
{
GameObject* temp;
temp = m_creature->FindNearestGameObject(entry_search[i],30);
@@ -65,7 +65,7 @@ struct TRINITY_DLL_DECL boss_archavonAI : public ScriptedAI
void EnterCombat(Unit *who)
{
DoScriptText(rand()%2 ? SAY_AGGRO1 : SAY_AGGRO2, me);
DoScriptText((rand()%2) ? SAY_AGGRO1 : SAY_AGGRO2, me);
DoZoneInCombat();
events.ScheduleEvent(EVENT_ROCK_SHARDS, 15000);
events.ScheduleEvent(EVENT_CHOKING_CLOUD, 30000);
@@ -558,10 +558,10 @@ struct TRINITY_DLL_DECL boss_alyson_antilleAI : public boss_hexlord_addAI
{
if(rand()%2)
{
if(Unit* target = DoSelectLowestHpFriendly(50, 0))
if(target = DoSelectLowestHpFriendly(50, 0))
m_creature->CastSpell(target, SPELL_DISPEL_MAGIC, false);
}
else if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0))
else if(target = SelectUnit(SELECT_TARGET_RANDOM, 0))
m_creature->CastSpell(target, SPELL_DISPEL_MAGIC, false);
}
flashheal_timer = 2500;
@@ -72,7 +72,7 @@ struct TRINITY_DLL_DECL boss_hazzarahAI : public ScriptedAI
//We will summon 3 illusions that will spawn on a random gamer and attack this gamer
//We will just use one model for the beginning
Unit* target = NULL;
for(int i = 0; i < 3;i++)
for(uint8 i = 0; i < 3;i++)
{
target = SelectUnit(SELECT_TARGET_RANDOM,0);
if(!target)
@@ -112,7 +112,7 @@ struct TRINITY_DLL_DECL boss_venoxisAI : public ScriptedAI
if (HolyNova_Timer < diff)
{
TargetInRange = 0;
for(int i=0; i<10; i++)
for(uint8 i=0; i<10; i++)
{
if (Unit* target = SelectUnit(SELECT_TARGET_TOPAGGRO,i))
if(m_creature->IsWithinMeleeRange(target))
+1 -1
View File
@@ -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
View File
@@ -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];
}
+2 -2
View File
@@ -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;
+1 -1
View File
@@ -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>
+1 -1
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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)
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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
View File
@@ -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())
{
+2 -2
View File
@@ -235,7 +235,7 @@ void Log::InitColors(const std::string& str)
std::istringstream ss(str);
for(int i = 0; i < LogLevels; ++i)
for(uint8 i = 0; i < LogLevels; ++i)
{
ss >> color[i];
@@ -246,7 +246,7 @@ void Log::InitColors(const std::string& str)
return;
}
for(int i = 0; i < LogLevels; ++i)
for(uint8 i = 0; i < LogLevels; ++i)
m_colors[i] = ColorTypes(color[i]);
m_colored = true;