Skip to content

Commit 0071679

Browse files
committed
Display colored pings in the scoreboard and server list
This makes visual grepping easier.
1 parent 4770d34 commit 0071679

2 files changed

Lines changed: 30 additions & 5 deletions

File tree

‎fpsgame/fps.cpp‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2056,6 +2056,21 @@ namespace game
20562056
return false;
20572057
}
20582058

2059+
const char* pingcolor;
2060+
if(attr.length() >= 4) {
2061+
if(ping < 70) {
2062+
pingcolor = "\f0";
2063+
} else if(ping < 135) {
2064+
pingcolor = "\f2";
2065+
} else if(ping < 200) {
2066+
pingcolor = "\f6";
2067+
} else {
2068+
pingcolor = "\f3";
2069+
}
2070+
} else {
2071+
pingcolor = "";
2072+
}
2073+
20592074
if(attr.empty() || attr[0]!=PROTOCOL_VERSION)
20602075
{
20612076
switch(i)
@@ -2115,7 +2130,7 @@ namespace game
21152130
case 0:
21162131
{
21172132
const char *icon = attr.inrange(3) && np >= attr[3] ? "serverfull" : (attr.inrange(4) ? mastermodeicon(attr[4], "serverunk") : "serverunk");
2118-
if(g->buttonf("%d ", 0xFFFFDD, icon, ping)&G3D_UP) return true;
2133+
if(g->buttonf("%s%d ", 0xFFFFDD, icon, pingcolor, ping)&G3D_UP) return true;
21192134
break;
21202135
}
21212136

@@ -2349,4 +2364,3 @@ namespace game
23492364
execfile("auth.cfg", false);
23502365
}
23512366
}
2352-

‎fpsgame/scoreboard.cpp‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,20 @@ namespace game
454454
{
455455
fpsent *p = o->ownernum >= 0 ? getclient(o->ownernum) : o;
456456
if(!p) p = o;
457-
if(!showpj && p->state==CS_LAGGED) g.text("LAG", 0xFFFFDD);
458-
else g.textf("%d", 0xFFFFDD, NULL, p->ping);
457+
458+
const char *pingcolor;
459+
if (p->ping < 70) {
460+
pingcolor = "\f0";
461+
} else if (p->ping < 135) {
462+
pingcolor = "\f2";
463+
} else if (p->ping < 200) {
464+
pingcolor = "\f6";
465+
} else {
466+
pingcolor = "\f3";
467+
}
468+
469+
if(!showpj && p->state==CS_LAGGED) g.text("\f3LAG", 0xFFFFFF);
470+
else g.textf("%s%d", 0xFFFFFF, NULL, pingcolor, p->ping);
459471
});
460472
g.poplist();
461473
}
@@ -718,4 +730,3 @@ namespace game
718730
ICOMMAND(showplayerstats, "D", (int *down), showplayerstats(*down!=0));
719731

720732
}
721-

0 commit comments

Comments
 (0)