From 0071679286aa1f767fae10fc0fff5c1fe2e5168c Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Sat, 28 Dec 2019 16:26:09 +0100 Subject: [PATCH] Display colored pings in the scoreboard and server list This makes visual grepping easier. --- fpsgame/fps.cpp | 18 ++++++++++++++++-- fpsgame/scoreboard.cpp | 17 ++++++++++++++--- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/fpsgame/fps.cpp b/fpsgame/fps.cpp index 7fe7940..bc4eb08 100644 --- a/fpsgame/fps.cpp +++ b/fpsgame/fps.cpp @@ -2056,6 +2056,21 @@ namespace game return false; } + const char* pingcolor; + if(attr.length() >= 4) { + if(ping < 70) { + pingcolor = "\f0"; + } else if(ping < 135) { + pingcolor = "\f2"; + } else if(ping < 200) { + pingcolor = "\f6"; + } else { + pingcolor = "\f3"; + } + } else { + pingcolor = ""; + } + if(attr.empty() || attr[0]!=PROTOCOL_VERSION) { switch(i) @@ -2115,7 +2130,7 @@ namespace game case 0: { const char *icon = attr.inrange(3) && np >= attr[3] ? "serverfull" : (attr.inrange(4) ? mastermodeicon(attr[4], "serverunk") : "serverunk"); - if(g->buttonf("%d ", 0xFFFFDD, icon, ping)&G3D_UP) return true; + if(g->buttonf("%s%d ", 0xFFFFDD, icon, pingcolor, ping)&G3D_UP) return true; break; } @@ -2349,4 +2364,3 @@ namespace game execfile("auth.cfg", false); } } - diff --git a/fpsgame/scoreboard.cpp b/fpsgame/scoreboard.cpp index 960f7c2..24204ff 100644 --- a/fpsgame/scoreboard.cpp +++ b/fpsgame/scoreboard.cpp @@ -454,8 +454,20 @@ namespace game { fpsent *p = o->ownernum >= 0 ? getclient(o->ownernum) : o; if(!p) p = o; - if(!showpj && p->state==CS_LAGGED) g.text("LAG", 0xFFFFDD); - else g.textf("%d", 0xFFFFDD, NULL, p->ping); + + const char *pingcolor; + if (p->ping < 70) { + pingcolor = "\f0"; + } else if (p->ping < 135) { + pingcolor = "\f2"; + } else if (p->ping < 200) { + pingcolor = "\f6"; + } else { + pingcolor = "\f3"; + } + + if(!showpj && p->state==CS_LAGGED) g.text("\f3LAG", 0xFFFFFF); + else g.textf("%s%d", 0xFFFFFF, NULL, pingcolor, p->ping); }); g.poplist(); } @@ -718,4 +730,3 @@ namespace game ICOMMAND(showplayerstats, "D", (int *down), showplayerstats(*down!=0)); } -