# HG changeset patch # User Adam Kaminski # Date 1634448651 14400 # Sun Oct 17 01:30:51 2021 -0400 # Node ID 97497908b5233bdee59da4a0e3485853044853f6 # Parent 58b931c351318915650c036868ccc0aefde49cc9 In-game RCON clients now receive private messages sent to/from the server. diff -r 58b931c35131 -r 97497908b523 src/chat.cpp --- a/src/chat.cpp Sun Oct 17 01:15:52 2021 -0400 +++ b/src/chat.cpp Sun Oct 17 01:30:51 2021 -0400 @@ -919,6 +919,10 @@ if (( ulPlayer != MAXPLAYERS ) && players[ulPlayer].bIgnoreChat ) return; + // [AK] Sanity check, make sure the chat mode is valid. + if (( ulMode == CHATMODE_NONE ) || ( ulMode >= NUM_CHATMODES )) + return; + // If ulPlayer == MAXPLAYERS, it is the server talking. if ( ulPlayer == MAXPLAYERS ) { @@ -984,12 +988,27 @@ OutString.AppendFormat( TEXTCOLOR_GREEN "%s" TEXTCOLOR_TEAMCHAT ": ", players[ulPlayer].userinfo.GetName() ); } } - else if (( ulMode == CHATMODE_PRIVATE_SEND ) || ( ulMode == CHATMODE_PRIVATE_RECEIVE )) + else { ulChatLevel = PRINT_PRIVATECHAT; + const bool bRconReceived = ( ulMode == CHATMODE_PRIVATE_RCON_SEND ) || ( ulMode == CHATMODE_PRIVATE_RCON_RECEIVE ); - OutString.AppendFormat( TEXTCOLOR_GREEN "<%s ", ulMode == CHATMODE_PRIVATE_SEND ? "To" : "From" ); - OutString.AppendFormat( "%s" TEXTCOLOR_GREEN ">", players[ulPlayer].userinfo.GetName() ); + // [AK] Check if this is a private message we received because it was sent to/from the server. + // In this case, the header needs to be formatted a little differently. + if ( bRconReceived ) + { + OutString += TEXTCOLOR_GREY; + + if ( ulMode == CHATMODE_PRIVATE_RCON_SEND ) + OutString.AppendFormat( "", players[ulPlayer].userinfo.GetName() ); + else + OutString.AppendFormat( "<%s" TEXTCOLOR_GREY " to Server>", players[ulPlayer].userinfo.GetName() ); + } + else + { + OutString.AppendFormat( TEXTCOLOR_GREEN "<%s ", ulMode == CHATMODE_PRIVATE_SEND ? "To" : "From" ); + OutString.AppendFormat( "%s" TEXTCOLOR_GREEN ">", players[ulPlayer].userinfo.GetName() ); + } // Special support for "/me" commands. if ( strnicmp( "/me", pszString, 3 ) == 0 ) @@ -999,7 +1018,7 @@ } else { - OutString.AppendFormat( TEXTCOLOR_PRIVATECHAT ": " ); + OutString.AppendFormat( "%s: ", bRconReceived == false ? TEXTCOLOR_PRIVATECHAT : "" ); } } diff -r 58b931c35131 -r 97497908b523 src/chat.h --- a/src/chat.h Sun Oct 17 01:15:52 2021 -0400 +++ b/src/chat.h Sun Oct 17 01:30:51 2021 -0400 @@ -68,8 +68,10 @@ CHATMODE_NONE, CHATMODE_GLOBAL, CHATMODE_TEAM, - CHATMODE_PRIVATE_SEND, // [AK] We're send a private message. - CHATMODE_PRIVATE_RECEIVE, // [AK] We're receiving a private message. + CHATMODE_PRIVATE_SEND, // [AK] We sent a private message. + CHATMODE_PRIVATE_RECEIVE, // [AK] We received a private message. + CHATMODE_PRIVATE_RCON_SEND, // [AK] We have RCON access and received a private message sent by the server. + CHATMODE_PRIVATE_RCON_RECEIVE, // [AK] We have RCON access and received a private message sent to the server. NUM_CHATMODES diff -r 58b931c35131 -r 97497908b523 src/sv_commands.cpp --- a/src/sv_commands.cpp Sun Oct 17 01:15:52 2021 -0400 +++ b/src/sv_commands.cpp Sun Oct 17 01:30:51 2021 -0400 @@ -201,6 +201,26 @@ ulBits |= CM_REUSE_Z; } } + +//***************************************************************************** +// +// [AK] Sends a private message sent to/from the server to all in-game RCON clients. +void SendPrivateMessageToRCONClients( ServerCommands::PlayerSay &command, ULONG ulPlayer, bool bServerSent ) +{ + command.SetPlayerNumber( ulPlayer ); + command.SetMode( bServerSent ? CHATMODE_PRIVATE_RCON_SEND : CHATMODE_PRIVATE_RCON_RECEIVE ); + + for ( ULONG ulIdx = 0; ulIdx < MAXPLAYERS; ulIdx++ ) + { + if ( SERVER_IsValidClient( ulIdx ) == false ) + continue; + + // [AK] Also ignore the player who sent/received the message. + if (( ulIdx != ulPlayer ) && ( SERVER_GetClient( ulIdx )->bRCONAccess )) + command.sendCommandToClients( ulIdx, SVCF_ONLYTHISCLIENT ); + } +} + //***************************************************************************** // void SERVERCOMMANDS_Ping( ULONG ulTime ) @@ -1114,6 +1134,11 @@ command.sendCommandToClients( ulReceiver, SVCF_ONLYTHISCLIENT ); } } + else + { + // [AK] Tell in-game RCON clients that the server received a private message from somebody. + SendPrivateMessageToRCONClients( command, ulSender, false ); + } // [AK] Next, send the command back to the player who sent the message. if ( ulSender != MAXPLAYERS ) @@ -1122,6 +1147,11 @@ command.SetMode( CHATMODE_PRIVATE_SEND ); command.sendCommandToClients( ulSender, SVCF_ONLYTHISCLIENT ); } + else + { + // [AK] Tell in-game RCON clients that the server sent a private message to somebody. + SendPrivateMessageToRCONClients( command, ulReceiver, true ); + } } //*****************************************************************************