From b4b01aa52d159efb5da7c9e9468c6271c55372bb Mon Sep 17 00:00:00 2001 From: lidgren Date: Thu, 23 Aug 2012 12:55:12 +0000 Subject: [PATCH] Fix for time issue 129; thanks to jujjyl --- Lidgren.Network/NetPeer.Internal.cs | 2 +- Lidgren.Network/NetTime.cs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Lidgren.Network/NetPeer.Internal.cs b/Lidgren.Network/NetPeer.Internal.cs index dbf449a..408a14a 100644 --- a/Lidgren.Network/NetPeer.Internal.cs +++ b/Lidgren.Network/NetPeer.Internal.cs @@ -270,7 +270,7 @@ namespace Lidgren.Network int maxCHBpS = 1250 - m_connections.Count; if (maxCHBpS < 250) maxCHBpS = 250; - if (delta > (1.0 / (double)maxCHBpS)) // max connection heartbeats/second max + if (delta > (1.0 / (double)maxCHBpS) || delta < 0.0) // max connection heartbeats/second max { m_frameCounter++; m_lastHeartbeat = dnow; diff --git a/Lidgren.Network/NetTime.cs b/Lidgren.Network/NetTime.cs index 494ab97..9e2f59d 100644 --- a/Lidgren.Network/NetTime.cs +++ b/Lidgren.Network/NetTime.cs @@ -40,10 +40,12 @@ namespace Lidgren.Network /// public static double Now { get { return (double)(Stopwatch.GetTimestamp() - s_timeInitialized) * s_dInvFreq; } } #else + private static readonly uint s_timeInitialized = (uint)Environment.TickCount; + /// /// Get number of seconds since the application started /// - public static double Now { get { return (double)Environment.TickCount / 1000.0; } } + public static double Now { get { return (double)((uint)Environment.TickCount - s_timeInitialized) / 1000.0; } } #endif ///