Commit MetaInfo

Revisión43774e7b5df53782d2ddbf3c3da144d340efc586 (tree)
Tiempo2023-11-20 06:48:51
AutorSean Baggaley <me@drin...>
CommiterSean Baggaley

Log Message

Added the forcerename and forcerename_idx CCMDs, which forcibly change a...

Cambiar Resumen

Diferencia incremental

diff -r 1601b1b423d9 -r 43774e7b5df5 docs/zandronum-history.txt
--- a/docs/zandronum-history.txt Tue Nov 07 11:14:46 2023 -0500
+++ b/docs/zandronum-history.txt Sun Nov 19 21:48:51 2023 +0000
@@ -41,6 +41,7 @@
4141 + - Added a segmented version of the launcher protocol, which allows splitting responses across multiple packets, avoiding network issues that arise when packets reach large sizes. [DrinkyBird]
4242 + - Added an optional parameter to the "ignore" and "ignore_idx" CCMDs that allows servers to specify a reason for muting a client, based on Janko Knezevic's patch. [Kaminsky]
4343 + - Added ACS functions that provide lump reading capabilities: "LumpOpen", "LumpReadChar", "LumpReadShort", "LumpReadInt", "LumpReadString", and "LumpSize". [TDRR]
44++ - Added the forcerename and forcerename_idx CCMDs, which forcibly change a player's name to a random generic one. [DrinkyBird]
4445 - - Fixed: clients didn't initialize a sector's friction properly in some cases due to a superfluous check that wasn't removed earlier. [Kaminsky]
4546 - - Fixed: the server wouldn't initialize compatflags and compatflags2 properly if entered as command line parameters. [Kaminsky]
4647 - - Fixed: serverinfo CVars entered on the command line were restored in reverse order. [Kaminsky]
diff -r 1601b1b423d9 -r 43774e7b5df5 src/sv_main.cpp
--- a/src/sv_main.cpp Tue Nov 07 11:14:46 2023 -0500
+++ b/src/sv_main.cpp Sun Nov 19 21:48:51 2023 +0000
@@ -176,6 +176,7 @@
176176 static void server_PerformBacktrace( ULONG ulClient, ULONG ulNumLateMoveCMDs );
177177 static bool server_ShouldPerformBacktrace( ULONG ulClient );
178178 static void server_FixZFromBacktrace( APlayerPawn *pmo, fixed_t oldFloorZ );
179+static void server_ForceRenamePlayer( ULONG playerIndex ); // [SB]
179180
180181 // [RC]
181182 #ifdef CREATE_PACKET_LOG
@@ -7783,6 +7784,35 @@
77837784 }
77847785
77857786 //*****************************************************************************
7787+// [SB] Used by the forcerename and forcerename_idx commands.
7788+static void server_ForceRenamePlayer( ULONG playerIndex )
7789+{
7790+ // Make sure the target is valid and applicable.
7791+ if ( PLAYER_IsValidPlayer ( playerIndex ) == false )
7792+ {
7793+ Printf( "No such player!\n" );
7794+ return;
7795+ }
7796+
7797+ FString oldName( players[playerIndex].userinfo.GetName() );
7798+ FString newName = PLAYER_GenerateUniqueName();
7799+
7800+ players[playerIndex].userinfo.NameChanged( newName );
7801+ SERVERCOMMANDS_SetPlayerUserInfo( playerIndex, { NAME_Name } );
7802+
7803+ // Inform the player in question.
7804+ FString message;
7805+ message.Format( "A server administrator has forcibly changed your name. You have been renamed to '%s'.\n", newName.GetChars() );
7806+ SERVERCOMMANDS_PrintMid( message, true, playerIndex, SVCF_ONLYTHISCLIENT );
7807+
7808+ // and everyone else.
7809+ SERVER_Printf( "%s is now known as %s\n", oldName.GetChars(), players[playerIndex].userinfo.GetName() );
7810+
7811+ // Update clients using the RCON utility.
7812+ SERVER_RCON_UpdateInfo( SVRCU_PLAYERDATA );
7813+}
7814+
7815+//*****************************************************************************
77867816 // CONSOLE COMMANDS
77877817
77887818 CCMD( kick_idx )
@@ -7994,6 +8024,73 @@
79948024 }
79958025
79968026 //*****************************************************************************
8027+// [SB] Commands to forcibly change a player's name.
8028+//
8029+CCMD( forcerename_idx )
8030+{
8031+ // This function may not be used by ConsoleCommand.
8032+ if ( ACS_IsCalledFromConsoleCommand( ))
8033+ return;
8034+
8035+ // Only the server can do this.
8036+ if ( NETWORK_GetState() != NETSTATE_SERVER )
8037+ return;
8038+
8039+ if ( argv.argc() < 2 )
8040+ {
8041+ Printf( "Usage: forcerename_idx <player index>\nYou can get the list of players and indexes with the ccmd playerinfo.\n" );
8042+ return;
8043+ }
8044+
8045+ int playerIndex;
8046+ if ( argv.SafeGetNumber(1, playerIndex) == false )
8047+ return;
8048+
8049+ if ( playerIndex < 0 || playerIndex >= MAXPLAYERS )
8050+ return;
8051+
8052+ server_ForceRenamePlayer( playerIndex );
8053+}
8054+
8055+CCMD( forcerename )
8056+{
8057+ // This function may not be used by ConsoleCommand.
8058+ if ( ACS_IsCalledFromConsoleCommand( ))
8059+ return;
8060+
8061+ // Only the server can do this.
8062+ if ( NETWORK_GetState() != NETSTATE_SERVER )
8063+ return;
8064+
8065+ if ( argv.argc() < 2 )
8066+ {
8067+ Printf( "Usage: forcerename <playername>\n" );
8068+ return;
8069+ }
8070+
8071+ // Loop through all the players, and try to find one that matches the given name.
8072+ for ( ULONG idx = 0; idx < MAXPLAYERS; idx++ )
8073+ {
8074+ if ( playeringame[idx] == false )
8075+ continue;
8076+
8077+ // Removes the color codes from the player name so it appears as the server sees it in the window.
8078+ FString playerName = players[idx].userinfo.GetName();
8079+ V_RemoveColorCodes( playerName );
8080+
8081+ if ( playerName.CompareNoCase( argv[1] ) == 0 )
8082+ {
8083+ server_ForceRenamePlayer( idx );
8084+
8085+ return;
8086+ }
8087+ }
8088+
8089+ // Didn't find a player that matches the name.
8090+ Printf( "Unknown player: %s\n", argv[1] );
8091+}
8092+
8093+//*****************************************************************************
79978094 #ifdef _DEBUG
79988095 CCMD( testchecksum )
79998096 {
Show on old repository browser