fix(core): Caches DateTime.NowUtc (#548)

- [X] Caches DateTime.NowUtc on the game loop (not other threads)
- [X] Replaces all locations where it makes sense
- [X] Adds Min/Max for `IComparable` (TimeSpan, DateTimes, etc)

Closes #261
This commit is contained in:
Kamron Batman 2021-03-13 01:32:04 -08:00 committed by GitHub
parent 5de6edbeb8
commit 6c4308bce6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
208 changed files with 660 additions and 793 deletions

View file

@ -185,7 +185,7 @@ namespace Server.Gumps
AddLabel(150, 270, LabelHue, Core.ScriptItems.ToString());
AddLabel(20, 290, LabelHue, "Uptime:");
AddLabel(150, 290, LabelHue, FormatTimeSpan(DateTime.UtcNow - Clock.ServerStart));
AddLabel(150, 290, LabelHue, FormatTimeSpan(Core.Now - Clock.ServerStart));
AddLabel(20, 310, LabelHue, "Memory:");
AddLabel(150, 310, LabelHue, FormatByteAmount(GC.GetTotalMemory(false)));
@ -902,17 +902,7 @@ namespace Server.Gumps
}
else
{
var remaining = DateTime.UtcNow - banTime;
if (remaining < TimeSpan.Zero)
{
remaining = TimeSpan.Zero;
}
else if (remaining > banDuration)
{
remaining = banDuration;
}
var remaining = (Core.Now - banTime).Clamp(TimeSpan.Zero, banDuration);
var remMinutes = remaining.TotalMinutes;
var totMinutes = banDuration.TotalMinutes;