Display RTT (round trip time, ping) on client status text
authorPerttu Ahola <celeron55@gmail.com>
Mon, 17 Oct 2011 14:18:50 +0000 (17:18 +0300)
committerPerttu Ahola <celeron55@gmail.com>
Mon, 17 Oct 2011 14:18:50 +0000 (17:18 +0300)
src/client.cpp
src/client.h
src/game.cpp

index 75168c6855ad1c16879d5cc45a62e77224c90eda..816ab39caeecb2088ada746e4389d7d70dd3371b 100644 (file)
@@ -2166,4 +2166,11 @@ ClientEvent Client::getClientEvent()
        return m_client_event_queue.pop_front();
 }
 
+float Client::getRTT(void)
+{
+       con::Peer *peer = m_con.GetPeerNoEx(PEER_ID_SERVER);
+       if(!peer)
+               return 0.0;
+       return peer->avg_rtt;
+}
 
index 07ac930c912b714d0f590ce03cbb256be8bdb434..52dd66ca2c6d2b1cd369d0bde77f80a8774b070c 100644 (file)
@@ -301,6 +301,8 @@ public:
                return m_access_denied_reason;
        }
 
+       float getRTT(void);
+
 private:
        
        // Virtual methods from con::PeerHandler
index 78962c18c545d19dafcb24680208fe21cb838c96..4d9b0c3f6325d044787c8c3e82bf302af60b6d86 100644 (file)
@@ -2025,14 +2025,15 @@ void the_game(
                                        "(% .1f, % .1f, % .1f)"
                                        " (% .3f < btime_jitter < % .3f"
                                        ", dtime_jitter = % .1f %%"
-                                       ", v_range = %.1f)",
+                                       ", v_range = %.1f, RTT = %.3f)",
                                        player_position.X/BS,
                                        player_position.Y/BS,
                                        player_position.Z/BS,
                                        busytime_jitter1_min_sample,
                                        busytime_jitter1_max_sample,
                                        dtime_jitter1_max_fraction * 100.0,
-                                       draw_control.wanted_range
+                                       draw_control.wanted_range,
+                                       client.getRTT()
                                        );
 
                        guitext2->setText(narrow_to_wide(temptext).c_str());