From 28f186a76fa5030b8970bdf22ef22119950bd350 Mon Sep 17 00:00:00 2001 From: MrGadget <9826063+MrGadget1024@users.noreply.github.com> Date: Sat, 15 May 2021 02:45:26 -0400 Subject: [PATCH] fix: Reset Network Time whenever server starts (#2713) --- Assets/Mirror/Runtime/NetworkServer.cs | 3 +++ Assets/Mirror/Runtime/NetworkTime.cs | 1 + 2 files changed, 4 insertions(+) diff --git a/Assets/Mirror/Runtime/NetworkServer.cs b/Assets/Mirror/Runtime/NetworkServer.cs index 3ea31de5c..2b6d2ea95 100644 --- a/Assets/Mirror/Runtime/NetworkServer.cs +++ b/Assets/Mirror/Runtime/NetworkServer.cs @@ -69,6 +69,9 @@ static void Initialize() //Make sure connections are cleared in case any old connections references exist from previous sessions connections.Clear(); + // reset NetworkTime + NetworkTime.Reset(); + Debug.Assert(Transport.activeTransport != null, "There was no active transport when calling NetworkServer.Listen, If you are calling Listen manually then make sure to set 'Transport.activeTransport' first"); AddTransportHandlers(); } diff --git a/Assets/Mirror/Runtime/NetworkTime.cs b/Assets/Mirror/Runtime/NetworkTime.cs index 5e8a9bc80..91547948d 100644 --- a/Assets/Mirror/Runtime/NetworkTime.cs +++ b/Assets/Mirror/Runtime/NetworkTime.cs @@ -36,6 +36,7 @@ static NetworkTime() public static void Reset() { + stopwatch.Restart(); _rtt = new ExponentialMovingAverage(PingWindowSize); _offset = new ExponentialMovingAverage(PingWindowSize); offsetMin = double.MinValue;