Fix colored name padding and allow IPv6 address to fit in output of

'status' command
This commit is contained in:
MAN-AT-ARMS 2014-02-22 20:47:18 -05:00
parent 71386beaac
commit 94e36c288c
1 changed files with 28 additions and 14 deletions

View File

@ -1141,6 +1141,25 @@ static void SV_ExceptDel_f(void)
SV_DelBanFromList(qtrue);
}
/*
** SV_Strlen -- skips color escape codes
*/
static int SV_Strlen( const char *str ) {
const char *s = str;
int count = 0;
while ( *s ) {
if ( Q_IsColorString( s ) ) {
s += 2;
} else {
count++;
s++;
}
}
return count;
}
/*
================
SV_Status_f
@ -1161,20 +1180,20 @@ static void SV_Status_f( void ) {
Com_Printf ("map: %s\n", sv_mapname->string );
Com_Printf ("num score ping name lastmsg address qport rate\n");
Com_Printf ("--- ----- ---- --------------- ------- --------------------- ----- -----\n");
Com_Printf ("cl score ping name address rate \n");
Com_Printf ("-- ----- ---- --------------- --------------------------------------- -----\n");
for (i=0,cl=svs.clients ; i < sv_maxclients->integer ; i++,cl++)
{
if (!cl->state)
continue;
Com_Printf ("%3i ", i);
Com_Printf ("%2i ", i);
ps = SV_GameClientNum( i );
Com_Printf ("%5i ", ps->persistant[PERS_SCORE]);
if (cl->state == CS_CONNECTED)
Com_Printf ("CNCT ");
Com_Printf ("CON ");
else if (cl->state == CS_ZOMBIE)
Com_Printf ("ZMBI ");
Com_Printf ("ZMB ");
else
{
ping = cl->ping < 9999 ? cl->ping : 9999;
@ -1183,10 +1202,7 @@ static void SV_Status_f( void ) {
Com_Printf ("%s", cl->name);
// TTimo adding a ^7 to reset the color
// NOTE: colored names in status breaks the padding (WONTFIX)
Com_Printf ("^7");
l = 14 - strlen(cl->name);
l = 16 - SV_Strlen(cl->name);
j = 0;
do
@ -1195,11 +1211,11 @@ static void SV_Status_f( void ) {
j++;
} while(j < l);
Com_Printf ("%7i ", svs.time - cl->lastPacketTime );
// TTimo adding a ^7 to reset the color
s = NET_AdrToString( cl->netchan.remoteAddress );
Com_Printf ("%s", s);
l = 22 - strlen(s);
Com_Printf ("^7%s", s);
l = 39 - strlen(s);
j = 0;
do
@ -1208,8 +1224,6 @@ static void SV_Status_f( void ) {
j++;
} while(j < l);
Com_Printf ("%5i", cl->netchan.qport);
Com_Printf (" %5i", cl->rate);
Com_Printf ("\n");