fix: Reset Network Time whenever server starts (#2713)

This commit is contained in:
MrGadget 2021-05-15 02:45:26 -04:00 committed by GitHub
parent d33965c800
commit 28f186a76f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 0 deletions

View File

@ -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();
}

View File

@ -36,6 +36,7 @@ static NetworkTime()
public static void Reset()
{
stopwatch.Restart();
_rtt = new ExponentialMovingAverage(PingWindowSize);
_offset = new ExponentialMovingAverage(PingWindowSize);
offsetMin = double.MinValue;