# HG changeset patch # User Adam Kaminski # Date 1634447752 14400 # Sun Oct 17 01:15:52 2021 -0400 # Node ID 58b931c351318915650c036868ccc0aefde49cc9 # Parent 3fa62fab8f2064c3ac31235752d0898b8b68f487 Spectators can no longer send private messages to the server while the chat is restricted. diff -r 3fa62fab8f20 -r 58b931c35131 src/chat.cpp --- a/src/chat.cpp Sat Oct 16 13:30:59 2021 -0400 +++ b/src/chat.cpp Sun Oct 17 01:15:52 2021 -0400 @@ -787,8 +787,10 @@ { if ( g_ulChatMode != CHATMODE_PRIVATE_SEND ) note += "Players cannot hear you chat"; - else if (( g_ulChatPlayer != MAXPLAYERS ) && ( players[g_ulChatPlayer].bSpectating == false )) - note.AppendFormat( "%s " TEXTCOLOR_GRAY "cannot hear you chat", players[g_ulChatPlayer].userinfo.GetName()); + else if ( g_ulChatPlayer == MAXPLAYERS ) + note += "The server cannot hear you chat"; + else if ( players[g_ulChatPlayer].bSpectating == false ) + note.AppendFormat( "%s " TEXTCOLOR_GRAY "cannot hear you chat", players[g_ulChatPlayer].userinfo.GetName() ); else bDrawNote = false; } else diff -r 3fa62fab8f20 -r 58b931c35131 src/sv_commands.cpp --- a/src/sv_commands.cpp Sat Oct 16 13:30:59 2021 -0400 +++ b/src/sv_commands.cpp Sun Oct 17 01:15:52 2021 -0400 @@ -1077,8 +1077,19 @@ // void SERVERCOMMANDS_PrivateSay( ULONG ulSender, ULONG ulReceiver, const char *pszString, bool bForbidChatToPlayers, ULONG ulPlayerExtra, ServerCommandFlags flags ) { - if ( ulSender != MAXPLAYERS && PLAYER_IsValidPlayer( ulSender ) == false ) - return; + if ( ulSender != MAXPLAYERS ) + { + if ( PLAYER_IsValidPlayer( ulSender ) == false ) + return; + + // [AK] Spectators cannot send private messages to the server or non-spectators when the chat is restricted. + if (( bForbidChatToPlayers ) && (( ulReceiver == MAXPLAYERS ) || ( players[ulReceiver].bSpectating == false ))) + { + SERVER_PrintfPlayer( ulSender, "You can't send any private messages to %s right now.\n", + ( ulReceiver == MAXPLAYERS ) ? "the server" : players[ulReceiver].userinfo.GetName() ); + return; + } + } ServerCommands::PlayerSay command; command.SetMessage( pszString ); @@ -1086,13 +1097,6 @@ // [AK] First send the command to the player receiving the message. if ( ulReceiver != MAXPLAYERS ) { - if (( bForbidChatToPlayers ) && ( players[ulReceiver].bSpectating == false )) - { - SERVER_PrintfPlayer( ulSender, "You can't send any private messages to %s right now.\n", - players[ulReceiver].userinfo.GetName() ); - return; - } - // [AK] Don't send the command if the sender is supposed to be ignoring the player who receives the message. if (( ulSender != MAXPLAYERS ) && ( SERVER_GetPlayerIgnoreTic( ulSender, SERVER_GetClient( ulReceiver )->Address ) != 0 )) { diff -r 3fa62fab8f20 -r 58b931c35131 src/sv_main.cpp --- a/src/sv_main.cpp Sat Oct 16 13:30:59 2021 -0400 +++ b/src/sv_main.cpp Sun Oct 17 01:15:52 2021 -0400 @@ -1191,9 +1191,16 @@ GAMEMODE_HandleEvent( GAMEEVENT_CHAT, 0, ulPlayer != MAXPLAYERS ? ulPlayer : -1, ulMode - CHATMODE_GLOBAL ); } - // [AK] Don't log private messages that aren't sent to/from the server. - if (( ulMode == CHATMODE_PRIVATE_SEND ) && ( ulPlayer != MAXPLAYERS ) && ( ulReceiver != MAXPLAYERS )) - return; + if ( ulMode == CHATMODE_PRIVATE_SEND ) + { + // [AK] Don't log private messages that aren't sent to/from the server. + if (( ulPlayer != MAXPLAYERS ) && ( ulReceiver != MAXPLAYERS )) + return; + + // [AK] Don't log private messages sent by spectators when the chat is restricted. + if (( ulReceiver == MAXPLAYERS ) && ( bForbidChatToPlayers )) + return; + } // [BB] This is to make the lines readily identifiable, necessary // for MiX-MaN's IRC server control tool for example.