From ff89f5f4c6deff65fab5f08f32e6d2bb07c7a632 Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Fri, 8 Jan 2021 16:21:54 +0100 Subject: [PATCH] Fix 8f3d1ec: "restart" did not always restart your current game In the sequence: - Load a game - Start a newgame (via console) - Restart a game (via console) Gave you the loaded game back, not the new game. --- src/openttd.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/openttd.cpp b/src/openttd.cpp index 41900933a4..805e591b98 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -928,6 +928,10 @@ static void MakeNewGameDone() static void MakeNewGame(bool from_heightmap, bool reset_settings) { _game_mode = GM_NORMAL; + if (!from_heightmap) { + /* "reload" command needs to know what mode we were in. */ + _file_to_saveload.SetMode(SLO_INVALID, FT_INVALID, DFT_INVALID); + } ResetGRFConfig(true); @@ -943,6 +947,8 @@ static void MakeNewEditorWorldDone() static void MakeNewEditorWorld() { _game_mode = GM_EDITOR; + /* "reload" command needs to know what mode we were in. */ + _file_to_saveload.SetMode(SLO_INVALID, FT_INVALID, DFT_INVALID); ResetGRFConfig(true); @@ -1052,9 +1058,9 @@ void SwitchToMode(SwitchMode new_mode) SwitchToMode(_switch_mode); break; } - /* No break here, to enter the next case: - * Restart --> 'Random game' with current settings */ - FALLTHROUGH; + + MakeNewGame(false, new_mode == SM_NEWGAME); + break; case SM_NEWGAME: // New Game --> 'Random game' if (_network_server) {