diff options
author | Perttu Ahola <celeron55@gmail.com> | 2011-10-17 17:18:50 +0300 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2011-10-17 17:18:50 +0300 |
commit | 558a133044ac638dafb7b0e9452a4d7e435177bf (patch) | |
tree | 32b7a6518f3e11d688e9ea723897ddc366ef532e /src | |
parent | 5037efdea9bd3fc86c1df5200e71741c98627b00 (diff) | |
download | minetest-558a133044ac638dafb7b0e9452a4d7e435177bf.tar.gz minetest-558a133044ac638dafb7b0e9452a4d7e435177bf.tar.bz2 minetest-558a133044ac638dafb7b0e9452a4d7e435177bf.zip |
Display RTT (round trip time, ping) on client status text
Diffstat (limited to 'src')
-rw-r--r-- | src/client.cpp | 7 | ||||
-rw-r--r-- | src/client.h | 2 | ||||
-rw-r--r-- | src/game.cpp | 5 |
3 files changed, 12 insertions, 2 deletions
diff --git a/src/client.cpp b/src/client.cpp index 75168c685..816ab39ca 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -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; +} diff --git a/src/client.h b/src/client.h index 07ac930c9..52dd66ca2 100644 --- a/src/client.h +++ b/src/client.h @@ -301,6 +301,8 @@ public: return m_access_denied_reason; } + float getRTT(void); + private: // Virtual methods from con::PeerHandler diff --git a/src/game.cpp b/src/game.cpp index 78962c18c..4d9b0c3f6 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -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()); |