- pingtime = 9999;
- for (i = 0;i < HOSTCACHESIZE;i++)
- if (!LHNETADDRESS_Compare(peeraddress, &pingcache[i].peeraddress))
- pingtime = (int)(realtime - pingcache[i].senttime);
- pingtime = bound(0, pingtime, 9999);
- memset(&hostcache[n], 0, sizeof(hostcache[n]));
- // store the data the engine cares about (address and ping)
- strcpy(hostcache[n].cname, cname);
- hostcache[n].ping = pingtime;
- // build description strings for the things users care about
- snprintf(hostcache[n].line1, sizeof(hostcache[n].line1), "%5d%c%3u/%3u %-65.65s", (int)pingtime, c != NET_PROTOCOL_VERSION ? '*' : ' ', users, maxusers, name);
- snprintf(hostcache[n].line2, sizeof(hostcache[n].line2), "%-21.21s %-19.19s %-17.17s %-20.20s", cname, game, mod, map);
- // if ping is especially high, display it as such
- if (pingtime >= 300)
- {
- // orange numbers (lower block)
- for (i = 0;i < 5;i++)
- if (hostcache[n].line1[i] != ' ')
- hostcache[n].line1[i] += 128;
- }
- else if (pingtime >= 200)
- {
- // yellow numbers (in upper block)
- for (i = 0;i < 5;i++)
- if (hostcache[n].line1[i] != ' ')
- hostcache[n].line1[i] -= 30;
- }
- // if not in the slist menu we should print the server to console
- if (m_state != m_slist)
- Con_Printf("%s\n%s\n", hostcache[n].line1, hostcache[n].line2);
- // and finally, re-sort the list
- for (i = 0;i < hostCacheCount;i++)