Core/Common: Merge TimeTrackerSmall with TimeTracker

This commit is contained in:
Carbenium
2020-07-29 00:16:15 +02:00
committed by Peter Keresztes Schmidt
parent e55516348d
commit 228696bf80
15 changed files with 30 additions and 70 deletions

View File

@@ -103,7 +103,7 @@ struct DynTreeImpl : public ParentTree/*, public Intersectable*/
}
}
TimeTrackerSmall rebalance_timer;
TimeTracker rebalance_timer;
int unbalanced_times;
};

View File

@@ -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

View File

@@ -2425,7 +2425,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
bool m_needsZoneUpdate;
TimeTrackerSmall m_groupUpdateTimer;
TimeTracker m_groupUpdateTimer;
private:
// internal common parts for CanStore/StoreItem functions

View File

@@ -117,7 +117,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;

View File

@@ -1800,7 +1800,7 @@ class TC_GAME_API Unit : public WorldObject
uint32 m_state; // Even derived shouldn't modify
uint32 m_lastManaUse; // msecs
TimeTrackerSmall m_splineSyncTimer;
TimeTracker m_splineSyncTimer;
DiminishingReturn m_Diminishing[DIMINISHING_MAX];

View File

@@ -370,6 +370,6 @@ 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;
};
#endif

View File

@@ -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;
};

View File

@@ -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;
};

View File

@@ -51,7 +51,7 @@ class FormationMovementGenerator : public MovementGeneratorMedium<Creature, Form
bool _hasPredictedDestination;
Position _lastLeaderPosition;
TimeTrackerSmall _nextMoveTimer;
TimeTracker _nextMoveTimer;
};
#endif // TRINITY_FORMATIONMOVEMENTGENERATOR_H

View File

@@ -44,7 +44,7 @@ class GenericMovementGenerator : public MovementGenerator
Movement::MoveSplineInit _splineInit;
MovementGeneratorType _type;
uint32 _pointId;
TimeTrackerSmall _duration;
TimeTracker _duration;
};
#endif

View File

@@ -68,7 +68,7 @@ class WaypointMovementGenerator<Creature> : public MovementGeneratorMedium<Creat
return false;
}
TimeTrackerSmall _nextMoveTime;
TimeTracker _nextMoveTime;
uint32 _pathId;
bool _repeating;
bool _loadedFromDB;

View File

@@ -237,7 +237,7 @@ struct npc_wisp_invis : public ScriptedAI
}
private:
TimeTrackerSmall _timer;
TimeTracker _timer;
uint32 _creatureType;
uint32 _firstSpell;
uint32 _secondSpell;
@@ -429,7 +429,7 @@ private:
}
TaskScheduler _scheduler;
TimeTrackerSmall _laughTimer;
TimeTracker _laughTimer;
ObjectGuid _bodyGUID;
uint32 _phase;
bool _withBody;
@@ -808,7 +808,7 @@ private:
InstanceScript* _instance;
TaskScheduler _scheduler;
TimeTrackerSmall _laughTimer;
TimeTracker _laughTimer;
ObjectGuid _headGUID;
uint32 _phase;
uint32 _id;

View File

@@ -153,7 +153,7 @@ struct boss_high_inquisitor_fairbanks : public BossAI
}
private:
TimeTrackerSmall _healTimer;
TimeTracker _healTimer;
bool _powerWordShield;
};

View File

@@ -233,7 +233,7 @@ public:
}
private:
TimeTrackerSmall _killYellTimer;
TimeTracker _killYellTimer;
bool _fakeDeath;
bool _canDie;
};
@@ -428,7 +428,7 @@ private:
InstanceScript* _instance;
EventMap _events;
TaskScheduler _scheduler;
TimeTrackerSmall _killYellTimer;
TimeTracker _killYellTimer;
bool _ressurectionInProgress;
bool _canDie;
};

View File

@@ -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);