mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-08 23:19:40 +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
3ecf335718
commit
ba4fd897b8
@ -952,13 +952,16 @@ DEF_CONSOLE_CMD(ConRestart)
|
|||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
IConsoleHelp("Restart game. Usage: 'restart'");
|
IConsoleHelp("Restart game. Usage: 'restart'");
|
||||||
IConsoleHelp("Restarts a game. It tries to reproduce the exact same map as the game started with.");
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Don't copy the _newgame pointers to the real pointers, so call SwitchToMode directly */
|
/* 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_x = MapLogX();
|
||||||
_settings_game.game_creation.map_y = FindFirstBit(MapSizeY());
|
_settings_game.game_creation.map_y = FindFirstBit(MapSizeY());
|
||||||
SwitchToMode(SM_NEWGAME);
|
SwitchToMode(SM_RESTARTGAME);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ void StartupEconomy();
|
|||||||
void StartupCompanies();
|
void StartupCompanies();
|
||||||
void StartupDisasters();
|
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
|
/* Please only use this variable in genworld.h and genworld.c and
|
||||||
* nowhere else. For speed improvements we need it to be global, but
|
* 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_x The X-size of the map.
|
||||||
* @param size_y The Y-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;
|
if (_gw.active) return;
|
||||||
_gw.mode = mode;
|
_gw.mode = mode;
|
||||||
@ -281,7 +281,7 @@ void GenerateWorld(GenerateWorldMode mode, uint size_x, uint size_y)
|
|||||||
GfxLoadSprites();
|
GfxLoadSprites();
|
||||||
LoadStringWidthTable();
|
LoadStringWidthTable();
|
||||||
|
|
||||||
InitializeGame(_gw.size_x, _gw.size_y, false);
|
InitializeGame(_gw.size_x, _gw.size_y, false, reset_settings);
|
||||||
PrepareGenerateWorldProgress();
|
PrepareGenerateWorldProgress();
|
||||||
|
|
||||||
/* Re-init the windowing system */
|
/* Re-init the windowing system */
|
||||||
|
@ -74,7 +74,7 @@ bool IsGenerateWorldThreaded();
|
|||||||
void GenerateWorldSetCallback(gw_done_proc *proc);
|
void GenerateWorldSetCallback(gw_done_proc *proc);
|
||||||
void GenerateWorldSetAbortCallback(gw_abort_proc *proc);
|
void GenerateWorldSetAbortCallback(gw_abort_proc *proc);
|
||||||
void WaitTillGeneratedWorld();
|
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();
|
void AbortGeneratingWorld();
|
||||||
bool IsGeneratingWorldAborted();
|
bool IsGeneratingWorldAborted();
|
||||||
void HandleGeneratingWorldAbortion();
|
void HandleGeneratingWorldAbortion();
|
||||||
|
@ -52,7 +52,7 @@ void InitializeCheats();
|
|||||||
void InitializeNPF();
|
void InitializeNPF();
|
||||||
void InitializeOldNames();
|
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
|
/* Make sure there isn't any window that can influence anything
|
||||||
* related to the new game we're about to start/load. */
|
* 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;
|
_date_fract = 0;
|
||||||
_cur_tileloop_tile = 0;
|
_cur_tileloop_tile = 0;
|
||||||
_thd.redsq = INVALID_TILE;
|
_thd.redsq = INVALID_TILE;
|
||||||
MakeNewgameSettingsLive();
|
if (reset_settings) MakeNewgameSettingsLive();
|
||||||
|
|
||||||
if (reset_date) {
|
if (reset_date) {
|
||||||
SetDate(ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1));
|
SetDate(ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1));
|
||||||
|
@ -796,7 +796,7 @@ static void MakeNewGameDone()
|
|||||||
MarkWholeScreenDirty();
|
MarkWholeScreenDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MakeNewGame(bool from_heightmap)
|
static void MakeNewGame(bool from_heightmap, bool reset_settings)
|
||||||
{
|
{
|
||||||
_game_mode = GM_NORMAL;
|
_game_mode = GM_NORMAL;
|
||||||
|
|
||||||
@ -807,7 +807,7 @@ static void MakeNewGame(bool from_heightmap)
|
|||||||
_industry_mngr.ResetMapping();
|
_industry_mngr.ResetMapping();
|
||||||
|
|
||||||
GenerateWorldSetCallback(&MakeNewGameDone);
|
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()
|
static void MakeNewEditorWorldDone()
|
||||||
@ -915,7 +915,7 @@ void SwitchToMode(SwitchMode new_mode)
|
|||||||
if (new_mode != SM_SAVE) {
|
if (new_mode != SM_SAVE) {
|
||||||
/* If the network is active, make it not-active */
|
/* If the network is active, make it not-active */
|
||||||
if (_networking) {
|
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();
|
NetworkReboot();
|
||||||
} else {
|
} else {
|
||||||
NetworkDisconnect();
|
NetworkDisconnect();
|
||||||
@ -948,13 +948,14 @@ void SwitchToMode(SwitchMode new_mode)
|
|||||||
MakeNewEditorWorld();
|
MakeNewEditorWorld();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SM_RESTARTGAME: // Restart --> 'Random game' with current settings
|
||||||
case SM_NEWGAME: // New Game --> 'Random game'
|
case SM_NEWGAME: // New Game --> 'Random game'
|
||||||
#ifdef ENABLE_NETWORK
|
#ifdef ENABLE_NETWORK
|
||||||
if (_network_server) {
|
if (_network_server) {
|
||||||
snprintf(_network_game_info.map_name, lengthof(_network_game_info.map_name), "Random Map");
|
snprintf(_network_game_info.map_name, lengthof(_network_game_info.map_name), "Random Map");
|
||||||
}
|
}
|
||||||
#endif /* ENABLE_NETWORK */
|
#endif /* ENABLE_NETWORK */
|
||||||
MakeNewGame(false);
|
MakeNewGame(false, new_mode == SM_NEWGAME);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SM_START_SCENARIO: // New Game --> Choose one of the preset scenarios
|
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);
|
snprintf(_network_game_info.map_name, lengthof(_network_game_info.map_name), "%s (Heightmap)", _file_to_saveload.title);
|
||||||
}
|
}
|
||||||
#endif /* ENABLE_NETWORK */
|
#endif /* ENABLE_NETWORK */
|
||||||
MakeNewGame(true);
|
MakeNewGame(true, true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SM_LOAD_HEIGHTMAP: // Load heightmap from scenario editor
|
case SM_LOAD_HEIGHTMAP: // Load heightmap from scenario editor
|
||||||
|
@ -16,6 +16,7 @@ enum GameMode {
|
|||||||
enum SwitchMode {
|
enum SwitchMode {
|
||||||
SM_NONE,
|
SM_NONE,
|
||||||
SM_NEWGAME,
|
SM_NEWGAME,
|
||||||
|
SM_RESTARTGAME,
|
||||||
SM_EDITOR,
|
SM_EDITOR,
|
||||||
SM_LOAD,
|
SM_LOAD,
|
||||||
SM_MENU,
|
SM_MENU,
|
||||||
|
@ -1633,7 +1633,7 @@ static const SaveLoadFormat *GetSavegameFormat(const char *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* actual loader/saver function */
|
/* 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 AfterLoadGame();
|
||||||
extern bool LoadOldSaveGame(const char *file);
|
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 */
|
/* Load a TTDLX or TTDPatch game */
|
||||||
if (mode == SL_OLD_LOAD) {
|
if (mode == SL_OLD_LOAD) {
|
||||||
_engine_mngr.ResetToDefaultMapping();
|
_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();
|
GamelogReset();
|
||||||
if (!LoadOldSaveGame(filename)) return SL_REINIT;
|
if (!LoadOldSaveGame(filename)) return SL_REINIT;
|
||||||
_sl_version = 0;
|
_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
|
/* Old maps were hardcoded to 256x256 and thus did not contain
|
||||||
* any mapsize information. Pre-initialize to 256x256 to not to
|
* any mapsize information. Pre-initialize to 256x256 to not to
|
||||||
* confuse old games */
|
* confuse old games */
|
||||||
InitializeGame(256, 256, true);
|
InitializeGame(256, 256, true, true);
|
||||||
|
|
||||||
GamelogReset();
|
GamelogReset();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user