diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 91ed84ea1..327927239 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -212,6 +212,8 @@ static textcmdtic_t *textcmds[TEXTCMD_HASH_SIZE] = {NULL}; consvar_t cv_showjoinaddress = CVAR_INIT ("showjoinaddress", "Off", CV_SAVE, CV_OnOff, NULL); +consvar_t cv_shownodeip = CVAR_INIT ("showipinnodelist", "Off", CV_SAVE, CV_OnOff, NULL); + static CV_PossibleValue_t playbackspeed_cons_t[] = {{1, "MIN"}, {10, "MAX"}, {0, NULL}}; consvar_t cv_playbackspeed = CVAR_INIT ("playbackspeed", "1", 0, playbackspeed_cons_t, NULL); @@ -2918,7 +2920,7 @@ static void Command_Nodes(void) if (playernode[i] != UINT8_MAX) { CONS_Printf(" - node %.2d", playernode[i]); - if (I_GetNodeAddress && (address = I_GetNodeAddress(playernode[i])) != NULL) + if ((I_GetNodeAddress && (address = I_GetNodeAddress(playernode[i])) != NULL) && (cv_shownodeip.value)) CONS_Printf(" - %s", address); } @@ -2933,6 +2935,102 @@ static void Command_Nodes(void) } } +static void Command_Listplayers(void) +{ + const char *address; + int width = 0; + + boolean admin; + boolean spectator; + + /* + Mode of player status for an individual player (admin, spectator). + 1 for admin + 2 for spectator + 4 for both + */ + int mode = 0; + + INT32 totalplayers = 0; + + const char *cc; + char pcc[2]; + + INT32 i; + int n; + + for (i = 0; i < MAXPLAYERS; ++i) + if (playeringame[i]) + { + n = strlen(player_names[i]); + if (n > width) + width = n; + + if (mode != 7) + { + admin = IsPlayerAdmin(i); + spectator = players[i].spectator; + + if (admin) + mode |= 1; + if (spectator) + mode |= 2; + if (admin && spectator) + mode |= 4; + } + } + + for (i = 0; i < MAXPLAYERS; ++i) + if (playeringame[i]) + { + admin = IsPlayerAdmin(i); + spectator = players[i].spectator; + + if (admin) + cc = "\x85";/* red */ + else if (spectator) + cc = "\x86";/* gray */ + else + cc = ""; + + UINT16 chatcolor = skincolors[players[i].skincolor].chatcolor; + + if (chatcolor > V_TANMAP) + { + sprintf(pcc, "%c", '\x80'); + } + else + { + sprintf(pcc, "%c", '\x80' + (chatcolor >> V_CHARCOLORSHIFT)); + } + + CONS_Printf("%.2d: ""%s""%-*s""\x80", i, pcc,width, player_names[i]); + + if ((I_GetNodeAddress && (address = I_GetNodeAddress(playernode[i])) != NULL) && (cv_shownodeip.value)) + CONS_Printf(" -- %s", address); + else/* print spacer */ + { + /* ...but not if there's a crammed status and were admin */ + if (mode != 7 || !admin) + CONS_Printf(" -- ");/* -- self */ + } + + if (admin) + CONS_Printf(M_GetText("%s"" (admin)"),cc); + if (spectator) + CONS_Printf(M_GetText("%s"" (spectator)"),cc); + + CONS_Printf("\n"); + + totalplayers++; + } + + if (totalplayers == 1) + CONS_Printf("\nThere is 1 player in the game.\n"); + else + CONS_Printf("\nThere are %d players in the game.\n", totalplayers); +} + static void Command_Ban(void) { if (COM_Argc() < 2) @@ -3542,6 +3640,7 @@ void D_ClientServerInit(void) COM_AddCommand("reloadbans", Command_ReloadBan); COM_AddCommand("connect", Command_connect); COM_AddCommand("nodes", Command_Nodes); + COM_AddCommand("listplayers", Command_Listplayers); #ifdef HAVE_CURL COM_AddCommand("set_http_login", Command_set_http_login); COM_AddCommand("list_http_logins", Command_list_http_logins); diff --git a/src/d_clisrv.h b/src/d_clisrv.h index d8f51c061..2fb831142 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -437,6 +437,7 @@ extern consvar_t cv_httpsource; extern consvar_t cv_kicktime; extern consvar_t cv_showjoinaddress; +extern consvar_t cv_shownodeip; extern consvar_t cv_playbackspeed; extern consvar_t cv_connectawaittime; diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 40f807536..9fb5160f1 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1132,6 +1132,7 @@ void D_RegisterServerCommands(void) CV_RegisterVar(&cv_joinnextround); #endif CV_RegisterVar(&cv_showjoinaddress); + CV_RegisterVar(&cv_shownodeip); CV_RegisterVar(&cv_blamecfail); COM_AddCommand("ping", Command_Ping_f);