Skip to content

Commit f960fcc

Browse files
author
Machiavelli
committed
Merge pull request #2639 from Fredi/clean
Core/AI: Code style and cleanups
2 parents fb87b41 + 0b64d72 commit f960fcc

31 files changed

Lines changed: 430 additions & 428 deletions

src/server/game/AI/CoreAI/CombatAI.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "Vehicle.h"
2323
#include "ObjectAccessor.h"
2424

25-
int AggressorAI::Permissible(const Creature *creature)
25+
int AggressorAI::Permissible(const Creature* creature)
2626
{
2727
// have some hostile factions, it will be selected by IsHostileTo check at MoveInLineOfSight
2828
if (!creature->isCivilian() && !creature->IsNeutralToAll())
@@ -81,7 +81,7 @@ void CombatAI::JustDied(Unit* killer)
8181
me->CastSpell(killer, *i, true);
8282
}
8383

84-
void CombatAI::EnterCombat(Unit *who)
84+
void CombatAI::EnterCombat(Unit* who)
8585
{
8686
for (SpellVct::iterator i = spells.begin(); i != spells.end(); ++i)
8787
{
@@ -127,7 +127,7 @@ void CasterAI::InitializeAI()
127127
m_attackDist = MELEE_RANGE;
128128
}
129129

130-
void CasterAI::EnterCombat(Unit *who)
130+
void CasterAI::EnterCombat(Unit* who)
131131
{
132132
if (spells.empty())
133133
return;
@@ -173,7 +173,7 @@ void CasterAI::UpdateAI(const uint32 diff)
173173
//ArcherAI
174174
//////////////
175175

176-
ArcherAI::ArcherAI(Creature *c) : CreatureAI(c)
176+
ArcherAI::ArcherAI(Creature* c) : CreatureAI(c)
177177
{
178178
if (!me->m_spells[0])
179179
sLog->outError("ArcherAI set for creature (entry = %u) with spell1=0. AI will do nothing", me->GetEntry());
@@ -187,7 +187,7 @@ ArcherAI::ArcherAI(Creature *c) : CreatureAI(c)
187187
me->m_SightDistance = me->m_CombatDistance;
188188
}
189189

190-
void ArcherAI::AttackStart(Unit *who)
190+
void ArcherAI::AttackStart(Unit* who)
191191
{
192192
if (!who)
193193
return;
@@ -222,7 +222,7 @@ void ArcherAI::UpdateAI(const uint32 /*diff*/)
222222
//TurretAI
223223
//////////////
224224

225-
TurretAI::TurretAI(Creature *c) : CreatureAI(c)
225+
TurretAI::TurretAI(Creature* c) : CreatureAI(c)
226226
{
227227
if (!me->m_spells[0])
228228
sLog->outError("TurretAI set for creature (entry = %u) with spell1=0. AI will do nothing", me->GetEntry());
@@ -242,7 +242,7 @@ bool TurretAI::CanAIAttack(const Unit* /*who*/) const
242242
return true;
243243
}
244244

245-
void TurretAI::AttackStart(Unit *who)
245+
void TurretAI::AttackStart(Unit* who)
246246
{
247247
if (who)
248248
me->Attack(who, false);
@@ -260,7 +260,7 @@ void TurretAI::UpdateAI(const uint32 /*diff*/)
260260
//VehicleAI
261261
//////////////
262262

263-
VehicleAI::VehicleAI(Creature *c) : CreatureAI(c), m_vehicle(c->GetVehicleKit()), m_IsVehicleInUse(false), m_ConditionsTimer(VEHICLE_CONDITION_CHECK_TIME)
263+
VehicleAI::VehicleAI(Creature* c) : CreatureAI(c), m_vehicle(c->GetVehicleKit()), m_IsVehicleInUse(false), m_ConditionsTimer(VEHICLE_CONDITION_CHECK_TIME)
264264
{
265265
LoadConditions();
266266
m_DoDismiss = false;
@@ -318,11 +318,11 @@ void VehicleAI::CheckConditions(const uint32 diff)
318318
for (SeatMap::iterator itr = m_vehicle->Seats.begin(); itr != m_vehicle->Seats.end(); ++itr)
319319
if (Unit* passenger = ObjectAccessor::GetUnit(*m_vehicle->GetBase(), itr->second.Passenger))
320320
{
321-
if (Player* plr = passenger->ToPlayer())
321+
if (Player* player = passenger->ToPlayer())
322322
{
323-
if (!sConditionMgr->IsPlayerMeetToConditions(plr, conditions))
323+
if (!sConditionMgr->IsPlayerMeetToConditions(player, conditions))
324324
{
325-
plr->ExitVehicle();
325+
player->ExitVehicle();
326326
return;//check other pessanger in next tick
327327
}
328328
}

src/server/game/AI/CoreAI/CombatAI.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,25 @@ class Creature;
2828
class AggressorAI : public CreatureAI
2929
{
3030
public:
31-
explicit AggressorAI(Creature *c) : CreatureAI(c) {}
31+
explicit AggressorAI(Creature* c) : CreatureAI(c) {}
3232

3333
void UpdateAI(const uint32);
34-
static int Permissible(const Creature *);
34+
static int Permissible(const Creature*);
3535
};
3636

3737
typedef std::vector<uint32> SpellVct;
3838

3939
class CombatAI : public CreatureAI
4040
{
4141
public:
42-
explicit CombatAI(Creature *c) : CreatureAI(c) {}
42+
explicit CombatAI(Creature* c) : CreatureAI(c) {}
4343

4444
void InitializeAI();
4545
void Reset();
4646
void EnterCombat(Unit* who);
4747
void JustDied(Unit* killer);
4848
void UpdateAI(const uint32 diff);
49-
static int Permissible(const Creature *);
49+
static int Permissible(const Creature*);
5050
protected:
5151
EventMap events;
5252
SpellVct spells;
@@ -55,7 +55,7 @@ class CombatAI : public CreatureAI
5555
class CasterAI : public CombatAI
5656
{
5757
public:
58-
explicit CasterAI(Creature *c) : CombatAI(c) { m_attackDist = MELEE_RANGE; }
58+
explicit CasterAI(Creature* c) : CombatAI(c) { m_attackDist = MELEE_RANGE; }
5959
void InitializeAI();
6060
void AttackStart(Unit* victim) { AttackStartCaster(victim, m_attackDist); }
6161
void UpdateAI(const uint32 diff);
@@ -67,24 +67,24 @@ class CasterAI : public CombatAI
6767
struct ArcherAI : public CreatureAI
6868
{
6969
public:
70-
explicit ArcherAI(Creature *c);
71-
void AttackStart(Unit *who);
70+
explicit ArcherAI(Creature* c);
71+
void AttackStart(Unit* who);
7272
void UpdateAI(const uint32 diff);
7373

74-
static int Permissible(const Creature *);
74+
static int Permissible(const Creature*);
7575
protected:
7676
float m_minRange;
7777
};
7878

7979
struct TurretAI : public CreatureAI
8080
{
8181
public:
82-
explicit TurretAI(Creature *c);
83-
bool CanAIAttack(const Unit *who) const;
84-
void AttackStart(Unit *who);
82+
explicit TurretAI(Creature* c);
83+
bool CanAIAttack(const Unit* who) const;
84+
void AttackStart(Unit* who);
8585
void UpdateAI(const uint32 diff);
8686

87-
static int Permissible(const Creature *);
87+
static int Permissible(const Creature*);
8888
protected:
8989
float m_minRange;
9090
};
@@ -94,13 +94,13 @@ struct TurretAI : public CreatureAI
9494
struct VehicleAI : public CreatureAI
9595
{
9696
public:
97-
explicit VehicleAI(Creature *c);
97+
explicit VehicleAI(Creature* c);
9898

9999
void UpdateAI(const uint32 diff);
100-
static int Permissible(const Creature *);
100+
static int Permissible(const Creature*);
101101
void Reset();
102-
void MoveInLineOfSight(Unit *) {}
103-
void AttackStart(Unit *) {}
102+
void MoveInLineOfSight(Unit*) {}
103+
void AttackStart(Unit*) {}
104104
void OnCharmed(bool apply);
105105

106106
private:

src/server/game/AI/CoreAI/GameObjectAI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ int GameObjectAI::Permissible(const GameObject* go)
2626
return PERMIT_BASE_NO;
2727
}
2828

29-
NullGameObjectAI::NullGameObjectAI(GameObject *g) : GameObjectAI(g) {}
29+
NullGameObjectAI::NullGameObjectAI(GameObject* g) : GameObjectAI(g) {}

src/server/game/AI/CoreAI/GameObjectAI.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class GameObjectAI
3030
protected:
3131
GameObject* const go;
3232
public:
33-
explicit GameObjectAI(GameObject *g) : go(g) {}
33+
explicit GameObjectAI(GameObject* g) : go(g) {}
3434
virtual ~GameObjectAI() {}
3535

3636
virtual void UpdateAI(const uint32 /*diff*/) {}
@@ -54,7 +54,7 @@ class GameObjectAI
5454
class NullGameObjectAI : public GameObjectAI
5555
{
5656
public:
57-
explicit NullGameObjectAI(GameObject *g);
57+
explicit NullGameObjectAI(GameObject* g);
5858

5959
void UpdateAI(const uint32 /*diff*/) {}
6060

src/server/game/AI/CoreAI/GuardAI.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ bool GuardAI::CanSeeAlways(WorldObject const* obj)
4040
if (!obj->isType(TYPEMASK_UNIT))
4141
return false;
4242

43-
std::list<HostileReference *> t_list = me->getThreatManager().getThreatList();
44-
for (std::list<HostileReference *>::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
43+
std::list<HostileReference*> t_list = me->getThreatManager().getThreatList();
44+
for (std::list<HostileReference*>::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
4545
{
4646
if (Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid()))
4747
if (unit == obj)

src/server/game/AI/CoreAI/GuardAI.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ class GuardAI : public ScriptedAI
3434

3535
public:
3636

37-
explicit GuardAI(Creature *c);
37+
explicit GuardAI(Creature* c);
3838

39-
void MoveInLineOfSight(Unit *);
39+
void MoveInLineOfSight(Unit*);
4040
void EnterEvadeMode();
41-
void JustDied(Unit *);
41+
void JustDied(Unit*);
4242
bool CanSeeAlways(WorldObject const* obj);
4343

4444
void UpdateAI(const uint32);
45-
static int Permissible(const Creature *);
45+
static int Permissible(const Creature*);
4646

4747
private:
4848
uint64 i_victimGuid;

src/server/game/AI/CoreAI/PassiveAI.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
#include "Creature.h"
2121
#include "TemporarySummon.h"
2222

23-
PassiveAI::PassiveAI(Creature *c) : CreatureAI(c) { me->SetReactState(REACT_PASSIVE); }
24-
PossessedAI::PossessedAI(Creature *c) : CreatureAI(c) { me->SetReactState(REACT_PASSIVE); }
25-
NullCreatureAI::NullCreatureAI(Creature *c) : CreatureAI(c) { me->SetReactState(REACT_PASSIVE); }
23+
PassiveAI::PassiveAI(Creature* c) : CreatureAI(c) { me->SetReactState(REACT_PASSIVE); }
24+
PossessedAI::PossessedAI(Creature* c) : CreatureAI(c) { me->SetReactState(REACT_PASSIVE); }
25+
NullCreatureAI::NullCreatureAI(Creature* c) : CreatureAI(c) { me->SetReactState(REACT_PASSIVE); }
2626

2727
void PassiveAI::UpdateAI(const uint32)
2828
{
@@ -59,7 +59,7 @@ void PossessedAI::KilledUnit(Unit* victim)
5959
victim->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
6060
}
6161

62-
void CritterAI::DamageTaken(Unit* /*done_by*/, uint32 &)
62+
void CritterAI::DamageTaken(Unit* /*done_by*/, uint32&)
6363
{
6464
if (!me->HasUnitState(UNIT_STAT_FLEEING))
6565
me->SetControlled(true, UNIT_STAT_FLEEING);
@@ -72,7 +72,7 @@ void CritterAI::EnterEvadeMode()
7272
CreatureAI::EnterEvadeMode();
7373
}
7474

75-
void TriggerAI::IsSummonedBy(Unit *summoner)
75+
void TriggerAI::IsSummonedBy(Unit* summoner)
7676
{
7777
if (me->m_spells[0])
7878
me->CastSpell(me, me->m_spells[0], false, 0, 0, summoner->GetGUID());

src/server/game/AI/CoreAI/PassiveAI.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,59 +25,59 @@
2525
class PassiveAI : public CreatureAI
2626
{
2727
public:
28-
explicit PassiveAI(Creature *c);
28+
explicit PassiveAI(Creature* c);
2929

30-
void MoveInLineOfSight(Unit *) {}
31-
void AttackStart(Unit *) {}
30+
void MoveInLineOfSight(Unit*) {}
31+
void AttackStart(Unit*) {}
3232
void UpdateAI(const uint32);
3333

34-
static int Permissible(const Creature *) { return PERMIT_BASE_IDLE; }
34+
static int Permissible(const Creature*) { return PERMIT_BASE_IDLE; }
3535
};
3636

3737
class PossessedAI : public CreatureAI
3838
{
3939
public:
40-
explicit PossessedAI(Creature *c);
40+
explicit PossessedAI(Creature* c);
4141

42-
void MoveInLineOfSight(Unit *) {}
42+
void MoveInLineOfSight(Unit*) {}
4343
void AttackStart(Unit* target);
4444
void UpdateAI(const uint32);
4545
void EnterEvadeMode() {}
4646

4747
void JustDied(Unit*);
4848
void KilledUnit(Unit* victim);
4949

50-
static int Permissible(const Creature *) { return PERMIT_BASE_IDLE; }
50+
static int Permissible(const Creature*) { return PERMIT_BASE_IDLE; }
5151
};
5252

5353
class NullCreatureAI : public CreatureAI
5454
{
5555
public:
56-
explicit NullCreatureAI(Creature *c);
56+
explicit NullCreatureAI(Creature* c);
5757

58-
void MoveInLineOfSight(Unit *) {}
59-
void AttackStart(Unit *) {}
58+
void MoveInLineOfSight(Unit*) {}
59+
void AttackStart(Unit*) {}
6060
void UpdateAI(const uint32) {}
6161
void EnterEvadeMode() {}
6262
void OnCharmed(bool /*apply*/) {}
6363

64-
static int Permissible(const Creature *) { return PERMIT_BASE_IDLE; }
64+
static int Permissible(const Creature*) { return PERMIT_BASE_IDLE; }
6565
};
6666

6767
class CritterAI : public PassiveAI
6868
{
6969
public:
70-
explicit CritterAI(Creature *c) : PassiveAI(c) {}
70+
explicit CritterAI(Creature* c) : PassiveAI(c) {}
7171

72-
void DamageTaken(Unit *done_by, uint32 & /*damage*/);
72+
void DamageTaken(Unit* done_by, uint32& /*damage*/);
7373
void EnterEvadeMode();
7474
};
7575

7676
class TriggerAI : public NullCreatureAI
7777
{
7878
public:
79-
explicit TriggerAI(Creature *c) : NullCreatureAI(c) {}
80-
void IsSummonedBy(Unit *summoner);
79+
explicit TriggerAI(Creature* c) : NullCreatureAI(c) {}
80+
void IsSummonedBy(Unit* summoner);
8181
};
8282

8383
#endif

0 commit comments

Comments
 (0)