mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-10-31 15:20:10 +00:00
(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
This commit is contained in:
parent
773bce46a3
commit
e918be12f2
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 */
|
||||
|
@ -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();
|
||||
|
@ -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));
|
||||
|
@ -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
|
||||
|
@ -16,6 +16,7 @@ enum GameMode {
|
||||
enum SwitchMode {
|
||||
SM_NONE,
|
||||
SM_NEWGAME,
|
||||
SM_RESTARTGAME,
|
||||
SM_EDITOR,
|
||||
SM_LOAD,
|
||||
SM_MENU,
|
||||
|
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user