# HG changeset patch # User Adam Kaminski # Date 1630642356 14400 # Fri Sep 03 00:12:36 2021 -0400 # Node ID e7facb14d2df6e389cfe415d956cb233a799b904 # Parent 103f126c10640be1beb3f527d9c9db1ea7b687bb Merged SVC2_ADDTOMAPROTATION and SVC2_DELFROMMAPROTATION into a single server command: SVC2_UPDATEMAPROTATION, which also resets the used status on all maps when they've all been played. diff -r 103f126c1064 -r e7facb14d2df src/cl_main.cpp --- a/src/cl_main.cpp Thu Sep 02 22:26:18 2021 -0400 +++ b/src/cl_main.cpp Fri Sep 03 00:12:36 2021 -0400 @@ -2293,28 +2293,43 @@ } break; - case SVC2_ADDTOMAPROTATION: + case SVC2_UPDATEMAPROTATION: { - const char *pszMapName = pByteStream->ReadString(); - int position = pByteStream->ReadByte(); - ULONG ulMinPlayers = pByteStream->ReadByte(); - ULONG ulMaxPlayers = pByteStream->ReadByte(); - - // [AK] Add this map to the rotation. - MAPROTATION_AddMap( pszMapName, position, ulMinPlayers, ulMaxPlayers, true ); - } - break; - - case SVC2_DELFROMMAPROTATION: - if ( pByteStream->ReadByte() ) - { - // [AK] Clear all maps from the rotation. - MAPROTATION_Construct(); - } - else - { - // [AK] Remove the map with the given name from the rotation. - MAPROTATION_DelMap( pByteStream->ReadString(), true ); + const LONG lType = pByteStream->ReadByte(); + + switch ( lType ) + { + // [AK] Add this map to the rotation using the passed name, position, and player limits. + case UPDATE_MAPROTATION_ADDMAP: + { + const char *pszMapName = pByteStream->ReadString(); + int position = pByteStream->ReadByte(); + ULONG ulMinPlayers = pByteStream->ReadByte(); + ULONG ulMaxPlayers = pByteStream->ReadByte(); + MAPROTATION_AddMap( pszMapName, position, ulMinPlayers, ulMaxPlayers, true ); + break; + } + + // [AK] Remove the map with the given name from the rotation. + case UPDATE_MAPROTATION_DELMAP: + MAPROTATION_DelMap( pByteStream->ReadString(), true ); + break; + + // [AK] Clear all maps from the rotation. + case UPDATE_MAPROTATION_CLEAR: + MAPROTATION_Construct(); + break; + + // [AK] Reset all maps in the rotation. To do this, we'll go through every entry on the list + // and manually set their used status to false. + case UPDATE_MAPROTATION_RESET: + { + ULONG ulNumEntries = MAPROTATION_GetNumEntries(); + for ( ULONG ulIdx = 0; ulIdx < ulNumEntries; ulIdx++ ) + MAPROTATION_SetUsed( ulIdx, false ); + break; + } + } } break; diff -r 103f126c1064 -r e7facb14d2df src/maprotation.cpp --- a/src/maprotation.cpp Thu Sep 02 22:26:18 2021 -0400 +++ b/src/maprotation.cpp Fri Sep 03 00:12:36 2021 -0400 @@ -193,6 +193,10 @@ { for ( ULONG ulIdx = 0; ulIdx < g_MapRotationEntries.size( ); ulIdx++ ) g_MapRotationEntries[ulIdx].bUsed = false; + + // [AK] If we're the server, tell the clients to reset their map lists too. + if ( NETWORK_GetState( ) == NETSTATE_SERVER ) + SERVERCOMMANDS_ResetMapRotation( ); } } diff -r 103f126c1064 -r e7facb14d2df src/network.h --- a/src/network.h Thu Sep 02 22:26:18 2021 -0400 +++ b/src/network.h Fri Sep 03 00:12:36 2021 -0400 @@ -207,6 +207,15 @@ ACTORSCALE_Y = 2 }; +// [AK] If we're updating the map rotation then what exactly are we doing? +enum UpdateMapRotationType +{ + UPDATE_MAPROTATION_ADDMAP, + UPDATE_MAPROTATION_DELMAP, + UPDATE_MAPROTATION_CLEAR, + UPDATE_MAPROTATION_RESET, +}; + // Which actor sound is being updated? #define ACTORSOUND_SEESOUND 1 #define ACTORSOUND_ATTACKSOUND 2 diff -r 103f126c1064 -r e7facb14d2df src/network_enums.h --- a/src/network_enums.h Thu Sep 02 22:26:18 2021 -0400 +++ b/src/network_enums.h Fri Sep 03 00:12:36 2021 -0400 @@ -377,8 +377,7 @@ ENUM_ELEMENT ( SVC2_SETLINETEXTUREOFFSETBYID ), ENUM_ELEMENT ( SVC2_SETLINETEXTURESCALEBYID ), ENUM_ELEMENT ( SVC2_SYNCMAPROTATION ), - ENUM_ELEMENT ( SVC2_ADDTOMAPROTATION ), - ENUM_ELEMENT ( SVC2_DELFROMMAPROTATION ), + ENUM_ELEMENT ( SVC2_UPDATEMAPROTATION ), ENUM_ELEMENT ( SVC2_STOPALLSOUNDSONTHING ), // [BB] Commands necessary for the account system. ENUM_ELEMENT ( SVC2_SRP_USER_START_AUTHENTICATION ), diff -r 103f126c1064 -r e7facb14d2df src/sv_commands.cpp --- a/src/sv_commands.cpp Thu Sep 02 22:26:18 2021 -0400 +++ b/src/sv_commands.cpp Fri Sep 03 00:12:36 2021 -0400 @@ -5007,7 +5007,8 @@ if (( pszMapName == NULL ) || ( FindLevelByName( pszMapName ) == NULL )) return; - NetCommand command ( SVC2_ADDTOMAPROTATION ); + NetCommand command ( SVC2_UPDATEMAPROTATION ); + command.addByte( UPDATE_MAPROTATION_ADDMAP ); command.addString( pszMapName ); command.addByte( position ); command.addByte( ulMinPlayers ); @@ -5019,8 +5020,8 @@ // [AK] void SERVERCOMMANDS_DelFromMapRotation( const char *pszMapName, bool bClear, ULONG ulPlayerExtra, ServerCommandFlags flags ) { - NetCommand command ( SVC2_DELFROMMAPROTATION ); - command.addByte( bClear ); + NetCommand command ( SVC2_UPDATEMAPROTATION ); + command.addByte( bClear ? UPDATE_MAPROTATION_CLEAR : UPDATE_MAPROTATION_DELMAP ); // [AK] We should only send a map name if we're not clearing the map list. if ( bClear == false ) @@ -5035,6 +5036,15 @@ } //***************************************************************************** +// [AK] +void SERVERCOMMANDS_ResetMapRotation( ULONG ulPlayerExtra, ServerCommandFlags flags ) +{ + NetCommand command ( SVC2_UPDATEMAPROTATION ); + command.addByte( UPDATE_MAPROTATION_RESET ); + command.sendCommandToClients( ulPlayerExtra, flags ); +} + +//***************************************************************************** void APathFollower::SyncWithClient ( const ULONG ulClient ) { if ( !EnsureActorHasNetID (this) ) diff -r 103f126c1064 -r e7facb14d2df src/sv_commands.h --- a/src/sv_commands.h Thu Sep 02 22:26:18 2021 -0400 +++ b/src/sv_commands.h Fri Sep 03 00:12:36 2021 -0400 @@ -462,5 +462,6 @@ void SERVERCOMMANDS_SyncMapRotation( ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); void SERVERCOMMANDS_AddToMapRotation( const char *pszMapName, int position, ULONG ulMinPlayers, ULONG ulMaxPlayers, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); void SERVERCOMMANDS_DelFromMapRotation( const char *pszMapName, bool bClear = false, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); +void SERVERCOMMANDS_ResetMapRotation( ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); #endif // __SV_COMMANDS_H__