Merge pull request #55 from MAN-AT-ARMS/status_command

Fix colored name padding and allow IPv6 address to fit in output of 'status' command
This commit is contained in:
Tim Angus 2014-03-24 14:12:06 +00:00
commit 2393c8f44f

View file

@ -1141,6 +1141,25 @@ static void SV_ExceptDel_f(void)
SV_DelBanFromList(qtrue); 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 SV_Status_f
@ -1161,20 +1180,20 @@ static void SV_Status_f( void ) {
Com_Printf ("map: %s\n", sv_mapname->string ); Com_Printf ("map: %s\n", sv_mapname->string );
Com_Printf ("num score ping name lastmsg address qport rate\n"); Com_Printf ("cl score ping name address rate \n");
Com_Printf ("--- ----- ---- --------------- ------- --------------------- ----- -----\n"); Com_Printf ("-- ----- ---- --------------- --------------------------------------- -----\n");
for (i=0,cl=svs.clients ; i < sv_maxclients->integer ; i++,cl++) for (i=0,cl=svs.clients ; i < sv_maxclients->integer ; i++,cl++)
{ {
if (!cl->state) if (!cl->state)
continue; continue;
Com_Printf ("%3i ", i); Com_Printf ("%2i ", i);
ps = SV_GameClientNum( i ); ps = SV_GameClientNum( i );
Com_Printf ("%5i ", ps->persistant[PERS_SCORE]); Com_Printf ("%5i ", ps->persistant[PERS_SCORE]);
if (cl->state == CS_CONNECTED) if (cl->state == CS_CONNECTED)
Com_Printf ("CNCT "); Com_Printf ("CON ");
else if (cl->state == CS_ZOMBIE) else if (cl->state == CS_ZOMBIE)
Com_Printf ("ZMBI "); Com_Printf ("ZMB ");
else else
{ {
ping = cl->ping < 9999 ? cl->ping : 9999; ping = cl->ping < 9999 ? cl->ping : 9999;
@ -1183,23 +1202,20 @@ static void SV_Status_f( void ) {
Com_Printf ("%s", cl->name); Com_Printf ("%s", cl->name);
l = 16 - SV_Strlen(cl->name);
j = 0;
do
{
Com_Printf (" ");
j++;
} while(j < l);
// TTimo adding a ^7 to reset the color // 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);
j = 0;
do
{
Com_Printf (" ");
j++;
} while(j < l);
Com_Printf ("%7i ", svs.time - cl->lastPacketTime );
s = NET_AdrToString( cl->netchan.remoteAddress ); s = NET_AdrToString( cl->netchan.remoteAddress );
Com_Printf ("%s", s); Com_Printf ("^7%s", s);
l = 22 - strlen(s); l = 39 - strlen(s);
j = 0; j = 0;
do do
@ -1208,8 +1224,6 @@ static void SV_Status_f( void ) {
j++; j++;
} while(j < l); } while(j < l);
Com_Printf ("%5i", cl->netchan.qport);
Com_Printf (" %5i", cl->rate); Com_Printf (" %5i", cl->rate);
Com_Printf ("\n"); Com_Printf ("\n");