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
|
|
@ -20,7 +20,7 @@ namespace UOContent.Tests
|
|||
).Compile();
|
||||
|
||||
var ns = PacketTestUtilities.CreateTestNetState();
|
||||
BuffInfo.SendAddBuffPacket(ns, mob, iconID, titleCliloc, secondaryCliloc, args, timeSpan);
|
||||
BuffInfo.SendAddBuffPacket(ns, mob, iconID, titleCliloc, secondaryCliloc, args, (int)timeSpan.TotalMilliseconds);
|
||||
|
||||
var result = ns.SendPipe.Reader.TryRead();
|
||||
AssertThat.Equal(result.Buffer[0].AsSpan(0), expected);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,9 @@ namespace Server.Network
|
|||
info.TitleCliloc,
|
||||
info.SecondaryCliloc,
|
||||
info.Args,
|
||||
info.TimeStart != DateTime.MinValue ? info.TimeStart + info.TimeLength - DateTime.UtcNow : TimeSpan.Zero
|
||||
info.TimeStart != 0 ?
|
||||
TimeSpan.FromMilliseconds(info.TimeStart + (long)info.TimeLength.TotalMilliseconds - Core.TickCount) :
|
||||
TimeSpan.Zero
|
||||
)
|
||||
{
|
||||
}
|
||||
|
|
@ -37,12 +39,7 @@ namespace Server.Network
|
|||
|
||||
Stream.Fill(4);
|
||||
|
||||
if (length < TimeSpan.Zero)
|
||||
{
|
||||
length = TimeSpan.Zero;
|
||||
}
|
||||
|
||||
Stream.Write((short)length.TotalSeconds); // Time in seconds
|
||||
Stream.Write((short)Math.Max(length.TotalSeconds, 0)); // Time in seconds
|
||||
|
||||
Stream.Fill(3);
|
||||
Stream.Write(titleCliloc);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue