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:
parent
5de6edbeb8
commit
6c4308bce6
208 changed files with 660 additions and 793 deletions
|
|
@ -113,9 +113,9 @@ namespace Server.Items
|
|||
|
||||
public static int GetDelay(Mobile m)
|
||||
{
|
||||
if (m_Delay.TryGetValue(m, out var timer) && timer.Next > DateTime.UtcNow)
|
||||
if (m_Delay.TryGetValue(m, out var timer) && timer.Next > Core.Now)
|
||||
{
|
||||
return (int)(timer.Next - DateTime.UtcNow).TotalSeconds;
|
||||
return (int)(timer.Next - Core.Now).TotalSeconds;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
@ -185,7 +185,7 @@ namespace Server.Items
|
|||
MoveToWorld(loc, map);
|
||||
|
||||
From = from;
|
||||
m_End = DateTime.UtcNow + TimeSpan.FromSeconds(10);
|
||||
m_End = Core.Now + TimeSpan.FromSeconds(10);
|
||||
|
||||
SetDamage(min, max);
|
||||
|
||||
|
|
@ -292,7 +292,7 @@ namespace Server.Items
|
|||
return;
|
||||
}
|
||||
|
||||
if (DateTime.UtcNow > m_End)
|
||||
if (Core.Now > m_End)
|
||||
{
|
||||
m_Item.Delete();
|
||||
Stop();
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ namespace Server.Items
|
|||
continue;
|
||||
}
|
||||
|
||||
mon.Pacify(from, DateTime.UtcNow + TimeSpan.FromSeconds(5.0)); // TODO check
|
||||
mon.Pacify(from, Core.Now + TimeSpan.FromSeconds(5.0)); // TODO check
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -131,9 +131,9 @@ namespace Server.Items
|
|||
|
||||
public static int GetDelay(Mobile m)
|
||||
{
|
||||
if (m_Delay.TryGetValue(m, out var timer) && timer.Next > DateTime.UtcNow)
|
||||
if (m_Delay.TryGetValue(m, out var timer) && timer.Next > Core.Now)
|
||||
{
|
||||
return (int)(timer.Next - DateTime.UtcNow).TotalSeconds;
|
||||
return (int)(timer.Next - Core.Now).TotalSeconds;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -342,7 +342,7 @@ namespace Server.Items
|
|||
return;
|
||||
}
|
||||
|
||||
if (DateTime.UtcNow < NextUse)
|
||||
if (Core.Now < NextUse)
|
||||
{
|
||||
from.SendLocalizedMessage(502406); // This book needs time to recharge.
|
||||
return;
|
||||
|
|
@ -359,7 +359,7 @@ namespace Server.Items
|
|||
{
|
||||
if (!Core.SA)
|
||||
{
|
||||
NextUse = DateTime.UtcNow + UseDelay;
|
||||
NextUse = Core.Now + UseDelay;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue