# HG changeset patch # User Adam Kaminski # Date 1627850654 14400 # Sun Aug 01 16:44:14 2021 -0400 # Node ID abfaafbd9e8559690863fe3cfcb6e1a06203cddb # Parent a9a2f0c02407d49d29f4d34086edd3cb847880ee Added some missing checks to the "messagemode2" CCMD. A warning message will also be printed if the player attempts to use the team chat if they're not on a team or playing on a game mode that supports teams. diff -r a9a2f0c02407 -r abfaafbd9e85 src/chat.cpp --- a/src/chat.cpp Thu Jul 29 21:38:15 2021 -0400 +++ b/src/chat.cpp Sun Aug 01 16:44:14 2021 -0400 @@ -1257,6 +1257,27 @@ //***************************************************************************** // +// [AK] Checks if the local player can use the team chat right now. +// +bool chat_CanUseTeamChat( void ) +{ + // Make sure that we're playing on a game mode that supports teams. + if (( GAMEMODE_GetCurrentFlags( ) & GMF_PLAYERSONTEAMS ) == false ) + { + Printf( "You can't use the team chat in game modes that don't support teams.\n" ); + return false; + } + + // Not on a team. No one to talk to. + if (( players[consoleplayer].bOnTeam == false ) && ( PLAYER_IsTrueSpectator( &players[consoleplayer] ) == false )) + { + Printf( "You can't use the team chat if you're not on a team." ); + return false; + } + + return true; +} + CCMD( say_team ) { ULONG ulIdx; @@ -1273,19 +1294,12 @@ return; } - // Make sure we have teammates to talk to before we use team chat. - if ( GAMEMODE_GetCurrentFlags() & GMF_PLAYERSONTEAMS ) - { - // Not on a team. No one to talk to. - if ( ( players[consoleplayer].bOnTeam == false ) && ( PLAYER_IsTrueSpectator ( &players[consoleplayer] ) == false ) ) - return; - } - // Not in any team mode. Nothing to do! - else + // The server never should have a team! + if ( NETWORK_GetState( ) == NETSTATE_SERVER ) return; - // The server never should have a team! - if ( NETWORK_GetState( ) == NETSTATE_SERVER ) + // Make sure we have teammates to talk to before we use team chat. + if ( chat_CanUseTeamChat( ) == false ) return; if ( argv.argc( ) < 2 ) @@ -1696,6 +1710,10 @@ if ( NETWORK_GetState() != NETSTATE_SERVER ) { + // Make sure we have teammates to talk to before we use team chat. + if ( chat_CanUseTeamChat( ) == false ) + return; + CHAT_SetChatMode( CHATMODE_TEAM ); C_HideConsole( ); g_ChatBuffer.Clear();