Revisión | 43774e7b5df53782d2ddbf3c3da144d340efc586 (tree) |
---|---|
Tiempo | 2023-11-20 06:48:51 |
Autor | Sean Baggaley <me@drin...> |
Commiter | Sean Baggaley |
Added the forcerename and forcerename_idx CCMDs, which forcibly change a...
@@ -41,6 +41,7 @@ | ||
41 | 41 | + - 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] |
42 | 42 | + - 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] |
43 | 43 | + - 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] | |
44 | 45 | - - Fixed: clients didn't initialize a sector's friction properly in some cases due to a superfluous check that wasn't removed earlier. [Kaminsky] |
45 | 46 | - - Fixed: the server wouldn't initialize compatflags and compatflags2 properly if entered as command line parameters. [Kaminsky] |
46 | 47 | - - Fixed: serverinfo CVars entered on the command line were restored in reverse order. [Kaminsky] |
@@ -176,6 +176,7 @@ | ||
176 | 176 | static void server_PerformBacktrace( ULONG ulClient, ULONG ulNumLateMoveCMDs ); |
177 | 177 | static bool server_ShouldPerformBacktrace( ULONG ulClient ); |
178 | 178 | static void server_FixZFromBacktrace( APlayerPawn *pmo, fixed_t oldFloorZ ); |
179 | +static void server_ForceRenamePlayer( ULONG playerIndex ); // [SB] | |
179 | 180 | |
180 | 181 | // [RC] |
181 | 182 | #ifdef CREATE_PACKET_LOG |
@@ -7783,6 +7784,35 @@ | ||
7783 | 7784 | } |
7784 | 7785 | |
7785 | 7786 | //***************************************************************************** |
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 | +//***************************************************************************** | |
7786 | 7816 | // CONSOLE COMMANDS |
7787 | 7817 | |
7788 | 7818 | CCMD( kick_idx ) |
@@ -7994,6 +8024,73 @@ | ||
7994 | 8024 | } |
7995 | 8025 | |
7996 | 8026 | //***************************************************************************** |
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 | +//***************************************************************************** | |
7997 | 8094 | #ifdef _DEBUG |
7998 | 8095 | CCMD( testchecksum ) |
7999 | 8096 | { |