# HG changeset patch # User Adam Kaminski # Date 1637772288 18000 # Wed Nov 24 11:44:48 2021 -0500 # Node ID f79c58a9b4d3c37d6dada5e6d192adb48abef044 # Parent 0cace8154daa9e142f4b71e542363f28ff2fa31a Merged all the server commands that updated a team's score into one single command: "SetTeamScore". diff -r 0cace8154daa -r f79c58a9b4d3 src/cl_main.cpp --- a/src/cl_main.cpp Tue Nov 23 12:14:54 2021 -0500 +++ b/src/cl_main.cpp Wed Nov 24 11:44:48 2021 -0500 @@ -214,9 +214,7 @@ static void client_SetDominationPointOwnership( BYTESTREAM_s *pByteStream ); // Team commands. -static void client_SetTeamFrags( BYTESTREAM_s *pByteStream ); static void client_SetTeamScore( BYTESTREAM_s *pByteStream ); -static void client_SetTeamWins( BYTESTREAM_s *pByteStream ); static void client_SetTeamReturnTicks( BYTESTREAM_s *pByteStream ); static void client_TeamFlagReturned( BYTESTREAM_s *pByteStream ); static void client_TeamFlagDropped( BYTESTREAM_s *pByteStream ); @@ -1679,18 +1677,10 @@ client_SetDominationPointOwnership( pByteStream ); break; - case SVC_SETTEAMFRAGS: - - client_SetTeamFrags( pByteStream ); - break; case SVC_SETTEAMSCORE: client_SetTeamScore( pByteStream ); break; - case SVC_SETTEAMWINS: - - client_SetTeamWins( pByteStream ); - break; case SVC_SETTEAMRETURNTICKS: client_SetTeamReturnTicks( pByteStream ); @@ -6193,80 +6183,42 @@ //***************************************************************************** // -static void client_SetTeamFrags( BYTESTREAM_s *pByteStream ) -{ - ULONG ulTeam; - LONG lFragCount; - bool bAnnounce; - - // Read in the team. - ulTeam = pByteStream->ReadByte(); - - // Read in the fragcount. - lFragCount = pByteStream->ReadShort(); - - // Announce a lead change... but don't do it if we're receiving a snapshot of the level! - bAnnounce = !!pByteStream->ReadByte(); - if ( g_ConnectionState != CTS_ACTIVE ) - bAnnounce = false; - - // Finally, set the team's fragcount. - TEAM_SetFragCount( ulTeam, lFragCount, bAnnounce ); -} - -//***************************************************************************** -// static void client_SetTeamScore( BYTESTREAM_s *pByteStream ) { - ULONG ulTeam; - LONG lScore; - bool bAnnounce; - // Read in the team having its score updated. - ulTeam = pByteStream->ReadByte(); + ULONG ulTeam = pByteStream->ReadByte(); + + // Should it be announced? + bool bAnnounce = !!pByteStream->ReadBit(); // Read in the team's new score. - lScore = pByteStream->ReadShort(); - - // Should it be announced? - bAnnounce = !!pByteStream->ReadByte(); - + ULONG ulType = pByteStream->ReadShortByte( 5 ); + LONG lScore = pByteStream->ReadVariable(); + // Don't announce the score change if we're receiving a snapshot of the level! if ( g_ConnectionState != CTS_ACTIVE ) bAnnounce = false; - TEAM_SetScore( ulTeam, lScore, bAnnounce ); + switch ( ulType ) + { + case TEAMSCORE_FRAGS: + TEAM_SetFragCount( ulTeam, lScore, bAnnounce ); + break; + + case TEAMSCORE_POINTS: + TEAM_SetScore( ulTeam, lScore, bAnnounce ); + break; + + case TEAMSCORE_WINS: + TEAM_SetWinCount( ulTeam, lScore, bAnnounce ); + break; + } HUD_Refresh( ); } //***************************************************************************** // -static void client_SetTeamWins( BYTESTREAM_s *pByteStream ) -{ - ULONG ulTeamIdx; - LONG lWinCount; - bool bAnnounce; - - // Read in the team. - ulTeamIdx = pByteStream->ReadByte(); - - // Read in the wins. - lWinCount = pByteStream->ReadShort(); - - // Read in whether or not it should be announced. - bAnnounce = !!pByteStream->ReadByte(); - - // Don't announce if we're receiving a snapshot of the level! - if ( g_ConnectionState != CTS_ACTIVE ) - bAnnounce = false; - - // Finally, set the team's win count. - TEAM_SetWinCount( ulTeamIdx, lWinCount, bAnnounce ); -} - -//***************************************************************************** -// static void client_SetTeamReturnTicks( BYTESTREAM_s *pByteStream ) { ULONG ulTeam; diff -r 0cace8154daa -r f79c58a9b4d3 src/network.h --- a/src/network.h Tue Nov 23 12:14:54 2021 -0500 +++ b/src/network.h Wed Nov 24 11:44:48 2021 -0500 @@ -234,6 +234,14 @@ UPDATE_MAPROTATION_RESET, }; +// [AK] What kind of team score are we sending to clients? +enum TeamScoreType +{ + TEAMSCORE_FRAGS, + TEAMSCORE_POINTS, + TEAMSCORE_WINS, +}; + // Which actor sound is being updated? #define ACTORSOUND_SEESOUND 1 #define ACTORSOUND_ATTACKSOUND 2 diff -r 0cace8154daa -r f79c58a9b4d3 src/network_enums.h --- a/src/network_enums.h Tue Nov 23 12:14:54 2021 -0500 +++ b/src/network_enums.h Wed Nov 24 11:44:48 2021 -0500 @@ -185,9 +185,7 @@ ENUM_ELEMENT ( SVC_DOGAMEMODEWINSEQUENCE ), ENUM_ELEMENT ( SVC_SETDOMINATIONSTATE ), ENUM_ELEMENT ( SVC_SETDOMINATIONPOINTOWNER ), - ENUM_ELEMENT ( SVC_SETTEAMFRAGS ), // TEAM COMMANDS - ENUM_ELEMENT ( SVC_SETTEAMSCORE ), - ENUM_ELEMENT ( SVC_SETTEAMWINS ), + ENUM_ELEMENT ( SVC_SETTEAMSCORE ), // TEAM COMMANDS ENUM_ELEMENT ( SVC_SETTEAMRETURNTICKS ), ENUM_ELEMENT ( SVC_TEAMFLAGRETURNED ), ENUM_ELEMENT ( SVC_TEAMFLAGDROPPED ), diff -r 0cace8154daa -r f79c58a9b4d3 src/sv_commands.cpp --- a/src/sv_commands.cpp Tue Nov 23 12:14:54 2021 -0500 +++ b/src/sv_commands.cpp Wed Nov 24 11:44:48 2021 -0500 @@ -2493,43 +2493,33 @@ //***************************************************************************** // -void SERVERCOMMANDS_SetTeamFrags( ULONG ulTeam, LONG lFrags, bool bAnnounce, ULONG ulPlayerExtra, ServerCommandFlags flags ) +void SERVERCOMMANDS_SetTeamScore( ULONG ulTeam, ULONG ulType, bool bAnnounce, ULONG ulPlayerExtra, ServerCommandFlags flags ) { if ( TEAM_CheckIfValid( ulTeam ) == false ) return; - NetCommand command( SVC_SETTEAMFRAGS ); - command.addByte( ulTeam ); - command.addShort( lFrags ); - command.addByte( bAnnounce ); - command.sendCommandToClients( ulPlayerExtra, flags ); -} - -//***************************************************************************** -// -void SERVERCOMMANDS_SetTeamScore( ULONG ulTeam, LONG lScore, bool bAnnounce, ULONG ulPlayerExtra, ServerCommandFlags flags ) -{ - if ( TEAM_CheckIfValid( ulTeam ) == false ) - return; + LONG lScore = 0; + + switch ( ulType ) + { + case TEAMSCORE_FRAGS: + lScore = TEAM_GetFragCount( ulTeam ); + break; + + case TEAMSCORE_POINTS: + lScore = TEAM_GetScore( ulTeam ); + break; + + case TEAMSCORE_WINS: + lScore = TEAM_GetWinCount( ulTeam ); + break; + } NetCommand command( SVC_SETTEAMSCORE ); command.addByte( ulTeam ); - command.addShort( lScore ); - command.addByte( bAnnounce ); - command.sendCommandToClients( ulPlayerExtra, flags ); -} - -//***************************************************************************** -// -void SERVERCOMMANDS_SetTeamWins( ULONG ulTeam, LONG lWins, bool bAnnounce, ULONG ulPlayerExtra, ServerCommandFlags flags ) -{ - if ( TEAM_CheckIfValid( ulTeam ) == false ) - return; - - NetCommand command( SVC_SETTEAMWINS ); - command.addByte( ulTeam ); - command.addShort( lWins ); - command.addByte( bAnnounce ); + command.addBit( bAnnounce ); + command.addShortByte( ulType, 5 ); + command.addVariable( lScore ); command.sendCommandToClients( ulPlayerExtra, flags ); } diff -r 0cace8154daa -r f79c58a9b4d3 src/sv_commands.h --- a/src/sv_commands.h Tue Nov 23 12:14:54 2021 -0500 +++ b/src/sv_commands.h Wed Nov 24 11:44:48 2021 -0500 @@ -221,9 +221,7 @@ void SERVERCOMMANDS_SetDominationPointOwnership( ULONG ulPoint, ULONG ulPlayer, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); // Team commands. These involve one of the teams in teamgame mode. -void SERVERCOMMANDS_SetTeamFrags( ULONG ulTeam, LONG lFrags, bool bAnnounce, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); -void SERVERCOMMANDS_SetTeamScore( ULONG ulTeam, LONG lScore, bool bAnnounce, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); -void SERVERCOMMANDS_SetTeamWins( ULONG ulTeam, LONG lWins, bool bAnnounce, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); +void SERVERCOMMANDS_SetTeamScore( ULONG ulTeam, ULONG ulType, bool bAnnounce, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); void SERVERCOMMANDS_SetTeamReturnTicks( ULONG ulTeam, ULONG ulReturnTicks, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); void SERVERCOMMANDS_TeamFlagReturned( ULONG ulTeam, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); void SERVERCOMMANDS_TeamFlagDropped( ULONG ulPlayer, ULONG ulTeam, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); diff -r 0cace8154daa -r f79c58a9b4d3 src/sv_main.cpp --- a/src/sv_main.cpp Tue Nov 23 12:14:54 2021 -0500 +++ b/src/sv_main.cpp Wed Nov 24 11:44:48 2021 -0500 @@ -2551,11 +2551,11 @@ for ( ulIdx = 0; ulIdx < teams.Size( ); ulIdx++ ) { if ( GAMEMODE_GetCurrentFlags() & GMF_PLAYERSEARNWINS ) - SERVERCOMMANDS_SetTeamWins( ulIdx, TEAM_GetWinCount( ulIdx ), false, ulClient, SVCF_ONLYTHISCLIENT ); + SERVERCOMMANDS_SetTeamScore( ulIdx, TEAMSCORE_WINS, false, ulClient, SVCF_ONLYTHISCLIENT ); else if ( GAMEMODE_GetCurrentFlags() & GMF_PLAYERSEARNPOINTS ) - SERVERCOMMANDS_SetTeamScore( ulIdx, TEAM_GetScore( ulIdx ), false, ulClient, SVCF_ONLYTHISCLIENT ); + SERVERCOMMANDS_SetTeamScore( ulIdx, TEAMSCORE_POINTS, false, ulClient, SVCF_ONLYTHISCLIENT ); else if ( GAMEMODE_GetCurrentFlags() & GMF_PLAYERSEARNFRAGS ) - SERVERCOMMANDS_SetTeamFrags( ulIdx, TEAM_GetFragCount( ulIdx ), false, ulClient, SVCF_ONLYTHISCLIENT ); + SERVERCOMMANDS_SetTeamScore( ulIdx, TEAMSCORE_FRAGS, false, ulClient, SVCF_ONLYTHISCLIENT ); } } diff -r 0cace8154daa -r f79c58a9b4d3 src/team.cpp --- a/src/team.cpp Tue Nov 23 12:14:54 2021 -0500 +++ b/src/team.cpp Wed Nov 24 11:44:48 2021 -0500 @@ -1056,7 +1056,7 @@ // If we're the server, tell clients about the team score update. if ( NETWORK_GetState( ) == NETSTATE_SERVER ) { - SERVERCOMMANDS_SetTeamScore( ulTeamIdx, lScore, bAnnouncer ); + SERVERCOMMANDS_SetTeamScore( ulTeamIdx, TEAMSCORE_POINTS, bAnnouncer ); // Also, update the scoreboard. SERVERCONSOLE_UpdateScoreboard( ); @@ -1333,7 +1333,7 @@ // If we're the server, let clients know that the score has changed. if ( NETWORK_GetState( ) == NETSTATE_SERVER ) { - SERVERCOMMANDS_SetTeamFrags( ulTeamIdx, lFragCount, bAnnounce ); + SERVERCOMMANDS_SetTeamScore( ulTeamIdx, TEAMSCORE_FRAGS, bAnnounce ); // Also, update the scoreboard. SERVERCONSOLE_UpdateScoreboard( ); @@ -1399,7 +1399,7 @@ // If we're the server, tell clients about the team score update. if ( NETWORK_GetState( ) == NETSTATE_SERVER ) { - SERVERCOMMANDS_SetTeamWins( ulTeamIdx, lWinCount, bAnnounce ); + SERVERCOMMANDS_SetTeamScore( ulTeamIdx, TEAMSCORE_WINS, bAnnounce ); // Also, update the scoreboard. SERVERCONSOLE_UpdateScoreboard( );