mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Common: Merge TimeTrackerSmall with TimeTracker
(cherry picked from commit 228696bf80)
This commit is contained in:
@@ -103,7 +103,7 @@ struct DynTreeImpl : public ParentTree/*, public Intersectable*/
|
||||
}
|
||||
}
|
||||
|
||||
TimeTrackerSmall rebalance_timer;
|
||||
TimeTracker rebalance_timer;
|
||||
int unbalanced_times;
|
||||
};
|
||||
|
||||
|
||||
@@ -115,81 +115,41 @@ private:
|
||||
struct TimeTracker
|
||||
{
|
||||
public:
|
||||
|
||||
TimeTracker(time_t expiry)
|
||||
: i_expiryTime(expiry)
|
||||
{
|
||||
}
|
||||
|
||||
void Update(time_t diff)
|
||||
{
|
||||
i_expiryTime -= diff;
|
||||
}
|
||||
|
||||
bool Passed() const
|
||||
{
|
||||
return i_expiryTime <= 0;
|
||||
}
|
||||
|
||||
void Reset(time_t interval)
|
||||
{
|
||||
i_expiryTime = interval;
|
||||
}
|
||||
|
||||
time_t GetExpiry() const
|
||||
{
|
||||
return i_expiryTime;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
time_t i_expiryTime;
|
||||
};
|
||||
|
||||
struct TimeTrackerSmall
|
||||
{
|
||||
public:
|
||||
|
||||
TimeTrackerSmall(int32 expiry = 0)
|
||||
: i_expiryTime(expiry)
|
||||
{
|
||||
}
|
||||
|
||||
TimeTrackerSmall(Milliseconds expiry) : i_expiryTime(expiry.count()) { }
|
||||
TimeTracker(int32 expiry = 0) : _expiryTime(expiry) { }
|
||||
TimeTracker(Milliseconds expiry) : _expiryTime(expiry) { }
|
||||
|
||||
void Update(int32 diff)
|
||||
{
|
||||
i_expiryTime -= diff;
|
||||
Update(Milliseconds(diff));
|
||||
}
|
||||
|
||||
void Update(Milliseconds diff)
|
||||
{
|
||||
Update(diff.count());
|
||||
_expiryTime -= diff;
|
||||
}
|
||||
|
||||
bool Passed() const
|
||||
{
|
||||
return i_expiryTime <= 0;
|
||||
return _expiryTime <= 0s;
|
||||
}
|
||||
|
||||
void Reset(int32 interval)
|
||||
void Reset(int32 expiry)
|
||||
{
|
||||
i_expiryTime = interval;
|
||||
Reset(Milliseconds(expiry));
|
||||
}
|
||||
|
||||
void Reset(Milliseconds expiry)
|
||||
{
|
||||
Reset(expiry.count());
|
||||
_expiryTime = expiry;
|
||||
}
|
||||
|
||||
Milliseconds GetExpiry() const
|
||||
{
|
||||
return Milliseconds(i_expiryTime);
|
||||
return _expiryTime;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
int32 i_expiryTime;
|
||||
Milliseconds _expiryTime;
|
||||
};
|
||||
|
||||
struct PeriodicTimer
|
||||
|
||||
@@ -3026,7 +3026,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
|
||||
|
||||
std::array<std::unique_ptr<CUFProfile>, MAX_CUF_PROFILES> _CUFProfiles;
|
||||
|
||||
TimeTrackerSmall m_groupUpdateTimer;
|
||||
TimeTracker m_groupUpdateTimer;
|
||||
|
||||
private:
|
||||
// internal common parts for CanStore/StoreItem functions
|
||||
|
||||
@@ -118,7 +118,7 @@ class TC_GAME_API Transport : public GameObject, public TransportBase
|
||||
|
||||
KeyFrameVec::const_iterator _currentFrame;
|
||||
KeyFrameVec::const_iterator _nextFrame;
|
||||
TimeTrackerSmall _positionChangeTimer;
|
||||
TimeTracker _positionChangeTimer;
|
||||
bool _isMoving;
|
||||
bool _pendingStop;
|
||||
|
||||
|
||||
@@ -1981,7 +1981,7 @@ class TC_GAME_API Unit : public WorldObject
|
||||
private:
|
||||
|
||||
uint32 m_state; // Even derived shouldn't modify
|
||||
TimeTrackerSmall m_splineSyncTimer;
|
||||
TimeTracker m_splineSyncTimer;
|
||||
|
||||
Diminishing m_Diminishing;
|
||||
|
||||
|
||||
@@ -458,7 +458,7 @@ class TC_GAME_API Group
|
||||
uint32 m_maxEnchantingLevel;
|
||||
uint32 m_dbStoreId; // Represents the ID used in database (Can be reused by other groups if group was disbanded)
|
||||
bool m_isLeaderOffline;
|
||||
TimeTrackerSmall m_leaderOfflineTimer;
|
||||
TimeTracker m_leaderOfflineTimer;
|
||||
|
||||
// Ready Check
|
||||
bool m_readyCheckStarted;
|
||||
|
||||
@@ -51,7 +51,7 @@ class ChaseMovementGenerator : public MovementGenerator, public AbstractFollower
|
||||
|
||||
std::unique_ptr<PathGenerator> _path;
|
||||
Optional<Position> _lastTargetPosition;
|
||||
TimeTrackerSmall _rangeCheckTimer;
|
||||
TimeTracker _rangeCheckTimer;
|
||||
bool _movingTowards = true;
|
||||
bool _mutualChase = true;
|
||||
};
|
||||
|
||||
@@ -53,7 +53,7 @@ class FollowMovementGenerator : public MovementGenerator, public AbstractFollowe
|
||||
float const _range;
|
||||
ChaseAngle const _angle;
|
||||
|
||||
TimeTrackerSmall _checkTimer;
|
||||
TimeTracker _checkTimer;
|
||||
std::unique_ptr<PathGenerator> _path;
|
||||
Optional<Position> _lastTargetPosition;
|
||||
};
|
||||
|
||||
@@ -51,7 +51,7 @@ class FormationMovementGenerator : public MovementGeneratorMedium<Creature, Form
|
||||
bool _hasPredictedDestination;
|
||||
|
||||
Position _lastLeaderPosition;
|
||||
TimeTrackerSmall _nextMoveTimer;
|
||||
TimeTracker _nextMoveTimer;
|
||||
};
|
||||
|
||||
#endif // TRINITY_FORMATIONMOVEMENTGENERATOR_H
|
||||
|
||||
@@ -45,7 +45,7 @@ class GenericMovementGenerator : public MovementGenerator
|
||||
Movement::MoveSplineInit _splineInit;
|
||||
MovementGeneratorType _type;
|
||||
uint32 _pointId;
|
||||
TimeTrackerSmall _duration;
|
||||
TimeTracker _duration;
|
||||
|
||||
uint32 _arrivalSpellId;
|
||||
ObjectGuid _arrivalSpellTargetGuid;
|
||||
|
||||
@@ -68,7 +68,7 @@ class WaypointMovementGenerator<Creature> : public MovementGeneratorMedium<Creat
|
||||
return false;
|
||||
}
|
||||
|
||||
TimeTrackerSmall _nextMoveTime;
|
||||
TimeTracker _nextMoveTime;
|
||||
uint32 _pathId;
|
||||
bool _repeating;
|
||||
bool _loadedFromDB;
|
||||
|
||||
@@ -236,7 +236,7 @@ struct npc_wisp_invis : public ScriptedAI
|
||||
}
|
||||
|
||||
private:
|
||||
TimeTrackerSmall _timer;
|
||||
TimeTracker _timer;
|
||||
uint32 _creatureType;
|
||||
uint32 _firstSpell;
|
||||
uint32 _secondSpell;
|
||||
@@ -428,7 +428,7 @@ private:
|
||||
}
|
||||
|
||||
TaskScheduler _scheduler;
|
||||
TimeTrackerSmall _laughTimer;
|
||||
TimeTracker _laughTimer;
|
||||
ObjectGuid _bodyGUID;
|
||||
uint32 _phase;
|
||||
bool _withBody;
|
||||
@@ -807,7 +807,7 @@ private:
|
||||
|
||||
InstanceScript* _instance;
|
||||
TaskScheduler _scheduler;
|
||||
TimeTrackerSmall _laughTimer;
|
||||
TimeTracker _laughTimer;
|
||||
ObjectGuid _headGUID;
|
||||
uint32 _phase;
|
||||
uint32 _id;
|
||||
|
||||
@@ -153,7 +153,7 @@ struct boss_high_inquisitor_fairbanks : public BossAI
|
||||
}
|
||||
|
||||
private:
|
||||
TimeTrackerSmall _healTimer;
|
||||
TimeTracker _healTimer;
|
||||
bool _powerWordShield;
|
||||
};
|
||||
|
||||
|
||||
@@ -232,7 +232,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
TimeTrackerSmall _killYellTimer;
|
||||
TimeTracker _killYellTimer;
|
||||
bool _fakeDeath;
|
||||
bool _canDie;
|
||||
};
|
||||
@@ -427,7 +427,7 @@ private:
|
||||
InstanceScript* _instance;
|
||||
EventMap _events;
|
||||
TaskScheduler _scheduler;
|
||||
TimeTrackerSmall _killYellTimer;
|
||||
TimeTracker _killYellTimer;
|
||||
bool _ressurectionInProgress;
|
||||
bool _canDie;
|
||||
};
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
|
||||
#include "Timer.h"
|
||||
|
||||
TEST_CASE("TimerTrackerSmall: Check if time passed")
|
||||
TEST_CASE("TimeTracker: Check if time passed")
|
||||
{
|
||||
TimeTrackerSmall tracker(1000 /*ms*/);
|
||||
TimeTracker tracker(1000 /*ms*/);
|
||||
REQUIRE_FALSE(tracker.Passed());
|
||||
REQUIRE(tracker.GetExpiry() == 1s);
|
||||
|
||||
@@ -39,9 +39,9 @@ TEST_CASE("TimerTrackerSmall: Check if time passed")
|
||||
REQUIRE(tracker.GetExpiry() == -500ms);
|
||||
}
|
||||
|
||||
TEST_CASE("TimerTrackerSmall: Reset timer")
|
||||
TEST_CASE("TimeTracker: Reset timer")
|
||||
{
|
||||
TimeTrackerSmall tracker(1000 /*ms*/);
|
||||
TimeTracker tracker(1000 /*ms*/);
|
||||
REQUIRE_FALSE(tracker.Passed());
|
||||
REQUIRE(tracker.GetExpiry() == 1s);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user