@ -832,15 +832,30 @@ void HandleExitGameRequest()
}
}
/**
* Triggers everything that should be triggered when starting a game .
* @ param dedicated_server Whether this is a dedicated server or not .
*/
static void OnStartGame ( bool dedicated_server )
{
/* Update the local company for a loaded game. It is either always
* company # 1 ( eg 0 ) or in the case of a dedicated server a spectator */
SetLocalCompany ( dedicated_server ? COMPANY_SPECTATOR : COMPANY_FIRST ) ;
/* Update the static game info to set the values from the new game. */
NetworkServerUpdateGameInfo ( ) ;
/* Execute the game-start script */
IConsoleCmdExec ( " exec scripts/game_start.scr 0 " ) ;
}
static void MakeNewGameDone ( )
{
SettingsDisableElrail ( _settings_game . vehicle . disable_elrails ) ;
/* In a dedicated server, the server does not play */
if ( ! VideoDriver : : GetInstance ( ) - > HasGUI ( ) ) {
SetLocalCompany ( COMPANY_SPECTATOR ) ;
OnStartGame( true ) ;
if ( _settings_client . gui . pause_on_newgame ) DoCommandP ( 0 , PM_PAUSED_NORMAL , 1 , CMD_PAUSE ) ;
IConsoleCmdExec ( " exec scripts/game_start.scr 0 " ) ;
return ;
}
@ -858,9 +873,7 @@ static void MakeNewGameDone()
_company_colours [ c - > index ] = ( Colours ) c - > colour ;
}
IConsoleCmdExec ( " exec scripts/game_start.scr 0 " ) ;
SetLocalCompany ( COMPANY_FIRST ) ;
OnStartGame ( false ) ;
InitializeRailGUI ( ) ;
InitializeRoadGUI ( ) ;
@ -1032,11 +1045,7 @@ void SwitchToMode(SwitchMode new_mode)
/* Reset engine pool to simplify changing engine NewGRFs in scenario editor. */
EngineOverrideManager : : ResetToCurrentNewGRFConfig ( ) ;
}
/* Update the local company for a loaded game. It is either always
* company # 1 ( eg 0 ) or in the case of a dedicated server a spectator */
SetLocalCompany ( _network_dedicated ? COMPANY_SPECTATOR : COMPANY_FIRST ) ;
/* Execute the game-start script */
IConsoleCmdExec ( " exec scripts/game_start.scr 0 " ) ;
OnStartGame ( _network_dedicated ) ;
/* Decrease pause counter (was increased from opening load dialog) */
DoCommandP ( 0 , PM_PAUSED_SAVELOAD , 0 , CMD_PAUSE ) ;
}