summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-08-06 22:00:32 +0000
committerrubidium <rubidium@openttd.org>2009-08-06 22:00:32 +0000
commitba4fd897b823fa4dc36ad3fbf0db36b94b95628b (patch)
treef68e0b5d1bb325182e763285855fca5dfd128856
parent3ecf3357181c0f01896d97d0a7b40bf9206d7327 (diff)
downloadopenttd-ba4fd897b823fa4dc36ad3fbf0db36b94b95628b.tar.xz
(svn r17097) -Fix [FS#3092] (r13256): make restart command work again and make the help show how it works and how it doesn't work
-rw-r--r--src/console_cmds.cpp5
-rw-r--r--src/genworld.cpp6
-rw-r--r--src/genworld.h2
-rw-r--r--src/misc.cpp4
-rw-r--r--src/openttd.cpp11
-rw-r--r--src/openttd.h1
-rw-r--r--src/saveload/saveload.cpp6
7 files changed, 20 insertions, 15 deletions
diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp
index 64070e7cf..dd4f96fac 100644
--- a/src/console_cmds.cpp
+++ b/src/console_cmds.cpp
@@ -952,13 +952,16 @@ DEF_CONSOLE_CMD(ConRestart)
if (argc == 0) {
IConsoleHelp("Restart game. Usage: 'restart'");
IConsoleHelp("Restarts a game. It tries to reproduce the exact same map as the game started with.");
+ IConsoleHelp("However:");
+ IConsoleHelp(" * restarting games started in another version might create another map due to difference in map generation");
+ IConsoleHelp(" * restarting games based on scenarios, loaded games or heightmaps will start a new game based on the settings stored in the scenario/savegame");
return true;
}
/* Don't copy the _newgame pointers to the real pointers, so call SwitchToMode directly */
_settings_game.game_creation.map_x = MapLogX();
_settings_game.game_creation.map_y = FindFirstBit(MapSizeY());
- SwitchToMode(SM_NEWGAME);
+ SwitchToMode(SM_RESTARTGAME);
return true;
}
diff --git a/src/genworld.cpp b/src/genworld.cpp
index 5dc204956..bbe6d5b27 100644
--- a/src/genworld.cpp
+++ b/src/genworld.cpp
@@ -39,7 +39,7 @@ void StartupEconomy();
void StartupCompanies();
void StartupDisasters();
-void InitializeGame(uint size_x, uint size_y, bool reset_date);
+void InitializeGame(uint size_x, uint size_y, bool reset_date, bool reset_settings);
/* Please only use this variable in genworld.h and genworld.c and
* nowhere else. For speed improvements we need it to be global, but
@@ -256,7 +256,7 @@ void HandleGeneratingWorldAbortion()
* @param size_x The X-size of the map.
* @param size_y The Y-size of the map.
*/
-void GenerateWorld(GenerateWorldMode mode, uint size_x, uint size_y)
+void GenerateWorld(GenerateWorldMode mode, uint size_x, uint size_y, bool reset_settings)
{
if (_gw.active) return;
_gw.mode = mode;
@@ -281,7 +281,7 @@ void GenerateWorld(GenerateWorldMode mode, uint size_x, uint size_y)
GfxLoadSprites();
LoadStringWidthTable();
- InitializeGame(_gw.size_x, _gw.size_y, false);
+ InitializeGame(_gw.size_x, _gw.size_y, false, reset_settings);
PrepareGenerateWorldProgress();
/* Re-init the windowing system */
diff --git a/src/genworld.h b/src/genworld.h
index 522d93f46..d94b156f6 100644
--- a/src/genworld.h
+++ b/src/genworld.h
@@ -74,7 +74,7 @@ bool IsGenerateWorldThreaded();
void GenerateWorldSetCallback(gw_done_proc *proc);
void GenerateWorldSetAbortCallback(gw_abort_proc *proc);
void WaitTillGeneratedWorld();
-void GenerateWorld(GenerateWorldMode mode, uint size_x, uint size_y);
+void GenerateWorld(GenerateWorldMode mode, uint size_x, uint size_y, bool reset_settings = true);
void AbortGeneratingWorld();
bool IsGeneratingWorldAborted();
void HandleGeneratingWorldAbortion();
diff --git a/src/misc.cpp b/src/misc.cpp
index 24bad8255..34e68e860 100644
--- a/src/misc.cpp
+++ b/src/misc.cpp
@@ -52,7 +52,7 @@ void InitializeCheats();
void InitializeNPF();
void InitializeOldNames();
-void InitializeGame(uint size_x, uint size_y, bool reset_date)
+void InitializeGame(uint size_x, uint size_y, bool reset_date, bool reset_settings)
{
/* Make sure there isn't any window that can influence anything
* related to the new game we're about to start/load. */
@@ -69,7 +69,7 @@ void InitializeGame(uint size_x, uint size_y, bool reset_date)
_date_fract = 0;
_cur_tileloop_tile = 0;
_thd.redsq = INVALID_TILE;
- MakeNewgameSettingsLive();
+ if (reset_settings) MakeNewgameSettingsLive();
if (reset_date) {
SetDate(ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1));
diff --git a/src/openttd.cpp b/src/openttd.cpp
index 9fddfcb2e..046717db5 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -796,7 +796,7 @@ static void MakeNewGameDone()
MarkWholeScreenDirty();
}
-static void MakeNewGame(bool from_heightmap)
+static void MakeNewGame(bool from_heightmap, bool reset_settings)
{
_game_mode = GM_NORMAL;
@@ -807,7 +807,7 @@ static void MakeNewGame(bool from_heightmap)
_industry_mngr.ResetMapping();
GenerateWorldSetCallback(&MakeNewGameDone);
- GenerateWorld(from_heightmap ? GW_HEIGHTMAP : GW_NEWGAME, 1 << _settings_game.game_creation.map_x, 1 << _settings_game.game_creation.map_y);
+ GenerateWorld(from_heightmap ? GW_HEIGHTMAP : GW_NEWGAME, 1 << _settings_game.game_creation.map_x, 1 << _settings_game.game_creation.map_y, reset_settings);
}
static void MakeNewEditorWorldDone()
@@ -915,7 +915,7 @@ void SwitchToMode(SwitchMode new_mode)
if (new_mode != SM_SAVE) {
/* If the network is active, make it not-active */
if (_networking) {
- if (_network_server && (new_mode == SM_LOAD || new_mode == SM_NEWGAME)) {
+ if (_network_server && (new_mode == SM_LOAD || new_mode == SM_NEWGAME || new_mode == SM_RESTARTGAME)) {
NetworkReboot();
} else {
NetworkDisconnect();
@@ -948,13 +948,14 @@ void SwitchToMode(SwitchMode new_mode)
MakeNewEditorWorld();
break;
+ case SM_RESTARTGAME: // Restart --> 'Random game' with current settings
case SM_NEWGAME: // New Game --> 'Random game'
#ifdef ENABLE_NETWORK
if (_network_server) {
snprintf(_network_game_info.map_name, lengthof(_network_game_info.map_name), "Random Map");
}
#endif /* ENABLE_NETWORK */
- MakeNewGame(false);
+ MakeNewGame(false, new_mode == SM_NEWGAME);
break;
case SM_START_SCENARIO: // New Game --> Choose one of the preset scenarios
@@ -1000,7 +1001,7 @@ void SwitchToMode(SwitchMode new_mode)
snprintf(_network_game_info.map_name, lengthof(_network_game_info.map_name), "%s (Heightmap)", _file_to_saveload.title);
}
#endif /* ENABLE_NETWORK */
- MakeNewGame(true);
+ MakeNewGame(true, true);
break;
case SM_LOAD_HEIGHTMAP: // Load heightmap from scenario editor
diff --git a/src/openttd.h b/src/openttd.h
index a1a67d6a3..ab4cd8891 100644
--- a/src/openttd.h
+++ b/src/openttd.h
@@ -16,6 +16,7 @@ enum GameMode {
enum SwitchMode {
SM_NONE,
SM_NEWGAME,
+ SM_RESTARTGAME,
SM_EDITOR,
SM_LOAD,
SM_MENU,
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp
index 88be40d72..731679dc5 100644
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -1633,7 +1633,7 @@ static const SaveLoadFormat *GetSavegameFormat(const char *s)
}
/* actual loader/saver function */
-void InitializeGame(uint size_x, uint size_y, bool reset_date);
+void InitializeGame(uint size_x, uint size_y, bool reset_date, bool reset_settings);
extern bool AfterLoadGame();
extern bool LoadOldSaveGame(const char *file);
@@ -1793,7 +1793,7 @@ SaveOrLoadResult SaveOrLoad(const char *filename, int mode, Subdirectory sb)
/* Load a TTDLX or TTDPatch game */
if (mode == SL_OLD_LOAD) {
_engine_mngr.ResetToDefaultMapping();
- InitializeGame(256, 256, true); // set a mapsize of 256x256 for TTDPatch games or it might get confused
+ InitializeGame(256, 256, true, true); // set a mapsize of 256x256 for TTDPatch games or it might get confused
GamelogReset();
if (!LoadOldSaveGame(filename)) return SL_REINIT;
_sl_version = 0;
@@ -1912,7 +1912,7 @@ SaveOrLoadResult SaveOrLoad(const char *filename, int mode, Subdirectory sb)
/* Old maps were hardcoded to 256x256 and thus did not contain
* any mapsize information. Pre-initialize to 256x256 to not to
* confuse old games */
- InitializeGame(256, 256, true);
+ InitializeGame(256, 256, true, true);
GamelogReset();