refactor(Core/Game): restyle game lib with astyle (#3466)

This commit is contained in:
Kargatum
2020-10-12 15:08:15 +07:00
committed by GitHub
parent e99b526e17
commit a2b26272d2
338 changed files with 52196 additions and 50944 deletions

View File

@@ -1,6 +1,6 @@
/*
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-GPL2
*
*
*
* This program is free software licensed under GPL version 2
* Please see the included DOCS/LICENSE.TXT for more information */
@@ -211,7 +211,7 @@ void ScriptedAI::DoPlayMusic(uint32 soundId, bool zone)
if (me && me->FindMap())
{
Map::PlayerList const &players = me->GetMap()->GetPlayers();
Map::PlayerList const& players = me->GetMap()->GetPlayers();
targets = new ObjectList();
if (!players.isEmpty())
@@ -278,11 +278,11 @@ SpellInfo const* ScriptedAI::SelectSpell(Unit* target, uint32 school, uint32 mec
// Targets and Effects checked first as most used restrictions
//Check the spell targets if specified
if (targets && !(SpellSummary[me->m_spells[i]].Targets & (1 << (targets-1))))
if (targets && !(SpellSummary[me->m_spells[i]].Targets & (1 << (targets - 1))))
continue;
//Check the type of spell if we are looking for a specific spell type
if (effects && !(SpellSummary[me->m_spells[i]].Effects & (1 << (effects-1))))
if (effects && !(SpellSummary[me->m_spells[i]].Effects & (1 << (effects - 1))))
continue;
//Check for school if specified
@@ -482,7 +482,7 @@ Player* ScriptedAI::SelectTargetFromPlayerList(float maxdist, uint32 excludeAura
tList.push_back(itr->GetSource());
}
if (!tList.empty())
return tList[urand(0,tList.size()-1)];
return tList[urand(0, tList.size() - 1)];
else
return nullptr;
}

View File

@@ -80,7 +80,7 @@ public:
void DespawnAll();
template <typename T>
void DespawnIf(T const &predicate)
void DespawnIf(T const& predicate)
{
storage_.remove_if(predicate);
}
@@ -135,25 +135,25 @@ private:
class EntryCheckPredicate
{
public:
EntryCheckPredicate(uint32 entry) : _entry(entry) {}
bool operator()(uint64 guid) { return GUID_ENPART(guid) == _entry; }
public:
EntryCheckPredicate(uint32 entry) : _entry(entry) {}
bool operator()(uint64 guid) { return GUID_ENPART(guid) == _entry; }
private:
uint32 _entry;
private:
uint32 _entry;
};
class PlayerOrPetCheck
{
public:
bool operator() (WorldObject* unit) const
{
if (unit->GetTypeId() != TYPEID_PLAYER)
if (!IS_PLAYER_GUID(unit->ToUnit()->GetOwnerGUID()))
return true;
public:
bool operator() (WorldObject* unit) const
{
if (unit->GetTypeId() != TYPEID_PLAYER)
if (!IS_PLAYER_GUID(unit->ToUnit()->GetOwnerGUID()))
return true;
return false;
}
return false;
}
};
struct ScriptedAI : public CreatureAI
@@ -353,92 +353,92 @@ struct ScriptedAI : public CreatureAI
Player* SelectTargetFromPlayerList(float maxdist, uint32 excludeAura = 0, bool mustBeInLOS = false) const;
private:
Difficulty _difficulty;
uint32 _evadeCheckCooldown;
bool _isCombatMovementAllowed;
bool _isHeroic;
private:
Difficulty _difficulty;
uint32 _evadeCheckCooldown;
bool _isCombatMovementAllowed;
bool _isHeroic;
};
class BossAI : public ScriptedAI
{
public:
BossAI(Creature* creature, uint32 bossId);
virtual ~BossAI() {}
public:
BossAI(Creature* creature, uint32 bossId);
virtual ~BossAI() {}
InstanceScript* const instance;
BossBoundaryMap const* GetBoundary() const { return _boundary; }
InstanceScript* const instance;
BossBoundaryMap const* GetBoundary() const { return _boundary; }
void JustSummoned(Creature* summon);
void SummonedCreatureDespawn(Creature* summon);
void JustSummoned(Creature* summon);
void SummonedCreatureDespawn(Creature* summon);
virtual void UpdateAI(uint32 diff);
virtual void UpdateAI(uint32 diff);
// Hook used to execute events scheduled into EventMap without the need
// to override UpdateAI
// note: You must re-schedule the event within this method if the event
// is supposed to run more than once
virtual void ExecuteEvent(uint32 /*eventId*/) { }
// Hook used to execute events scheduled into EventMap without the need
// to override UpdateAI
// note: You must re-schedule the event within this method if the event
// is supposed to run more than once
virtual void ExecuteEvent(uint32 /*eventId*/) { }
void Reset() { _Reset(); }
void EnterCombat(Unit* /*who*/) { _EnterCombat(); }
void JustDied(Unit* /*killer*/) { _JustDied(); }
void JustReachedHome() { _JustReachedHome(); }
void Reset() { _Reset(); }
void EnterCombat(Unit* /*who*/) { _EnterCombat(); }
void JustDied(Unit* /*killer*/) { _JustDied(); }
void JustReachedHome() { _JustReachedHome(); }
protected:
void _Reset();
void _EnterCombat();
void _JustDied();
void _JustReachedHome() { me->setActive(false); }
protected:
void _Reset();
void _EnterCombat();
void _JustDied();
void _JustReachedHome() { me->setActive(false); }
bool CheckInRoom()
{
if (CheckBoundary(me))
return true;
bool CheckInRoom()
{
if (CheckBoundary(me))
return true;
EnterEvadeMode();
return false;
}
EnterEvadeMode();
return false;
}
bool CheckBoundary(Unit* who);
void TeleportCheaters();
bool CheckBoundary(Unit* who);
void TeleportCheaters();
EventMap events;
SummonList summons;
EventMap events;
SummonList summons;
private:
BossBoundaryMap const* const _boundary;
uint32 const _bossId;
private:
BossBoundaryMap const* const _boundary;
uint32 const _bossId;
};
class WorldBossAI : public ScriptedAI
{
public:
WorldBossAI(Creature* creature);
virtual ~WorldBossAI() {}
public:
WorldBossAI(Creature* creature);
virtual ~WorldBossAI() {}
void JustSummoned(Creature* summon);
void SummonedCreatureDespawn(Creature* summon);
void JustSummoned(Creature* summon);
void SummonedCreatureDespawn(Creature* summon);
virtual void UpdateAI(uint32 diff);
virtual void UpdateAI(uint32 diff);
// Hook used to execute events scheduled into EventMap without the need
// to override UpdateAI
// note: You must re-schedule the event within this method if the event
// is supposed to run more than once
virtual void ExecuteEvent(uint32 /*eventId*/) { }
// Hook used to execute events scheduled into EventMap without the need
// to override UpdateAI
// note: You must re-schedule the event within this method if the event
// is supposed to run more than once
virtual void ExecuteEvent(uint32 /*eventId*/) { }
void Reset() { _Reset(); }
void EnterCombat(Unit* /*who*/) { _EnterCombat(); }
void JustDied(Unit* /*killer*/) { _JustDied(); }
void Reset() { _Reset(); }
void EnterCombat(Unit* /*who*/) { _EnterCombat(); }
void JustDied(Unit* /*killer*/) { _JustDied(); }
protected:
void _Reset();
void _EnterCombat();
void _JustDied();
protected:
void _Reset();
void _EnterCombat();
void _JustDied();
EventMap events;
SummonList summons;
EventMap events;
SummonList summons;
};
// SD2 grid searchers.

View File

@@ -131,7 +131,7 @@ void npc_escortAI::JustDied(Unit* /*killer*/)
void npc_escortAI::JustRespawned()
{
RemoveEscortState(STATE_ESCORT_ESCORTING|STATE_ESCORT_RETURNING|STATE_ESCORT_PAUSED);
RemoveEscortState(STATE_ESCORT_ESCORTING | STATE_ESCORT_RETURNING | STATE_ESCORT_PAUSED);
if (!IsCombatMovementAllowed())
SetCombatMovement(true);
@@ -432,7 +432,7 @@ void npc_escortAI::Start(bool isActiveAttacker /* = true*/, bool run /* = false
if (WaypointList.empty())
{
sLog->outErrorDb("TSCR: EscortAI (script: %s, creature entry: %u) starts with 0 waypoints (possible missing entry in script_waypoint. Quest: %u).",
me->GetScriptName().c_str(), me->GetEntry(), quest ? quest->GetQuestId() : 0);
me->GetScriptName().c_str(), me->GetEntry(), quest ? quest->GetQuestId() : 0);
return;
}
@@ -556,7 +556,7 @@ void npc_escortAI::GenerateWaypointArray(Movement::PointsArray* points)
uint32 startingWaypointId = CurrentWP->id;
// Flying unit, just fill array
if (me->m_movementInfo.HasMovementFlag((MovementFlags)(MOVEMENTFLAG_CAN_FLY|MOVEMENTFLAG_DISABLE_GRAVITY)))
if (me->m_movementInfo.HasMovementFlag((MovementFlags)(MOVEMENTFLAG_CAN_FLY | MOVEMENTFLAG_DISABLE_GRAVITY)))
{
// xinef: first point in vector is unit real position
points->clear();
@@ -571,7 +571,7 @@ void npc_escortAI::GenerateWaypointArray(Movement::PointsArray* points)
std::vector<G3D::Vector3> pVector;
// xinef: first point in vector is unit real position
pVector.push_back(G3D::Vector3(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ()));
uint32 length = (WaypointList.size() - startingWaypointId)*size;
uint32 length = (WaypointList.size() - startingWaypointId) * size;
uint32 cnt = 0;
for (std::list<Escort_Waypoint>::const_iterator itr = CurrentWP; itr != WaypointList.end() && cnt <= length; ++itr, ++cnt)
@@ -579,11 +579,11 @@ void npc_escortAI::GenerateWaypointArray(Movement::PointsArray* points)
if (pVector.size() > 2) // more than source + dest
{
G3D::Vector3 middle = (pVector[0] + pVector[pVector.size()-1]) / 2.f;
G3D::Vector3 middle = (pVector[0] + pVector[pVector.size() - 1]) / 2.f;
G3D::Vector3 offset;
bool continueLoop = false;
for (uint32 i = 1; i < pVector.size()-1; ++i)
for (uint32 i = 1; i < pVector.size() - 1; ++i)
{
offset = middle - pVector[i];
if (fabs(offset.x) >= 0xFF || fabs(offset.y) >= 0xFF || fabs(offset.z) >= 0x7F)
@@ -599,6 +599,6 @@ void npc_escortAI::GenerateWaypointArray(Movement::PointsArray* points)
// everything ok
*points = pVector;
break;
}
}
}
}

View File

@@ -38,92 +38,92 @@ enum eEscortState
struct npc_escortAI : public ScriptedAI
{
public:
explicit npc_escortAI(Creature* creature);
~npc_escortAI() {}
public:
explicit npc_escortAI(Creature* creature);
~npc_escortAI() {}
// CreatureAI functions
void AttackStart(Unit* who);
// CreatureAI functions
void AttackStart(Unit* who);
void MoveInLineOfSight(Unit* who);
void MoveInLineOfSight(Unit* who);
void JustDied(Unit*);
void JustDied(Unit*);
void JustRespawned();
void JustRespawned();
void ReturnToLastPoint();
void ReturnToLastPoint();
void EnterEvadeMode();
void EnterEvadeMode();
void UpdateAI(uint32 diff); //the "internal" update, calls UpdateEscortAI()
virtual void UpdateEscortAI(uint32 diff); //used when it's needed to add code in update (abilities, scripted events, etc)
void UpdateAI(uint32 diff); //the "internal" update, calls UpdateEscortAI()
virtual void UpdateEscortAI(uint32 diff); //used when it's needed to add code in update (abilities, scripted events, etc)
void MovementInform(uint32, uint32);
void MovementInform(uint32, uint32);
// EscortAI functions
void AddWaypoint(uint32 id, float x, float y, float z, uint32 waitTime = 0); // waitTime is in ms
// EscortAI functions
void AddWaypoint(uint32 id, float x, float y, float z, uint32 waitTime = 0); // waitTime is in ms
//this will set the current position to x/y/z/o, and the current WP to pointId.
bool SetNextWaypoint(uint32 pointId, float x, float y, float z, float orientation);
//this will set the current position to x/y/z/o, and the current WP to pointId.
bool SetNextWaypoint(uint32 pointId, float x, float y, float z, float orientation);
//this will set the current position to WP start position (if setPosition == true),
//and the current WP to pointId
bool SetNextWaypoint(uint32 pointId, bool setPosition = true);
//this will set the current position to WP start position (if setPosition == true),
//and the current WP to pointId
bool SetNextWaypoint(uint32 pointId, bool setPosition = true);
bool GetWaypointPosition(uint32 pointId, float& x, float& y, float& z);
bool GetWaypointPosition(uint32 pointId, float& x, float& y, float& z);
void GenerateWaypointArray(Movement::PointsArray* points);
void GenerateWaypointArray(Movement::PointsArray* points);
virtual void WaypointReached(uint32 pointId) = 0;
virtual void WaypointStart(uint32 /*pointId*/) {}
virtual void WaypointReached(uint32 pointId) = 0;
virtual void WaypointStart(uint32 /*pointId*/) {}
void Start(bool isActiveAttacker = true, bool run = false, uint64 playerGUID = 0, Quest const* quest = NULL, bool instantRespawn = false, bool canLoopPath = false, bool resetWaypoints = true);
void Start(bool isActiveAttacker = true, bool run = false, uint64 playerGUID = 0, Quest const* quest = NULL, bool instantRespawn = false, bool canLoopPath = false, bool resetWaypoints = true);
void SetRun(bool on = true);
void SetEscortPaused(bool on);
void SetRun(bool on = true);
void SetEscortPaused(bool on);
bool HasEscortState(uint32 escortState) { return (m_uiEscortState & escortState); }
virtual bool IsEscorted() { return (m_uiEscortState & STATE_ESCORT_ESCORTING); }
bool HasEscortState(uint32 escortState) { return (m_uiEscortState & escortState); }
virtual bool IsEscorted() { return (m_uiEscortState & STATE_ESCORT_ESCORTING); }
void SetMaxPlayerDistance(float newMax) { MaxPlayerDistance = newMax; }
float GetMaxPlayerDistance() { return MaxPlayerDistance; }
void SetMaxPlayerDistance(float newMax) { MaxPlayerDistance = newMax; }
float GetMaxPlayerDistance() { return MaxPlayerDistance; }
void SetDespawnAtEnd(bool despawn) { DespawnAtEnd = despawn; }
void SetDespawnAtFar(bool despawn) { DespawnAtFar = despawn; }
bool GetAttack() { return m_bIsActiveAttacker; }//used in EnterEvadeMode override
void SetCanAttack(bool attack) { m_bIsActiveAttacker = attack; }
uint64 GetEventStarterGUID() { return m_uiPlayerGUID; }
void SetDespawnAtEnd(bool despawn) { DespawnAtEnd = despawn; }
void SetDespawnAtFar(bool despawn) { DespawnAtFar = despawn; }
bool GetAttack() { return m_bIsActiveAttacker; }//used in EnterEvadeMode override
void SetCanAttack(bool attack) { m_bIsActiveAttacker = attack; }
uint64 GetEventStarterGUID() { return m_uiPlayerGUID; }
void AddEscortState(uint32 escortState) { m_uiEscortState |= escortState; }
void RemoveEscortState(uint32 escortState) { m_uiEscortState &= ~escortState; }
void AddEscortState(uint32 escortState) { m_uiEscortState |= escortState; }
void RemoveEscortState(uint32 escortState) { m_uiEscortState &= ~escortState; }
protected:
Player* GetPlayerForEscort() { return ObjectAccessor::GetPlayer(*me, m_uiPlayerGUID); }
protected:
Player* GetPlayerForEscort() { return ObjectAccessor::GetPlayer(*me, m_uiPlayerGUID); }
private:
bool AssistPlayerInCombat(Unit* who);
bool IsPlayerOrGroupInRange();
void FillPointMovementListForCreature();
private:
bool AssistPlayerInCombat(Unit* who);
bool IsPlayerOrGroupInRange();
void FillPointMovementListForCreature();
uint64 m_uiPlayerGUID;
uint32 m_uiWPWaitTimer;
uint32 m_uiPlayerCheckTimer;
uint32 m_uiEscortState;
float MaxPlayerDistance;
uint64 m_uiPlayerGUID;
uint32 m_uiWPWaitTimer;
uint32 m_uiPlayerCheckTimer;
uint32 m_uiEscortState;
float MaxPlayerDistance;
Quest const* m_pQuestForEscort; //generally passed in Start() when regular escort script.
Quest const* m_pQuestForEscort; //generally passed in Start() when regular escort script.
std::list<Escort_Waypoint> WaypointList;
std::list<Escort_Waypoint>::iterator CurrentWP;
std::list<Escort_Waypoint> WaypointList;
std::list<Escort_Waypoint>::iterator CurrentWP;
bool m_bIsActiveAttacker; //obsolete, determined by faction.
bool m_bIsRunning; //all creatures are walking by default (has flag MOVEMENTFLAG_WALK)
bool m_bCanInstantRespawn; //if creature should respawn instantly after escort over (if not, database respawntime are used)
bool m_bCanReturnToStart; //if creature can walk same path (loop) without despawn. Not for regular escort quests.
bool DespawnAtEnd;
bool DespawnAtFar;
bool ScriptWP;
bool HasImmuneToNPCFlags;
bool m_bIsActiveAttacker; //obsolete, determined by faction.
bool m_bIsRunning; //all creatures are walking by default (has flag MOVEMENTFLAG_WALK)
bool m_bCanInstantRespawn; //if creature should respawn instantly after escort over (if not, database respawntime are used)
bool m_bCanReturnToStart; //if creature can walk same path (loop) without despawn. Not for regular escort quests.
bool DespawnAtEnd;
bool DespawnAtFar;
bool ScriptWP;
bool HasImmuneToNPCFlags;
};
#endif

View File

@@ -21,48 +21,48 @@ enum eFollowState
class FollowerAI : public ScriptedAI
{
public:
explicit FollowerAI(Creature* creature);
~FollowerAI() {}
public:
explicit FollowerAI(Creature* creature);
~FollowerAI() {}
//virtual void WaypointReached(uint32 uiPointId) = 0;
//virtual void WaypointReached(uint32 uiPointId) = 0;
void MovementInform(uint32 motionType, uint32 pointId);
void MovementInform(uint32 motionType, uint32 pointId);
void AttackStart(Unit*);
void AttackStart(Unit*);
void MoveInLineOfSight(Unit*);
void MoveInLineOfSight(Unit*);
void EnterEvadeMode();
void EnterEvadeMode();
void JustDied(Unit*);
void JustDied(Unit*);
void JustRespawned();
void JustRespawned();
void UpdateAI(uint32); //the "internal" update, calls UpdateFollowerAI()
virtual void UpdateFollowerAI(uint32); //used when it's needed to add code in update (abilities, scripted events, etc)
void UpdateAI(uint32); //the "internal" update, calls UpdateFollowerAI()
virtual void UpdateFollowerAI(uint32); //used when it's needed to add code in update (abilities, scripted events, etc)
void StartFollow(Player* player, uint32 factionForFollower = 0, const Quest* quest = nullptr);
void StartFollow(Player* player, uint32 factionForFollower = 0, const Quest* quest = nullptr);
void SetFollowPaused(bool bPaused); //if special event require follow mode to hold/resume during the follow
void SetFollowComplete(bool bWithEndEvent = false);
void SetFollowPaused(bool bPaused); //if special event require follow mode to hold/resume during the follow
void SetFollowComplete(bool bWithEndEvent = false);
bool HasFollowState(uint32 uiFollowState) { return (m_uiFollowState & uiFollowState); }
bool HasFollowState(uint32 uiFollowState) { return (m_uiFollowState & uiFollowState); }
protected:
Player* GetLeaderForFollower();
protected:
Player* GetLeaderForFollower();
private:
void AddFollowState(uint32 uiFollowState) { m_uiFollowState |= uiFollowState; }
void RemoveFollowState(uint32 uiFollowState) { m_uiFollowState &= ~uiFollowState; }
private:
void AddFollowState(uint32 uiFollowState) { m_uiFollowState |= uiFollowState; }
void RemoveFollowState(uint32 uiFollowState) { m_uiFollowState &= ~uiFollowState; }
bool AssistPlayerInCombat(Unit* who);
bool AssistPlayerInCombat(Unit* who);
uint64 m_uiLeaderGUID;
uint32 m_uiUpdateFollowTimer;
uint32 m_uiFollowState;
uint64 m_uiLeaderGUID;
uint32 m_uiUpdateFollowTimer;
uint32 m_uiFollowState;
const Quest* m_pQuestForFollow; //normally we have a quest
const Quest* m_pQuestForFollow; //normally we have a quest
};
#endif