Core/Common: Merge TimeTrackerSmall with TimeTracker
Port From (https://github.com/TrinityCore/TrinityCore/commit/8809d54ca2daa230b1439f012c8b10ee88d6beae)
This commit is contained in:
@@ -339,79 +339,49 @@ public static class Time
|
||||
}
|
||||
}
|
||||
|
||||
public class TimeTrackerSmall
|
||||
public class TimeTracker
|
||||
{
|
||||
public TimeTrackerSmall(int expiry = 0)
|
||||
public TimeTracker(uint expiry = 0)
|
||||
{
|
||||
i_expiryTime = expiry;
|
||||
_expiryTime = TimeSpan.FromMilliseconds(expiry);
|
||||
}
|
||||
|
||||
public TimeTrackerSmall(TimeSpan expiry = default)
|
||||
public TimeTracker(TimeSpan expiry)
|
||||
{
|
||||
i_expiryTime = (int)expiry.TotalMilliseconds;
|
||||
_expiryTime = expiry;
|
||||
}
|
||||
|
||||
public void Update(int diff)
|
||||
public void Update(uint diff)
|
||||
{
|
||||
i_expiryTime -= diff;
|
||||
Update(TimeSpan.FromMilliseconds(diff));
|
||||
}
|
||||
|
||||
public void Update(TimeSpan diff)
|
||||
{
|
||||
Update((int)diff.TotalMilliseconds);
|
||||
_expiryTime -= diff;
|
||||
}
|
||||
|
||||
public bool Passed()
|
||||
{
|
||||
return i_expiryTime <= 0;
|
||||
return _expiryTime <= TimeSpan.Zero;
|
||||
}
|
||||
|
||||
public void Reset(int interval)
|
||||
public void Reset(uint expiry)
|
||||
{
|
||||
i_expiryTime = interval;
|
||||
Reset(TimeSpan.FromMilliseconds(expiry));
|
||||
}
|
||||
|
||||
public void Reset(TimeSpan expiry)
|
||||
{
|
||||
Reset((int)expiry.TotalMilliseconds);
|
||||
_expiryTime = expiry;
|
||||
}
|
||||
|
||||
public TimeSpan GetExpiry()
|
||||
{
|
||||
return TimeSpan.FromMilliseconds(i_expiryTime);
|
||||
return _expiryTime;
|
||||
}
|
||||
|
||||
int i_expiryTime;
|
||||
}
|
||||
|
||||
public class TimeTracker
|
||||
{
|
||||
public TimeTracker(long expiry = 0)
|
||||
{
|
||||
i_expiryTime = expiry;
|
||||
}
|
||||
|
||||
public void Update(long diff)
|
||||
{
|
||||
i_expiryTime -= diff;
|
||||
}
|
||||
|
||||
public bool Passed()
|
||||
{
|
||||
return i_expiryTime <= 0;
|
||||
}
|
||||
|
||||
public void Reset(long interval)
|
||||
{
|
||||
i_expiryTime = interval;
|
||||
}
|
||||
|
||||
public long GetExpiry()
|
||||
{
|
||||
return i_expiryTime;
|
||||
}
|
||||
|
||||
long i_expiryTime;
|
||||
TimeSpan _expiryTime;
|
||||
}
|
||||
|
||||
public class IntervalTimer
|
||||
|
||||
@@ -179,7 +179,7 @@ namespace Game.Collision
|
||||
{
|
||||
public DynTreeImpl()
|
||||
{
|
||||
rebalance_timer = new TimeTrackerSmall(200);
|
||||
rebalance_timer = new TimeTracker(200);
|
||||
unbalanced_times = 0;
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ namespace Game.Collision
|
||||
if (Empty())
|
||||
return;
|
||||
|
||||
rebalance_timer.Update((int)difftime);
|
||||
rebalance_timer.Update(difftime);
|
||||
if (rebalance_timer.Passed())
|
||||
{
|
||||
rebalance_timer.Reset(200);
|
||||
@@ -215,7 +215,7 @@ namespace Game.Collision
|
||||
}
|
||||
}
|
||||
|
||||
TimeTrackerSmall rebalance_timer;
|
||||
TimeTracker rebalance_timer;
|
||||
int unbalanced_times;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,7 +241,7 @@ namespace Game.Entities
|
||||
float[] m_powerFraction = new float[(int)PowerType.MaxPerClass];
|
||||
int[] m_MirrorTimer = new int[3];
|
||||
|
||||
TimeTrackerSmall m_groupUpdateTimer;
|
||||
TimeTracker m_groupUpdateTimer;
|
||||
|
||||
ulong m_GuildIdInvited;
|
||||
DeclinedName _declinedname;
|
||||
|
||||
@@ -612,7 +612,7 @@ namespace Game.Entities
|
||||
}
|
||||
|
||||
// group update
|
||||
m_groupUpdateTimer.Update((int)diff);
|
||||
m_groupUpdateTimer.Update(diff);
|
||||
if (m_groupUpdateTimer.Passed())
|
||||
{
|
||||
SendUpdateToOutOfRangeGroupMembers();
|
||||
|
||||
@@ -152,7 +152,7 @@ namespace Game.Entities
|
||||
|
||||
public override void Update(uint diff)
|
||||
{
|
||||
int positionUpdateDelay = 200;
|
||||
uint positionUpdateDelay = 200;
|
||||
|
||||
if (GetAI() != null)
|
||||
GetAI().UpdateAI(diff);
|
||||
@@ -236,7 +236,7 @@ namespace Game.Entities
|
||||
}
|
||||
|
||||
// Set position
|
||||
_positionChangeTimer.Update((int)diff);
|
||||
_positionChangeTimer.Update(diff);
|
||||
if (_positionChangeTimer.Passed())
|
||||
{
|
||||
_positionChangeTimer.Reset(positionUpdateDelay);
|
||||
@@ -805,7 +805,7 @@ namespace Game.Entities
|
||||
|
||||
KeyFrame _currentFrame;
|
||||
int _nextFrame;
|
||||
TimeTrackerSmall _positionChangeTimer = new();
|
||||
TimeTracker _positionChangeTimer = new();
|
||||
bool _isMoving;
|
||||
bool _pendingStop;
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Game.Entities
|
||||
public MoveSpline MoveSpline { get; set; }
|
||||
MotionMaster i_motionMaster;
|
||||
public uint m_movementCounter; //< Incrementing counter used in movement packets
|
||||
TimeTrackerSmall splineSyncTimer;
|
||||
TimeTracker splineSyncTimer;
|
||||
MovementForces _movementForces;
|
||||
PositionUpdateInfo _positionUpdateInfo;
|
||||
protected Unit m_unitMovedByMe; // only ever set for players, and only for direct client control
|
||||
|
||||
@@ -1708,7 +1708,7 @@ namespace Game.Entities
|
||||
|
||||
if (MoveSpline.IsCyclic())
|
||||
{
|
||||
splineSyncTimer.Update((int)diff);
|
||||
splineSyncTimer.Update(diff);
|
||||
if (splineSyncTimer.Passed())
|
||||
{
|
||||
splineSyncTimer.Reset(5000); // Retail value, do not change
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace Game.Entities
|
||||
|
||||
m_serverSideVisibility.SetValue(ServerSideVisibilityType.Ghost, GhostVisibilityType.Alive);
|
||||
|
||||
splineSyncTimer = new TimeTrackerSmall();
|
||||
splineSyncTimer = new TimeTracker();
|
||||
|
||||
m_unitData = new UnitData();
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace Game.Groups
|
||||
{
|
||||
if (_isLeaderOffline)
|
||||
{
|
||||
_leaderOfflineTimer.Update((int)diff);
|
||||
_leaderOfflineTimer.Update(diff);
|
||||
if (_leaderOfflineTimer.Passed())
|
||||
{
|
||||
SelectNewPartyOrRaidLeader();
|
||||
@@ -2752,7 +2752,7 @@ namespace Game.Groups
|
||||
uint m_maxEnchantingLevel;
|
||||
uint m_dbStoreId;
|
||||
bool _isLeaderOffline;
|
||||
TimeTrackerSmall _leaderOfflineTimer = new();
|
||||
TimeTracker _leaderOfflineTimer = new();
|
||||
|
||||
// Ready Check
|
||||
bool m_readyCheckStarted;
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Game.Maps
|
||||
|
||||
public GridInfo(long expiry, bool unload = true)
|
||||
{
|
||||
i_timer = new TimeTracker((int)expiry);
|
||||
i_timer = new TimeTracker((uint)expiry);
|
||||
vis_Update = new PeriodicTimer(0, RandomHelper.IRand(0, 1000));
|
||||
i_unloadActiveLockCount = 0;
|
||||
i_unloadExplicitLock = !unload;
|
||||
@@ -71,12 +71,12 @@ namespace Game.Maps
|
||||
|
||||
public void ResetTimeTracker(long interval)
|
||||
{
|
||||
i_timer.Reset(interval);
|
||||
i_timer.Reset((uint)interval);
|
||||
}
|
||||
|
||||
public void UpdateTimeTracker(long diff)
|
||||
{
|
||||
i_timer.Update(diff);
|
||||
i_timer.Update((uint)diff);
|
||||
}
|
||||
|
||||
public PeriodicTimer GetRelocationTimer()
|
||||
|
||||
@@ -24,14 +24,14 @@ namespace Game.Movement
|
||||
{
|
||||
class ChaseMovementGenerator : MovementGenerator
|
||||
{
|
||||
static int RANGE_CHECK_INTERVAL = 100; // time (ms) until we attempt to recalculate
|
||||
static uint RANGE_CHECK_INTERVAL = 100; // time (ms) until we attempt to recalculate
|
||||
|
||||
ChaseRange? _range;
|
||||
ChaseAngle? _angle;
|
||||
|
||||
PathGenerator _path;
|
||||
Position _lastTargetPosition;
|
||||
TimeTrackerSmall _rangeCheckTimer;
|
||||
TimeTracker _rangeCheckTimer;
|
||||
bool _movingTowards = true;
|
||||
bool _mutualChase = true;
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace Game.Movement
|
||||
ChaseAngle? angle = mutualChase ? null : _angle;
|
||||
|
||||
// periodically check if we're already in the expected range...
|
||||
_rangeCheckTimer.Update((int)diff);
|
||||
_rangeCheckTimer.Update(diff);
|
||||
if (_rangeCheckTimer.Passed())
|
||||
{
|
||||
_rangeCheckTimer.Reset(RANGE_CHECK_INTERVAL);
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace Game.Movement
|
||||
MoveSplineInit init = new(owner);
|
||||
init.MovebyPath(_path.GetPath());
|
||||
init.SetWalk(true);
|
||||
int traveltime = init.Launch();
|
||||
uint traveltime = (uint)init.Launch();
|
||||
_timer.Reset(traveltime + RandomHelper.URand(800, 1500));
|
||||
}
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ namespace Game.Movement
|
||||
MoveSplineInit init = new(owner);
|
||||
init.MovebyPath(_path.GetPath());
|
||||
init.SetWalk(false);
|
||||
int traveltime = init.Launch();
|
||||
uint traveltime = (uint)init.Launch();
|
||||
_timer.Reset(traveltime + RandomHelper.URand(800, 1500));
|
||||
}
|
||||
|
||||
|
||||
@@ -24,13 +24,13 @@ namespace Game.Movement
|
||||
{
|
||||
public class FollowMovementGenerator : MovementGenerator
|
||||
{
|
||||
static int CHECK_INTERVAL = 100;
|
||||
static uint CHECK_INTERVAL = 100;
|
||||
static float FOLLOW_RANGE_TOLERANCE = 1.0f;
|
||||
|
||||
float _range;
|
||||
ChaseAngle _angle;
|
||||
|
||||
TimeTrackerSmall _checkTimer;
|
||||
TimeTracker _checkTimer;
|
||||
PathGenerator _path;
|
||||
Position _lastTargetPosition;
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace Game.Movement
|
||||
return true;
|
||||
}
|
||||
|
||||
_checkTimer.Update((int)diff);
|
||||
_checkTimer.Update(diff);
|
||||
if (_checkTimer.Passed())
|
||||
{
|
||||
_checkTimer.Reset(CHECK_INTERVAL);
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Game.Movement
|
||||
{
|
||||
AbstractFollower _abstractFollower;
|
||||
|
||||
static int FORMATION_MOVEMENT_INTERVAL = 1200; // sniffed (3 batch update cycles)
|
||||
static uint FORMATION_MOVEMENT_INTERVAL = 1200; // sniffed (3 batch update cycles)
|
||||
float _range;
|
||||
float _angle;
|
||||
uint _point1;
|
||||
@@ -34,7 +34,7 @@ namespace Game.Movement
|
||||
bool _hasPredictedDestination;
|
||||
|
||||
Position _lastLeaderPosition;
|
||||
TimeTrackerSmall _nextMoveTimer = new();
|
||||
TimeTracker _nextMoveTimer = new();
|
||||
|
||||
public FormationMovementGenerator(Unit leader, float range, float angle, uint point1, uint point2)
|
||||
{
|
||||
@@ -128,7 +128,7 @@ namespace Game.Movement
|
||||
return true;
|
||||
}
|
||||
|
||||
_nextMoveTimer.Update((int)diff);
|
||||
_nextMoveTimer.Update(diff);
|
||||
if (_nextMoveTimer.Passed())
|
||||
{
|
||||
_nextMoveTimer.Reset(FORMATION_MOVEMENT_INTERVAL);
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Game.Movement
|
||||
MoveSplineInit _splineInit;
|
||||
MovementGeneratorType _type;
|
||||
uint _pointId;
|
||||
TimeTrackerSmall _duration;
|
||||
TimeTracker _duration;
|
||||
|
||||
uint _arrivalSpellId;
|
||||
ObjectGuid _arrivalSpellTargetGuid;
|
||||
@@ -57,7 +57,7 @@ namespace Game.Movement
|
||||
RemoveFlag(MovementGeneratorFlags.InitializationPending | MovementGeneratorFlags.Deactivated);
|
||||
AddFlag(MovementGeneratorFlags.Initialized);
|
||||
|
||||
_duration.Reset(_splineInit.Launch());
|
||||
_duration.Reset((uint)_splineInit.Launch());
|
||||
}
|
||||
|
||||
public override void Reset(Unit owner)
|
||||
@@ -72,7 +72,7 @@ namespace Game.Movement
|
||||
|
||||
// Cyclic splines never expire, so update the duration only if it's not cyclic
|
||||
if (!owner.MoveSpline.IsCyclic())
|
||||
_duration.Update((int)diff);
|
||||
_duration.Update(diff);
|
||||
|
||||
if (_duration.Passed() || owner.MoveSpline.Finalized())
|
||||
{
|
||||
|
||||
@@ -188,7 +188,7 @@ namespace Game.Movement
|
||||
MoveSplineInit init = new(owner);
|
||||
init.MovebyPath(_path.GetPath());
|
||||
init.SetWalk(walk);
|
||||
int splineDuration = init.Launch();
|
||||
uint splineDuration = (uint)init.Launch();
|
||||
|
||||
--_wanderSteps;
|
||||
if (_wanderSteps != 0) // Creature has yet to do steps before pausing
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Game.Movement
|
||||
{
|
||||
public WaypointMovementGenerator(uint pathId = 0, bool repeating = true)
|
||||
{
|
||||
_nextMoveTime = new TimeTrackerSmall(0);
|
||||
_nextMoveTime = new TimeTracker(0);
|
||||
_pathId = pathId;
|
||||
_repeating = repeating;
|
||||
_loadedFromDB = true;
|
||||
@@ -40,7 +40,7 @@ namespace Game.Movement
|
||||
|
||||
public WaypointMovementGenerator(WaypointPath path, bool repeating = true)
|
||||
{
|
||||
_nextMoveTime = new TimeTrackerSmall(0);
|
||||
_nextMoveTime = new TimeTracker(0);
|
||||
_repeating = repeating;
|
||||
_path = path;
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace Game.Movement
|
||||
return;
|
||||
|
||||
AddFlag(MovementGeneratorFlags.TimedPaused);
|
||||
_nextMoveTime.Reset((int)timer);
|
||||
_nextMoveTime.Reset(timer);
|
||||
RemoveFlag(MovementGeneratorFlags.Paused);
|
||||
}
|
||||
else
|
||||
@@ -73,7 +73,7 @@ namespace Game.Movement
|
||||
public override void Resume(uint overrideTimer = 0)
|
||||
{
|
||||
if (overrideTimer != 0)
|
||||
_nextMoveTime.Reset((int)overrideTimer);
|
||||
_nextMoveTime.Reset(overrideTimer);
|
||||
|
||||
if (_nextMoveTime.Passed())
|
||||
_nextMoveTime.Reset(1); // Needed so that Update does not behave as if node was reached
|
||||
@@ -251,7 +251,7 @@ namespace Game.Movement
|
||||
if (waypoint.delay != 0)
|
||||
{
|
||||
owner.ClearUnitState(UnitState.RoamingMove);
|
||||
_nextMoveTime.Reset((int)waypoint.delay);
|
||||
_nextMoveTime.Reset(waypoint.delay);
|
||||
}
|
||||
|
||||
if (waypoint.eventId != 0 && RandomHelper.URand(0, 99) < waypoint.eventChance)
|
||||
@@ -398,7 +398,7 @@ namespace Game.Movement
|
||||
|
||||
bool UpdateTimer(uint diff)
|
||||
{
|
||||
_nextMoveTime.Update((int)diff);
|
||||
_nextMoveTime.Update(diff);
|
||||
if (_nextMoveTime.Passed())
|
||||
{
|
||||
_nextMoveTime.Reset(0);
|
||||
@@ -411,7 +411,7 @@ namespace Game.Movement
|
||||
|
||||
public override void UnitSpeedChanged() { AddFlag(MovementGeneratorFlags.SpeedUpdatePending); }
|
||||
|
||||
TimeTrackerSmall _nextMoveTime;
|
||||
TimeTracker _nextMoveTime;
|
||||
uint _pathId;
|
||||
bool _repeating;
|
||||
bool _loadedFromDB;
|
||||
|
||||
Reference in New Issue
Block a user