mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-25 14:46:24 +00:00
refactor(Core/Game): restyle game lib with astyle (#3466)
This commit is contained in:
@@ -34,7 +34,7 @@ enum MovementGeneratorType
|
||||
POINT_MOTION_TYPE = 8, // PointMovementGenerator.h
|
||||
FLEEING_MOTION_TYPE = 9, // FleeingMovementGenerator.h
|
||||
DISTRACT_MOTION_TYPE = 10, // IdleMovementGenerator.h
|
||||
ASSISTANCE_MOTION_TYPE= 11, // PointMovementGenerator.h (first part of flee for assistance)
|
||||
ASSISTANCE_MOTION_TYPE = 11, // PointMovementGenerator.h (first part of flee for assistance)
|
||||
ASSISTANCE_DISTRACT_MOTION_TYPE = 12, // IdleMovementGenerator.h (second part of flee for assistance)
|
||||
TIMED_FLEEING_MOTION_TYPE = 13, // FleeingMovementGenerator.h (alt.second part of flee for assistance)
|
||||
FOLLOW_MOTION_TYPE = 14,
|
||||
@@ -71,152 +71,152 @@ enum RotateDirection
|
||||
|
||||
class MotionMaster //: private std::stack<MovementGenerator *>
|
||||
{
|
||||
private:
|
||||
//typedef std::stack<MovementGenerator *> Impl;
|
||||
typedef MovementGenerator* _Ty;
|
||||
private:
|
||||
//typedef std::stack<MovementGenerator *> Impl;
|
||||
typedef MovementGenerator* _Ty;
|
||||
|
||||
void pop()
|
||||
void pop()
|
||||
{
|
||||
if (empty())
|
||||
return;
|
||||
|
||||
Impl[_top] = nullptr;
|
||||
while (!empty() && !top())
|
||||
--_top;
|
||||
}
|
||||
|
||||
bool needInitTop() const
|
||||
{
|
||||
if (empty())
|
||||
return false;
|
||||
return _needInit[_top];
|
||||
}
|
||||
void InitTop();
|
||||
public:
|
||||
|
||||
explicit MotionMaster(Unit* unit) : _expList(nullptr), _top(-1), _owner(unit), _cleanFlag(MMCF_NONE)
|
||||
{
|
||||
for (uint8 i = 0; i < MAX_MOTION_SLOT; ++i)
|
||||
{
|
||||
if (empty())
|
||||
return;
|
||||
|
||||
Impl[_top] = nullptr;
|
||||
while (!empty() && !top())
|
||||
--_top;
|
||||
Impl[i] = nullptr;
|
||||
_needInit[i] = true;
|
||||
}
|
||||
}
|
||||
~MotionMaster();
|
||||
|
||||
bool needInitTop() const
|
||||
{
|
||||
if (empty())
|
||||
return false;
|
||||
return _needInit[_top];
|
||||
}
|
||||
void InitTop();
|
||||
public:
|
||||
void Initialize();
|
||||
void InitDefault();
|
||||
|
||||
explicit MotionMaster(Unit* unit) : _expList(nullptr), _top(-1), _owner(unit), _cleanFlag(MMCF_NONE)
|
||||
bool empty() const { return (_top < 0); }
|
||||
int size() const { return _top + 1; }
|
||||
_Ty top() const
|
||||
{
|
||||
ASSERT(!empty());
|
||||
return Impl[_top];
|
||||
}
|
||||
_Ty GetMotionSlot(int slot) const
|
||||
{
|
||||
ASSERT(slot >= 0);
|
||||
return Impl[slot];
|
||||
}
|
||||
|
||||
uint8 GetCleanFlags() const { return _cleanFlag; }
|
||||
|
||||
void DirectDelete(_Ty curr);
|
||||
void DelayedDelete(_Ty curr);
|
||||
|
||||
void UpdateMotion(uint32 diff);
|
||||
void Clear(bool reset = true)
|
||||
{
|
||||
if (_cleanFlag & MMCF_UPDATE)
|
||||
{
|
||||
for (uint8 i = 0; i < MAX_MOTION_SLOT; ++i)
|
||||
{
|
||||
Impl[i] = nullptr;
|
||||
_needInit[i] = true;
|
||||
}
|
||||
}
|
||||
~MotionMaster();
|
||||
|
||||
void Initialize();
|
||||
void InitDefault();
|
||||
|
||||
bool empty() const { return (_top < 0); }
|
||||
int size() const { return _top + 1; }
|
||||
_Ty top() const
|
||||
{
|
||||
ASSERT(!empty());
|
||||
return Impl[_top];
|
||||
}
|
||||
_Ty GetMotionSlot(int slot) const
|
||||
{
|
||||
ASSERT(slot >= 0);
|
||||
return Impl[slot];
|
||||
}
|
||||
|
||||
uint8 GetCleanFlags() const { return _cleanFlag; }
|
||||
|
||||
void DirectDelete(_Ty curr);
|
||||
void DelayedDelete(_Ty curr);
|
||||
|
||||
void UpdateMotion(uint32 diff);
|
||||
void Clear(bool reset = true)
|
||||
{
|
||||
if (_cleanFlag & MMCF_UPDATE)
|
||||
{
|
||||
if (reset)
|
||||
_cleanFlag |= MMCF_RESET;
|
||||
else
|
||||
_cleanFlag &= ~MMCF_RESET;
|
||||
DelayedClean();
|
||||
}
|
||||
if (reset)
|
||||
_cleanFlag |= MMCF_RESET;
|
||||
else
|
||||
DirectClean(reset);
|
||||
_cleanFlag &= ~MMCF_RESET;
|
||||
DelayedClean();
|
||||
}
|
||||
void MovementExpired(bool reset = true)
|
||||
else
|
||||
DirectClean(reset);
|
||||
}
|
||||
void MovementExpired(bool reset = true)
|
||||
{
|
||||
if (_cleanFlag & MMCF_UPDATE)
|
||||
{
|
||||
if (_cleanFlag & MMCF_UPDATE)
|
||||
{
|
||||
if (reset)
|
||||
_cleanFlag |= MMCF_RESET;
|
||||
else
|
||||
_cleanFlag &= ~MMCF_RESET;
|
||||
DelayedExpire();
|
||||
}
|
||||
if (reset)
|
||||
_cleanFlag |= MMCF_RESET;
|
||||
else
|
||||
DirectExpire(reset);
|
||||
_cleanFlag &= ~MMCF_RESET;
|
||||
DelayedExpire();
|
||||
}
|
||||
else
|
||||
DirectExpire(reset);
|
||||
}
|
||||
|
||||
void MovementExpiredOnSlot(MovementSlot slot, bool reset = true)
|
||||
{
|
||||
// xinef: cannot be used during motion update!
|
||||
if (!(_cleanFlag & MMCF_UPDATE))
|
||||
DirectExpireSlot(slot, reset);
|
||||
}
|
||||
void MovementExpiredOnSlot(MovementSlot slot, bool reset = true)
|
||||
{
|
||||
// xinef: cannot be used during motion update!
|
||||
if (!(_cleanFlag & MMCF_UPDATE))
|
||||
DirectExpireSlot(slot, reset);
|
||||
}
|
||||
|
||||
void MoveIdle();
|
||||
void MoveTargetedHome();
|
||||
void MoveRandom(float wanderDistance = 0.0f);
|
||||
void MoveFollow(Unit* target, float dist, float angle, MovementSlot slot = MOTION_SLOT_ACTIVE);
|
||||
void MoveChase(Unit* target, float dist = 0.0f, float angle = 0.0f);
|
||||
void MoveConfused();
|
||||
void MoveFleeing(Unit* enemy, uint32 time = 0);
|
||||
void MovePoint(uint32 id, const Position &pos, bool generatePath = true, bool forceDestination = true)
|
||||
{ MovePoint(id, pos.m_positionX, pos.m_positionY, pos.m_positionZ, generatePath, forceDestination, MOTION_SLOT_ACTIVE, pos.GetOrientation()); }
|
||||
void MovePoint(uint32 id, float x, float y, float z, bool generatePath = true, bool forceDestination = true, MovementSlot slot = MOTION_SLOT_ACTIVE, float orientation = 0.0f);
|
||||
void MoveSplinePath(Movement::PointsArray* path);
|
||||
void MoveIdle();
|
||||
void MoveTargetedHome();
|
||||
void MoveRandom(float wanderDistance = 0.0f);
|
||||
void MoveFollow(Unit* target, float dist, float angle, MovementSlot slot = MOTION_SLOT_ACTIVE);
|
||||
void MoveChase(Unit* target, float dist = 0.0f, float angle = 0.0f);
|
||||
void MoveConfused();
|
||||
void MoveFleeing(Unit* enemy, uint32 time = 0);
|
||||
void MovePoint(uint32 id, const Position& pos, bool generatePath = true, bool forceDestination = true)
|
||||
{ MovePoint(id, pos.m_positionX, pos.m_positionY, pos.m_positionZ, generatePath, forceDestination, MOTION_SLOT_ACTIVE, pos.GetOrientation()); }
|
||||
void MovePoint(uint32 id, float x, float y, float z, bool generatePath = true, bool forceDestination = true, MovementSlot slot = MOTION_SLOT_ACTIVE, float orientation = 0.0f);
|
||||
void MoveSplinePath(Movement::PointsArray* path);
|
||||
|
||||
// These two movement types should only be used with creatures having landing/takeoff animations
|
||||
void MoveLand(uint32 id, Position const& pos, float speed);
|
||||
void MoveLand(uint32 id, float x, float y, float z, float speed); // pussywizard: added for easy calling by passing 3 floats x, y, z
|
||||
void MoveTakeoff(uint32 id, Position const& pos, float speed);
|
||||
void MoveTakeoff(uint32 id, float x, float y, float z, float speed); // pussywizard: added for easy calling by passing 3 floats x, y, z
|
||||
// These two movement types should only be used with creatures having landing/takeoff animations
|
||||
void MoveLand(uint32 id, Position const& pos, float speed);
|
||||
void MoveLand(uint32 id, float x, float y, float z, float speed); // pussywizard: added for easy calling by passing 3 floats x, y, z
|
||||
void MoveTakeoff(uint32 id, Position const& pos, float speed);
|
||||
void MoveTakeoff(uint32 id, float x, float y, float z, float speed); // pussywizard: added for easy calling by passing 3 floats x, y, z
|
||||
|
||||
void MoveCharge(float x, float y, float z, float speed = SPEED_CHARGE, uint32 id = EVENT_CHARGE, const Movement::PointsArray* path = NULL, bool generatePath = false, float orientation = 0.0f);
|
||||
void MoveKnockbackFrom(float srcX, float srcY, float speedXY, float speedZ);
|
||||
void MoveJumpTo(float angle, float speedXY, float speedZ);
|
||||
void MoveJump(Position const& pos, float speedXY, float speedZ, uint32 id = 0)
|
||||
{ MoveJump(pos.m_positionX, pos.m_positionY, pos.m_positionZ, speedXY, speedZ, id); };
|
||||
void MoveJump(float x, float y, float z, float speedXY, float speedZ, uint32 id = 0, Unit const* target = nullptr);
|
||||
void MoveFall(uint32 id = 0, bool addFlagForNPC = false);
|
||||
void MoveCharge(float x, float y, float z, float speed = SPEED_CHARGE, uint32 id = EVENT_CHARGE, const Movement::PointsArray* path = NULL, bool generatePath = false, float orientation = 0.0f);
|
||||
void MoveKnockbackFrom(float srcX, float srcY, float speedXY, float speedZ);
|
||||
void MoveJumpTo(float angle, float speedXY, float speedZ);
|
||||
void MoveJump(Position const& pos, float speedXY, float speedZ, uint32 id = 0)
|
||||
{ MoveJump(pos.m_positionX, pos.m_positionY, pos.m_positionZ, speedXY, speedZ, id); };
|
||||
void MoveJump(float x, float y, float z, float speedXY, float speedZ, uint32 id = 0, Unit const* target = nullptr);
|
||||
void MoveFall(uint32 id = 0, bool addFlagForNPC = false);
|
||||
|
||||
void MoveSeekAssistance(float x, float y, float z);
|
||||
void MoveSeekAssistanceDistract(uint32 timer);
|
||||
void MoveTaxiFlight(uint32 path, uint32 pathnode);
|
||||
void MoveDistract(uint32 time);
|
||||
void MovePath(uint32 path_id, bool repeatable);
|
||||
void MoveRotate(uint32 time, RotateDirection direction);
|
||||
void MoveSeekAssistance(float x, float y, float z);
|
||||
void MoveSeekAssistanceDistract(uint32 timer);
|
||||
void MoveTaxiFlight(uint32 path, uint32 pathnode);
|
||||
void MoveDistract(uint32 time);
|
||||
void MovePath(uint32 path_id, bool repeatable);
|
||||
void MoveRotate(uint32 time, RotateDirection direction);
|
||||
|
||||
MovementGeneratorType GetCurrentMovementGeneratorType() const;
|
||||
MovementGeneratorType GetMotionSlotType(int slot) const;
|
||||
uint32 GetCurrentSplineId() const; // Xinef: Escort system
|
||||
MovementGeneratorType GetCurrentMovementGeneratorType() const;
|
||||
MovementGeneratorType GetMotionSlotType(int slot) const;
|
||||
uint32 GetCurrentSplineId() const; // Xinef: Escort system
|
||||
|
||||
void propagateSpeedChange();
|
||||
void ReinitializeMovement();
|
||||
void propagateSpeedChange();
|
||||
void ReinitializeMovement();
|
||||
|
||||
bool GetDestination(float &x, float &y, float &z);
|
||||
private:
|
||||
void Mutate(MovementGenerator *m, MovementSlot slot); // use Move* functions instead
|
||||
bool GetDestination(float& x, float& y, float& z);
|
||||
private:
|
||||
void Mutate(MovementGenerator* m, MovementSlot slot); // use Move* functions instead
|
||||
|
||||
void DirectClean(bool reset);
|
||||
void DelayedClean();
|
||||
void DirectClean(bool reset);
|
||||
void DelayedClean();
|
||||
|
||||
void DirectExpire(bool reset);
|
||||
void DirectExpireSlot(MovementSlot slot, bool reset);
|
||||
void DelayedExpire();
|
||||
void DirectExpire(bool reset);
|
||||
void DirectExpireSlot(MovementSlot slot, bool reset);
|
||||
void DelayedExpire();
|
||||
|
||||
typedef std::vector<_Ty> ExpireList;
|
||||
ExpireList* _expList;
|
||||
_Ty Impl[MAX_MOTION_SLOT];
|
||||
int _top;
|
||||
Unit* _owner;
|
||||
bool _needInit[MAX_MOTION_SLOT];
|
||||
uint8 _cleanFlag;
|
||||
typedef std::vector<_Ty> ExpireList;
|
||||
ExpireList* _expList;
|
||||
_Ty Impl[MAX_MOTION_SLOT];
|
||||
int _top;
|
||||
Unit* _owner;
|
||||
bool _needInit[MAX_MOTION_SLOT];
|
||||
uint8 _cleanFlag;
|
||||
};
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user