# HG changeset patch # User Adam Kaminski # Date 1618169586 14400 # Sun Apr 11 15:33:06 2021 -0400 # Node ID befdbef3a7cbb576573262e4c91b132bfe0de7f3 # Parent 1bf40bcf61ab191e214fefc1b9fc3daab7e828c6 The SetCurrentGamemode ACS function now restarts the game every time the game mode change is successful. diff -r 1bf40bcf61ab -r befdbef3a7cb src/g_level.cpp --- a/src/g_level.cpp Tue Mar 23 11:20:53 2021 -0400 +++ b/src/g_level.cpp Sun Apr 11 15:33:06 2021 -0400 @@ -211,15 +211,8 @@ // Turn campaign mode back on. CAMPAIGN_EnableCampaign( ); - // Reset the duel and LMS modules. - if ( duel ) - DUEL_SetState( DS_WAITINGFORPLAYERS ); - if ( lastmanstanding || teamlms ) - LASTMANSTANDING_SetState( LMSS_WAITINGFORPLAYERS ); - if ( possession || teampossession ) - POSSESSION_SetState( PSNS_WAITINGFORPLAYERS ); - if ( invasion ) - INVASION_SetState( IS_WAITINGFORPLAYERS ); + // [AK] Reset the game mode's state. + GAMEMODE_SetState( GAMESTATE_WAITFORPLAYERS ); G_DeferedInitNew (argv[1]); } diff -r 1bf40bcf61ab -r befdbef3a7cb src/gamemode.cpp --- a/src/gamemode.cpp Tue Mar 23 11:20:53 2021 -0400 +++ b/src/gamemode.cpp Sun Apr 11 15:33:06 2021 -0400 @@ -1138,9 +1138,6 @@ UCVarValue Val; g_CurrentGameMode = GameMode; - // [AK] Set any locked flags to what they're supposed to be in the new game mode. - GAMEMODE_ReconfigureGameSettings(); - // [RC] Set all the CVars. We can't just use "= true;" because of the latched cvars. // (Hopefully Blzut's update will save us from this garbage.) @@ -1265,41 +1262,6 @@ //***************************************************************************** // -ULONG GAMEMODE_GetCountdownTicks( void ) -{ - if ( survival ) - return ( SURVIVAL_GetCountdownTicks() ); - else if ( invasion ) - return ( INVASION_GetCountdownTicks() ); - else if ( duel ) - return ( DUEL_GetCountdownTicks() ); - else if ( teamlms || lastmanstanding ) - return ( LASTMANSTANDING_GetCountdownTicks() ); - else if ( possession || teampossession ) - return ( POSSESSION_GetCountdownTicks() ); - - // [AK] The other gamemodes don't have a countdown, so just return zero. - return 0; -} - -//***************************************************************************** -// -void GAMEMODE_SetCountdownTicks( const ULONG Ticks ) -{ - if ( survival ) - SURVIVAL_SetCountdownTicks( Ticks ); - else if ( invasion ) - INVASION_SetCountdownTicks( Ticks ); - else if ( duel ) - DUEL_SetCountdownTicks( Ticks ); - else if ( teamlms || lastmanstanding ) - LASTMANSTANDING_SetCountdownTicks( Ticks ); - else if ( possession || teampossession ) - POSSESSION_SetCountdownTicks( Ticks ); -} - -//***************************************************************************** -// void GAMEMODE_SetLimit( GAMELIMIT_e GameLimit, int value ) { UCVarValue Val; diff -r 1bf40bcf61ab -r befdbef3a7cb src/gamemode.h --- a/src/gamemode.h Tue Mar 23 11:20:53 2021 -0400 +++ b/src/gamemode.h Sun Apr 11 15:33:06 2021 -0400 @@ -216,9 +216,6 @@ void GAMEMODE_SetCurrentMode( GAMEMODE_e GameMode ); MODIFIER_e GAMEMODE_GetModifier( void ); void GAMEMODE_SetModifier( MODIFIER_e Modifier ); - -ULONG GAMEMODE_GetCountdownTicks( void ); -void GAMEMODE_SetCountdownTicks( const ULONG Ticks ); void GAMEMODE_SetLimit( GAMELIMIT_e GameLimit, int value ); void GAMEMODE_ReconfigureGameSettings( bool bLockedOnly = false ); diff -r 1bf40bcf61ab -r befdbef3a7cb src/p_acs.cpp --- a/src/p_acs.cpp Tue Mar 23 11:20:53 2021 -0400 +++ b/src/p_acs.cpp Sun Apr 11 15:33:06 2021 -0400 @@ -7275,9 +7275,7 @@ { const char *name = FBehavior::StaticLookupString( args[0] ); const GAMEMODE_e oldmode = GAMEMODE_GetCurrentMode(); - const GAMESTATE_e state = GAMEMODE_GetState(); GAMEMODE_e newmode; - ULONG ulCountdownTicks; // [AK] Only the server should change the gamemode, but not during the result sequence. if ( NETWORK_InClientMode() || state == GAMESTATE_INRESULTSEQUENCE ) @@ -7323,42 +7321,13 @@ return 0; } - // [AK] Get the ticks left in the countdown and reset the gamemode, if necessary. - ulCountdownTicks = GAMEMODE_GetCountdownTicks(); - GAMEMODE_SetState( GAMESTATE_WAITFORPLAYERS ); - // [AK] If everything's okay now, change the gamemode. - GAMEMODE_ResetSpecalGamemodeStates(); GAMEMODE_SetCurrentMode( newmode ); - // [AK] If we're the server, tell the clients to change the gamemode too. - if ( NETWORK_GetState() == NETSTATE_SERVER ) - SERVERCOMMANDS_SetGameMode(); - - // [AK] Remove players from any teams if the new gamemode doesn't support them. - if (( GAMEMODE_GetFlags( oldmode ) & GMF_PLAYERSONTEAMS ) && ( GAMEMODE_GetCurrentFlags() & GMF_PLAYERSONTEAMS ) == false ) - { - for ( ULONG ulIdx = 0; ulIdx < MAXPLAYERS; ulIdx++ ) - PLAYER_SetTeam( &players[ulIdx], teams.Size(), true ); - } - // [AK] If we need to move players into teams instead, assign them automatically. - else if (( GAMEMODE_GetFlags( oldmode ) & GMF_PLAYERSONTEAMS ) == false && ( GAMEMODE_GetCurrentFlags() & GMF_PLAYERSONTEAMS )) - { - for ( ULONG ulIdx = 0; ulIdx < MAXPLAYERS; ulIdx++ ) - { - if ( playeringame[ulIdx] && players[ulIdx].bSpectating == false && players[ulIdx].bOnTeam == false ) - PLAYER_SetTeam( &players[ulIdx], TEAM_ChooseBestTeamForPlayer(), true ); - } - } - - // [AK] If necessary, transfer the countdown time and state to the new gamemode. - if ( state > GAMESTATE_WAITFORPLAYERS ) - { - GAMEMODE_SetCountdownTicks( ulCountdownTicks ); - GAMEMODE_SetState( state ); - } - - GAMEMODE_SpawnSpecialGamemodeThings(); + // [AK] We should also start a new game, so just execute the "map" CCMD to do this. + FString command; + command.Format( "map %s", level.mapname ); + C_DoCommand( command.GetChars()); return 1; } return 0;