attempt to fix kick/ban commands causing dedicated servers to self destruct

if a player was specified which was not being in game
this is what caused dedis to sometimes go to the main menu
This commit is contained in:
alufolie91 committed 2026-07-19 04:32:49 +02:00
1 parent 9dc179aba4
commit 3bee6bfaff
1 file changed
+20 -1
+20 -1
View File
@@ -3767,6 +3767,10 @@ static void Command_Ban(void)
if (pn == -1 || pn == 0)
return;
// player does not exist
if (!nodeingame[playernode[pn]])
return;
WRITEUINT8(p, pn);
if (COM_Argc() == 2)
@@ -3884,6 +3888,10 @@ static void Command_Kick(void)
if (pn == -1 || pn == 0)
return;
// player does not exist
if (!nodeingame[playernode[pn]])
return;
// Special case if we are trying to kick a player who is downloading the game state:
// trigger a timeout instead of kicking them, because a kick would only
// take effect after they have finished downloading
@@ -3933,7 +3941,8 @@ static void Got_KickCmd(const UINT8 **p, INT32 playernum)
pnum = READUINT8(*p);
msg = READUINT8(*p);
if (pnum == serverplayer && IsPlayerAdmin(playernum))
// FIXME: this does not work at all on dedi, servernode == 0 which is prevented from kick/ban command
if (playernode[pnum] == servernode && IsPlayerAdmin(playernum))
{
CONS_Printf(M_GetText("Server is being shut down remotely. Goodbye!\n"));
@@ -3943,6 +3952,16 @@ static void Got_KickCmd(const UINT8 **p, INT32 playernum)
return;
}
// without this the server will remove itself and thus self destruct on dedicated
if (!nodeingame[playernode[pnum]])
{
CONS_Alert(CONS_WARNING, M_GetText("Attempting to kick player %d which is not in game received from %s\n"), pnum, player_names[playernum]);
return;
}
// make sure we dont read garbage anywhere
memset(reason, 0, sizeof(buf));
// Is playernum authorized to make this kick?
if (playernum != serverplayer && !IsPlayerAdmin(playernum)
/*&& !(playernode[playernum] != UINT8_MAX && playerpernode[playernode[playernum]] == 2