fix: Fixes TimeSpan rounding issues (#1610)

### Summary

TLDR - .NET Framework rounded TimeSpan (and some DateTime) methods to the nearest millisecond. This was actually _expected_ accidentally for parts of RunUO.

We are aiming to fix this and clean up some other bad assumptions.

Closes #1604
This commit is contained in:
Kamron Batman 2023-11-22 18:03:56 -08:00 • committed by GitHub
parent 98727d13b3
commit 331f24cb71
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 91 additions and 87 deletions

View file

@ -162,7 +162,7 @@ namespace Server
}
var hasArgs = args != null;
var length = hasArgs ? args.ToString().Length * 2 + 52 : 46;
var length = hasArgs ? args.ToString()!.Length * 2 + 52 : 46;
var writer = new SpanWriter(stackalloc byte[length]);
writer.Write((byte)0xDF); // Packet ID
writer.Write((ushort)length);
@ -174,6 +174,8 @@ namespace Server
writer.Write((short)iconID);
writer.Write((short)0x1); // command (0 = remove, 1 = add, 2 = data)
writer.Write(0);
// Truncate to whole seconds - The packet should be delayed by the partial seconds and then sent "on the second"
writer.Write((short)(ticks / 1000));
writer.Clear(3);
writer.Write(titleCliloc);

View file

@ -181,7 +181,7 @@ namespace Server.Misc
if (shouldKick)
{
state.Mobile.SendMessage(0x22, $"You will be disconnected in {KickDelay.TotalSeconds} seconds.");
state.Mobile.SendMessage(0x22, $"You will be disconnected in {KickDelay.TotalSeconds:F0} seconds.");
Timer.StartTimer(KickDelay, () => OnKick(state));
return;
}