From 167acf260cd3f4809b3e5827e859456485617e0f Mon Sep 17 00:00:00 2001 From: MrDave1999 Date: Sat, 9 Nov 2024 16:48:27 -0500 Subject: [PATCH] fix(ecs): Use DateTime.UtcNow.Ticks instead of Stopwatch.GetTimestamp --- src/SampSharp.Entities/Timers/TimerReference.cs | 2 +- src/SampSharp.Entities/Timers/TimerSystem.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/SampSharp.Entities/Timers/TimerReference.cs b/src/SampSharp.Entities/Timers/TimerReference.cs index 56857645..e6af6ca7 100644 --- a/src/SampSharp.Entities/Timers/TimerReference.cs +++ b/src/SampSharp.Entities/Timers/TimerReference.cs @@ -30,7 +30,7 @@ internal TimerReference(TimerInfo info, object target, MethodInfo method) } /// Gets the time span until the next tick of this timer. - public TimeSpan NextTick => new(Info.NextTick - Stopwatch.GetTimestamp()); + public TimeSpan NextTick => new(Info.NextTick - DateTime.UtcNow.Ticks); internal TimerInfo Info { get; set; } diff --git a/src/SampSharp.Entities/Timers/TimerSystem.cs b/src/SampSharp.Entities/Timers/TimerSystem.cs index a64ae1da..10e82623 100644 --- a/src/SampSharp.Entities/Timers/TimerSystem.cs +++ b/src/SampSharp.Entities/Timers/TimerSystem.cs @@ -64,7 +64,7 @@ public TimerReference Start(Action action, Tim { IsActive = true, IntervalTicks = interval.Ticks, - NextTick = Stopwatch.GetTimestamp() + interval.Ticks + NextTick = DateTime.UtcNow.Ticks + interval.Ticks }; var reference = new TimerReference(invoker, null, null); @@ -79,7 +79,7 @@ public TimerReference Start(Action action, Tim [Event] internal void OnGameModeInit() { - _lastTick = Stopwatch.GetTimestamp(); + _lastTick = DateTime.UtcNow.Ticks; CreateTimersFromAssemblies(_lastTick); @@ -92,7 +92,7 @@ public void Tick() if (!_didInitialize || _timers.Count == 0) return; - var timestamp = Stopwatch.GetTimestamp(); + var timestamp = DateTime.UtcNow.Ticks; // Don't user foreach for performance reasons // ReSharper disable once ForCanBeConvertedToForeach