Skip to content

Commit

Permalink
fix(ecs): Use DateTime.UtcNow.Ticks instead of Stopwatch.GetTimestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
MrDave1999 committed Nov 9, 2024
1 parent c09a54e commit 167acf2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/SampSharp.Entities/Timers/TimerReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ internal TimerReference(TimerInfo info, object target, MethodInfo method)
}

/// <summary>Gets the time span until the next tick of this timer.</summary>
public TimeSpan NextTick => new(Info.NextTick - Stopwatch.GetTimestamp());
public TimeSpan NextTick => new(Info.NextTick - DateTime.UtcNow.Ticks);

internal TimerInfo Info { get; set; }

Expand Down
6 changes: 3 additions & 3 deletions src/SampSharp.Entities/Timers/TimerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public TimerReference Start(Action<IServiceProvider, TimerReference> 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);
Expand All @@ -79,7 +79,7 @@ public TimerReference Start(Action<IServiceProvider, TimerReference> action, Tim
[Event]
internal void OnGameModeInit()
{
_lastTick = Stopwatch.GetTimestamp();
_lastTick = DateTime.UtcNow.Ticks;

CreateTimersFromAssemblies(_lastTick);

Expand All @@ -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
Expand Down

0 comments on commit 167acf2

Please sign in to comment.