1
0
Fork 0

Merge pull request #141 from KuehnhammerTobias/pr_kick_cmds

Added kicknum, kickall, and kickbots commands, patch by Ensiform.
This commit is contained in:
Eugene C 2022-01-21 23:55:34 +02:00 committed by GitHub
commit 747d30844c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 101 additions and 37 deletions

View File

@ -420,7 +420,6 @@ static void SV_Kick_f( void ) {
}
if( cl->netchan.remoteAddress.type == NA_LOOPBACK ) {
Com_Printf("Cannot kick host player\n");
return;
}
@ -428,6 +427,100 @@ static void SV_Kick_f( void ) {
cl->lastPacketTime = svs.time; // in case there is a funny zombie
}
/*
==================
SV_KickBots_f
Kick all bots off of the server
==================
*/
static void SV_KickBots_f( void ) {
client_t *cl;
int i;
// make sure server is running
if ( !com_sv_running->integer ) {
Com_Printf("Server is not running.\n");
return;
}
for( i = 0, cl = svs.clients; i < sv_maxclients->integer; i++, cl++ ) {
if ( cl->state < CS_CONNECTED ) {
continue;
}
if ( cl->netchan.remoteAddress.type != NA_BOT ) {
continue;
}
SV_DropClient( cl, "was kicked" );
cl->lastPacketTime = svs.time; // in case there is a funny zombie
}
}
/*
==================
SV_KickAll_f
Kick all users off of the server
==================
*/
static void SV_KickAll_f( void ) {
client_t *cl;
int i;
// make sure server is running
if ( !com_sv_running->integer ) {
Com_Printf( "Server is not running.\n" );
return;
}
for( i = 0, cl = svs.clients; i < sv_maxclients->integer; i++, cl++ ) {
if ( cl->state < CS_CONNECTED ) {
continue;
}
if ( cl->netchan.remoteAddress.type == NA_LOOPBACK ) {
continue;
}
SV_DropClient( cl, "was kicked" );
cl->lastPacketTime = svs.time; // in case there is a funny zombie
}
}
/*
==================
SV_KickNum_f
Kick a user off of the server
==================
*/
static void SV_KickNum_f( void ) {
client_t *cl;
// make sure server is running
if ( !com_sv_running->integer ) {
Com_Printf( "Server is not running.\n" );
return;
}
if ( Cmd_Argc() != 2 ) {
Com_Printf ("Usage: %s <client number>\n", Cmd_Argv(0));
return;
}
cl = SV_GetPlayerByNum();
if ( !cl ) {
return;
}
if ( cl->netchan.remoteAddress.type == NA_LOOPBACK ) {
Com_Printf("Cannot kick host player\n");
return;
}
SV_DropClient( cl, "was kicked" );
cl->lastPacketTime = svs.time; // in case there is a funny zombie
}
#ifndef STANDALONE
// these functions require the auth server which of course is not available anymore for stand-alone games.
@ -1065,41 +1158,6 @@ static void SV_ExceptDel_f(void)
#endif // USE_BANS
/*
==================
SV_KickNum_f
Kick a user off of the server FIXME: move to game
==================
*/
static void SV_KickNum_f( void ) {
client_t *cl;
// make sure server is running
if ( !com_sv_running->integer ) {
Com_Printf( "Server is not running.\n" );
return;
}
if ( Cmd_Argc() != 2 ) {
Com_Printf ("Usage: kicknum <client number>\n");
return;
}
cl = SV_GetPlayerByNum();
if ( !cl ) {
return;
}
if( cl->netchan.remoteAddress.type == NA_LOOPBACK ) {
SV_SendServerCommand(NULL, "print \"%s\"", "Cannot kick host player\n");
return;
}
SV_DropClient( cl, "was kicked" );
cl->lastPacketTime = svs.time; // in case there is a funny zombie
}
/*
** SV_Strlen -- skips color escape codes
*/
@ -1484,7 +1542,10 @@ void SV_AddOperatorCommands( void ) {
}
#endif
#endif
Cmd_AddCommand ("clientkick", SV_KickNum_f);
Cmd_AddCommand ("kickbots", SV_KickBots_f);
Cmd_AddCommand ("kickall", SV_KickAll_f);
Cmd_AddCommand ("kicknum", SV_KickNum_f);
Cmd_AddCommand ("clientkick", SV_KickNum_f); // Legacy command
Cmd_AddCommand ("status", SV_Status_f);
Cmd_AddCommand ("dumpuser", SV_DumpUser_f);
Cmd_AddCommand ("map_restart", SV_MapRestart_f);
@ -1524,7 +1585,10 @@ void SV_RemoveOperatorCommands( void ) {
// removing these won't let the server start again
Cmd_RemoveCommand ("heartbeat");
Cmd_RemoveCommand ("kick");
Cmd_RemoveCommand ("kicknum");
Cmd_RemoveCommand ("clientkick");
Cmd_RemoveCommand ("kickall");
Cmd_RemoveCommand ("kickbots");
Cmd_RemoveCommand ("banUser");
Cmd_RemoveCommand ("banClient");
Cmd_RemoveCommand ("status");