Browse Source

Prevent zero round trip time

NX 7 years ago
parent
commit
6b6c327130
1 changed files with 5 additions and 1 deletions
  1. 5 1
      Source/Native/enet.h

+ 5 - 1
Source/Native/enet.h

@@ -2096,6 +2096,10 @@ extern "C" {
         peer->earliestTimeout = 0;
         peer->earliestTimeout = 0;
         roundTripTime = ENET_TIME_DIFFERENCE(host->serviceTime, receivedSentTime);
         roundTripTime = ENET_TIME_DIFFERENCE(host->serviceTime, receivedSentTime);
 
 
+        if (roundTripTime == 0) {
+            roundTripTime = 1;
+        }
+
         if (peer->smoothedRoundTripTime == 0) {
         if (peer->smoothedRoundTripTime == 0) {
             peer->smoothedRoundTripTime = (enet_uint32)((1 - ENET_SRTT_PARA_G) * ENET_SRTT_INITIAL + ENET_SRTT_PARA_G * roundTripTime);
             peer->smoothedRoundTripTime = (enet_uint32)((1 - ENET_SRTT_PARA_G) * ENET_SRTT_INITIAL + ENET_SRTT_PARA_G * roundTripTime);
         } else {
         } else {
@@ -5622,4 +5626,4 @@ extern "C" {
 }
 }
 #endif
 #endif
 #endif
 #endif
-#endif
+#endif