diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 6522a56e..c5cb0c70 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1375,8 +1375,7 @@ static boolean SV_SendServerConfig(INT32 node) for (i = 0; i < MAXPLAYERS; i++) { - if (i < 4) - netbuffer->u.servercfg.adminplayers[i] = (SINT8)adminplayers[i]; + netbuffer->u.servercfg.adminplayers[i] = (SINT8)adminplayers[i]; if (!playeringame[i]) continue; @@ -3224,6 +3223,10 @@ boolean Playing(void) boolean SV_SpawnServer(void) { + INT32 i; + for (i = 0; i < MAXPLAYERS; i++) + adminplayers[i] = -1; // Populate the entire adminplayers array with -1. + if (demoplayback) G_StopDemo(); // reset engine parameter if (metalplayback) @@ -3547,9 +3550,8 @@ static void HandlePacketFromAwayNode(SINT8 node) maketic = gametic = neededtic = (tic_t)LONG(netbuffer->u.servercfg.gametic); gametype = netbuffer->u.servercfg.gametype; modifiedgame = netbuffer->u.servercfg.modifiedgame; - for (j = 0; j < 4; j++) + for (j = 0; j < MAXPLAYERS; j++) adminplayers[j] = netbuffer->u.servercfg.adminplayers[j]; - j = 0; memcpy(server_context, netbuffer->u.servercfg.server_context, 8); } diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 8249f1f4..5fde8ade 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -290,7 +290,7 @@ typedef struct UINT8 gametype; UINT8 modifiedgame; - SINT8 adminplayers[4]; // Needs to be signed + SINT8 adminplayers[MAXPLAYERS]; // Needs to be signed char server_context[8]; // Unique context id, generated at server startup. @@ -329,7 +329,7 @@ typedef struct UINT8 cheatsenabled; UINT8 isdedicated; UINT8 fileneedednum; - SINT8 adminplayers[4]; + SINT8 adminplayers[MAXPLAYERS]; tic_t time; tic_t leveltime; char servername[MAXSERVERNAME]; diff --git a/src/d_netcmd.c b/src/d_netcmd.c index ca24a998..4eff3242 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -145,7 +145,9 @@ static void Command_Changepassword_f(void); static void Command_Login_f(void); static void Got_Login(UINT8 **cp, INT32 playernum); static void Got_Verification(UINT8 **cp, INT32 playernum); +static void Got_Removal(UINT8 **cp, INT32 playernum); static void Command_Verify_f(void); +static void Command_RemoveAdmin_f(void); static void Command_MotD_f(void); static void Got_MotD_f(UINT8 **cp, INT32 playernum); @@ -409,7 +411,7 @@ consvar_t cv_sleep = {"cpusleep", "-1", CV_SAVE, sleeping_cons_t, NULL, -1, NULL INT16 gametype = GT_RACE; // SRB2kart boolean splitscreen = false; boolean circuitmap = true; // SRB2kart -INT32 adminplayers[] = { -1, -1, -1, -1 }; // Hardcoded to four admins for now. +INT32 adminplayers[MAXPLAYERS]; /// \warning Keep this up-to-date if you add/remove/rename net text commands const char *netxcmdnames[MAXNETXCMD - 1] = @@ -471,8 +473,10 @@ void D_RegisterServerCommands(void) COM_AddCommand("password", Command_Changepassword_f); RegisterNetXCmd(XD_LOGIN, Got_Login); COM_AddCommand("login", Command_Login_f); // useful in dedicated to kick off remote admin - COM_AddCommand("verify", Command_Verify_f); + COM_AddCommand("giveadmin", Command_Verify_f); RegisterNetXCmd(XD_VERIFIED, Got_Verification); + COM_AddCommand("removeadmin", Command_RemoveAdmin_f); + RegisterNetXCmd(XD_DEMOTED, Got_Removal); COM_AddCommand("motd", Command_MotD_f); RegisterNetXCmd(XD_SETMOTD, Got_MotD_f); // For remote admin @@ -2784,7 +2788,7 @@ static void Got_Login(UINT8 **cp, INT32 playernum) if (!memcmp(sentmd5, finalmd5, 16)) { CONS_Printf(M_GetText("%s passed authentication.\n"), player_names[playernum]); - COM_BufInsertText(va("verify %d\n", playernum)); // do this immediately + COM_BufInsertText(va("giveadmin %d\n", playernum)); // do this immediately } else CONS_Printf(M_GetText("Password from %s failed.\n"), player_names[playernum]); @@ -2794,7 +2798,7 @@ static void Got_Login(UINT8 **cp, INT32 playernum) boolean IsPlayerAdmin(INT32 playernum) { INT32 i; - for (i = 0; i < 4; i++) + for (i = 0; i < MAXPLAYERS; i++) if (playernum == adminplayers[i]) return true; @@ -2804,7 +2808,7 @@ boolean IsPlayerAdmin(INT32 playernum) void SetAdminPlayer(INT32 playernum) { INT32 i; - for (i = 0; i < 4; i++) + for (i = 0; i < MAXPLAYERS; i++) { if (playernum == adminplayers[i]) return; // Player is already admin @@ -2815,25 +2819,25 @@ void SetAdminPlayer(INT32 playernum) break; // End the loop now. If it keeps going, the same player might get assigned to two slots. } - if (i == 3 && adminplayers[i] != -1) // End of the loop and all slots are full + /*if (i == 3 && adminplayers[i] != -1) // End of the loop and all slots are full { adminplayers[0] = playernum; // Overwrite the first slot break; - } + }*/ } } void ClearAdminPlayers(void) { INT32 i; - for (i = 0; i < 4; i++) + for (i = 0; i < MAXPLAYERS; i++) adminplayers[i] = -1; } void RemoveAdminPlayer(INT32 playernum) { INT32 i; - for (i = 0; i < 4; i++) + for (i = 0; i < MAXPLAYERS; i++) if (playernum == adminplayers[i]) adminplayers[i] = -1; } @@ -2852,7 +2856,7 @@ static void Command_Verify_f(void) if (COM_Argc() != 2) { - CONS_Printf(M_GetText("verify : give admin privileges to a node\n")); + CONS_Printf(M_GetText("giveadmin : give admin privileges to a node\n")); return; } @@ -2894,6 +2898,62 @@ static void Got_Verification(UINT8 **cp, INT32 playernum) CONS_Printf(M_GetText("You are now a server administrator.\n")); } +static void Command_RemoveAdmin_f(void) +{ + XBOXSTATIC char buf[8]; // Should be plenty + char *temp; + INT32 playernum; + + if (client) + { + CONS_Printf(M_GetText("Only the server can use this.\n")); + return; + } + + if (COM_Argc() != 2) + { + CONS_Printf(M_GetText("removeadmin : remove admin privileges from a node\n")); + return; + } + + strlcpy(buf, COM_Argv(1), sizeof(buf)); + + playernum = atoi(buf); + + temp = buf; + + WRITEUINT8(temp, playernum); + + if (playeringame[playernum]) + SendNetXCmd(XD_DEMOTED, buf, 1); +} + +static void Got_Removal(UINT8 **cp, INT32 playernum) +{ + INT16 num = READUINT8(*cp); + + if (playernum != serverplayer) // it's not from the server (hacker or bug) + { + CONS_Alert(CONS_WARNING, M_GetText("Illegal demotion received from %s (serverplayer is %s)\n"), player_names[playernum], player_names[serverplayer]); + if (server) + { + XBOXSTATIC UINT8 buf[2]; + + buf[0] = (UINT8)playernum; + buf[1] = KICK_MSG_CON_FAIL; + SendNetXCmd(XD_KICK, &buf, 2); + } + return; + } + + RemoveAdminPlayer(num); + + if (num != consoleplayer) + return; + + CONS_Printf(M_GetText("You are no longer a server administrator.\n")); +} + static void Command_MotD_f(void) { size_t i, j; @@ -3236,7 +3296,7 @@ static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum) CONS_Printf("%s",message); - for (j = 0; j < 4; j++) + for (j = 0; j < MAXPLAYERS; j++) if (adminplayers[j]) COM_BufAddText(va("sayto %d %s", adminplayers[j], message)); diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 68dc7ed2..d5287ddf 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -176,9 +176,10 @@ typedef enum XD_DELFILE, // 18 XD_SETMOTD, // 19 XD_SUICIDE, // 20 + XD_DEMOTED, // 21 #ifdef HAVE_BLUA - XD_LUACMD, // 21 - XD_LUAVAR, // 22 + XD_LUACMD, // 22 + XD_LUAVAR, // 23 #endif MAXNETXCMD } netxcmd_t; diff --git a/src/doomstat.h b/src/doomstat.h index 9d4fda5e..11560259 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -494,7 +494,7 @@ extern consvar_t cv_forceskin; // force clients to use the server's skin extern consvar_t cv_downloading; // allow clients to downloading WADs. extern ticcmd_t netcmds[BACKUPTICS][MAXPLAYERS]; extern INT32 serverplayer; -extern INT32 adminplayers[4]; +extern INT32 adminplayers[MAXPLAYERS]; /// \note put these in d_clisrv outright? diff --git a/src/sdl/Srb2SDL-vc10.vcxproj b/src/sdl/Srb2SDL-vc10.vcxproj index 82019264..b6c42f3f 100644 --- a/src/sdl/Srb2SDL-vc10.vcxproj +++ b/src/sdl/Srb2SDL-vc10.vcxproj @@ -23,8 +23,8 @@ {61BA7D3C-F77D-4D31-B718-1177FE482CF2} Win32Proj Srb2SDL + srb2kart 8.1 - Srb2Win @@ -160,6 +160,7 @@ + @@ -294,6 +295,7 @@ true + diff --git a/src/sdl/Srb2SDL-vc10.vcxproj.filters b/src/sdl/Srb2SDL-vc10.vcxproj.filters index d04007dd..f3ac2397 100644 --- a/src/sdl/Srb2SDL-vc10.vcxproj.filters +++ b/src/sdl/Srb2SDL-vc10.vcxproj.filters @@ -444,6 +444,9 @@ SDLApp + + D_Doom + @@ -876,6 +879,9 @@ SDLApp + + D_Doom +