From 1224203c198060b00650190e5a00cdbdc94d0c84 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 23 Sep 2022 21:59:26 +0300 Subject: [PATCH 29/29] get_ping_time_text(): Skip any negative time Never show a negative time as a real ping time. See osdn #45500 Signed-off-by: Marko Lindqvist --- client/text.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/client/text.c b/client/text.c index e28ad7fe42..84f6d2489d 100644 --- a/client/text.c +++ b/client/text.c @@ -1601,8 +1601,8 @@ const char *format_duration(int duration) } /************************************************************************//** - Return text giving the ping time for the player. This is generally used - in the playerdlg. This should only be used in playerdlg_common.c. + Return text giving the ping time for the player. This is generally used + in the playerdlg. This should only be used in playerdlg_common.c. ****************************************************************************/ const char *get_ping_time_text(const struct player *pplayer) { @@ -1612,13 +1612,13 @@ const char *get_ping_time_text(const struct player *pplayer) conn_list_iterate(pplayer->connections, pconn) { if (!pconn->observer - /* Certainly not needed, but safer. */ - && 0 == strcmp(pconn->username, pplayer->username)) { - if (pconn->ping_time != -1) { - double ping_time_in_ms = 1000 * pconn->ping_time; + /* Certainly not needed, but safer. */ + && 0 == strcmp(pconn->username, pplayer->username)) { + if (pconn->ping_time >= 0) { + double ping_time_in_ms = 1000 * pconn->ping_time; - astr_add(&str, _("%6d.%02d ms"), (int) ping_time_in_ms, - ((int) (ping_time_in_ms * 100.0)) % 100); + astr_add(&str, _("%6d.%02d ms"), (int) ping_time_in_ms, + ((int) (ping_time_in_ms * 100.0)) % 100); } break; } -- 2.35.1