]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Calculate ping in the server list better.
authorcloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 25 May 2020 23:19:38 +0000 (23:19 +0000)
committercloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 25 May 2020 23:19:38 +0000 (23:19 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12580 d7cf8633-e32d-0410-b094-e92efae38249

netconn.c

index fc5c4d8cb86442e311905a6b454d8c443c6bb936..584b3279bc757170ea9beac795fa1d927d940aed 100755 (executable)
--- a/netconn.c
+++ b/netconn.c
@@ -1575,7 +1575,6 @@ int NetConn_IsLocalGame(void)
 static int NetConn_ClientParsePacket_ServerList_ProcessReply(const char *addressstring)
 {
        int n;
 static int NetConn_ClientParsePacket_ServerList_ProcessReply(const char *addressstring)
 {
        int n;
-       int pingtime;
        serverlist_entry_t *entry = NULL;
 
        // search the cache for this server and update it
        serverlist_entry_t *entry = NULL;
 
        // search the cache for this server and update it
@@ -1612,15 +1611,10 @@ static int NetConn_ClientParsePacket_ServerList_ProcessReply(const char *address
                ++serverlist_cachecount;
        }
        // if this is the first reply from this server, count it as having replied
                ++serverlist_cachecount;
        }
        // if this is the first reply from this server, count it as having replied
-       pingtime = (int)((realtime - entry->querytime) * 1000.0 + 0.5);
-       pingtime = bound(0, pingtime, 9999);
+       entry->info.ping = bound(0, (int)floor((realtime - entry->querytime) * 1000 + 0.5),9999);
        if (entry->query == SQS_REFRESHING) {
        if (entry->query == SQS_REFRESHING) {
-               entry->info.ping = pingtime;
                entry->query = SQS_QUERIED;
        } else {
                entry->query = SQS_QUERIED;
        } else {
-               // convert to unsigned to catch the -1
-               // I still dont like this but its better than the old 10000 magic ping number - as in easier to type and read :( [11/8/2007 Black]
-               entry->info.ping = min((unsigned) entry->info.ping, (unsigned) pingtime);
                serverreplycount++;
        }
        
                serverreplycount++;
        }