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

@ -70,9 +70,9 @@ namespace Server.Engines.Quests.Collector
{
if (m_Begin == DateTime.MaxValue)
{
m_Begin = DateTime.UtcNow;
m_Begin = Core.Now;
}
else if (DateTime.UtcNow - m_Begin > TimeSpan.FromSeconds(30.0))
else if (Core.Now - m_Begin > TimeSpan.FromSeconds(30.0))
{
Complete();
}

View file

@ -24,7 +24,7 @@ namespace Server.Engines.Quests
{
if (restartDelay < TimeSpan.MaxValue)
{
RestartTime = DateTime.UtcNow + restartDelay;
RestartTime = Core.Now + restartDelay;
}
else
{

View file

@ -473,7 +473,7 @@ namespace Server.Engines.Quests
{
var endTime = restartInfo.RestartTime;
if (DateTime.UtcNow < endTime)
if (Core.Now < endTime)
{
inRestartPeriod = true;
return false;

View file

@ -30,7 +30,7 @@ namespace Server.Engines.Quests.Naturalist
{
if (m_StudyState != StudyState.Inactive)
{
var time = DateTime.UtcNow - m_StudyBegin;
var time = Core.Now - m_StudyBegin;
if (time > TimeSpan.FromSeconds(30.0))
{
@ -84,7 +84,7 @@ namespace Server.Engines.Quests.Naturalist
if (nest != null)
{
m_CurrentNest = nest;
m_StudyBegin = DateTime.UtcNow;
m_StudyBegin = Core.Now;
if (m_StudiedNests.Contains(nest))
{