From 7556bf43a60e09024cb7644620392fada61812e0 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Fri, 13 Sep 2024 18:51:58 +0200 Subject: [PATCH] Fix RTT set before value is available --- src/network/connection.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/network/connection.cpp b/src/network/connection.cpp index 7f64e0466..9d0d57e23 100644 --- a/src/network/connection.cpp +++ b/src/network/connection.cpp @@ -995,13 +995,15 @@ bool UDPPeer::isTimedOut(float timeout, std::string &reason) void UDPPeer::reportRTT(float rtt) { - if (rtt < 0.0) { + if (rtt < 0) return; - } RTTStatistics(rtt,"rudp",MAX_RELIABLE_WINDOW_SIZE*10); // use this value to decide the resend timeout - float timeout = getStat(AVG_RTT) * RESEND_TIMEOUT_FACTOR; + const float rtt_stat = getStat(AVG_RTT); + if (rtt_stat < 0) + return; + float timeout = rtt_stat * RESEND_TIMEOUT_FACTOR; if (timeout < RESEND_TIMEOUT_MIN) timeout = RESEND_TIMEOUT_MIN; if (timeout > RESEND_TIMEOUT_MAX)