mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-11-17 02:01:15 +00:00
Remove hardcoded limit on admins
This commit is contained in:
parent
854e93cdc7
commit
4714e8d179
7 changed files with 92 additions and 21 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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 <node>: give admin privileges to a node\n"));
|
||||
CONS_Printf(M_GetText("giveadmin <node>: 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 <node>: 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));
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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?
|
||||
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
<ProjectGuid>{61BA7D3C-F77D-4D31-B718-1177FE482CF2}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>Srb2SDL</RootNamespace>
|
||||
<ProjectName>srb2kart</ProjectName>
|
||||
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
|
||||
<ProjectName>Srb2Win</ProjectName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup>
|
||||
|
@ -160,6 +160,7 @@
|
|||
<ClInclude Include="..\i_tcp.h" />
|
||||
<ClInclude Include="..\i_video.h" />
|
||||
<ClInclude Include="..\keys.h" />
|
||||
<ClInclude Include="..\k_kart.h" />
|
||||
<ClInclude Include="..\lua_hook.h" />
|
||||
<ClInclude Include="..\lua_hud.h" />
|
||||
<ClInclude Include="..\lua_libs.h" />
|
||||
|
@ -294,6 +295,7 @@
|
|||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\i_tcp.c" />
|
||||
<ClCompile Include="..\k_kart.c" />
|
||||
<ClCompile Include="..\lua_baselib.c" />
|
||||
<ClCompile Include="..\lua_consolelib.c" />
|
||||
<ClCompile Include="..\lua_hooklib.c" />
|
||||
|
|
|
@ -444,6 +444,9 @@
|
|||
<ClInclude Include="sdlmain.h">
|
||||
<Filter>SDLApp</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\k_kart.h">
|
||||
<Filter>D_Doom</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="..\tmap.nas">
|
||||
|
@ -876,6 +879,9 @@
|
|||
<ClCompile Include="SDL_main\SDL_windows_main.c">
|
||||
<Filter>SDLApp</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\k_kart.c">
|
||||
<Filter>D_Doom</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="Srb2SDL.ico">
|
||||
|
|
Loading…
Reference in a new issue