diff --git a/main_gui.c b/main_gui.c index 89f2611bf0..2c8c1a2aeb 100644 --- a/main_gui.c +++ b/main_gui.c @@ -1067,7 +1067,7 @@ static void ResetLandscape(void) _random_seeds[0][0] = InteractiveRandom(); _random_seeds[0][1] = InteractiveRandom(); - GenerateWorld(1, 1 << _patches.map_x, 1 << _patches.map_y); + GenerateWorld(GW_EMPTY, 1 << _patches.map_x, 1 << _patches.map_y); MarkWholeScreenDirty(); } diff --git a/misc.c b/misc.c index 1e2993a21b..8abbc5bf8f 100644 --- a/misc.c +++ b/misc.c @@ -122,7 +122,7 @@ void GenerateTrees(void); void ConvertGroundTilesIntoWaterTiles(void); -void InitializeGame(uint size_x, uint size_y) +void InitializeGame(int mode, uint size_x, uint size_y) { AllocateMap(size_x, size_y); @@ -136,7 +136,7 @@ void InitializeGame(uint size_x, uint size_y) _date_fract = 0; _cur_tileloop_tile = 0; - { + if ((mode & IG_DATE_RESET) == IG_DATE_RESET) { uint starting = ConvertIntDate(_patches.starting_date); if ( starting == (uint)-1) starting = 10958; SetDate(starting); @@ -189,14 +189,14 @@ void GenerateWorld(int mode, uint size_x, uint size_y) _current_player = OWNER_NONE; _generating_world = true; - InitializeGame(size_x, size_y); + InitializeGame(mode == GW_RANDOM ? 0 : IG_DATE_RESET, size_x, size_y); SetObjectToPlace(SPR_CURSOR_ZZZ, 0, 0, 0); // Must start economy early because of the costs. StartupEconomy(); // Don't generate landscape items when in the scenario editor. - if (mode == 1) { + if (mode == GW_EMPTY) { // empty world in scenario editor ConvertGroundTilesIntoWaterTiles(); } else { @@ -204,7 +204,7 @@ void GenerateWorld(int mode, uint size_x, uint size_y) GenerateClearTile(); // only generate towns, tree and industries in newgame mode. - if (mode == 0) { + if (mode == GW_NEWGAME) { GenerateTowns(); GenerateTrees(); GenerateIndustries(); @@ -219,7 +219,7 @@ void GenerateWorld(int mode, uint size_x, uint size_y) _generating_world = false; // No need to run the tile loop in the scenario editor. - if (mode != 1) { + if (mode != GW_EMPTY) { for(i=0x500; i!=0; i--) RunTileLoop(); } diff --git a/openttd.c b/openttd.c index b18850069c..f6daae393b 100644 --- a/openttd.c +++ b/openttd.c @@ -279,7 +279,7 @@ static void LoadIntroGame(void) sprintf(filename, "%sopntitle.dat", _path.second_data_dir); if (SaveOrLoad(filename, SL_LOAD) != SL_OK) #endif - GenerateWorld(1, 64, 64); // if failed loading, make empty world. + GenerateWorld(GW_EMPTY, 64, 64); // if failed loading, make empty world. } _pause = 0; @@ -461,7 +461,7 @@ int ttd_main(int argc, char* argv[]) InitializeGUI(); IConsoleCmdExec("exec scripts/autoexec.scr 0"); - GenerateWorld(1, 64, 64); // Make the viewport initialization happy + GenerateWorld(GW_EMPTY, 64, 64); // Make the viewport initialization happy #ifdef ENABLE_NETWORK if ((network) && (_network_available)) { @@ -582,7 +582,7 @@ static void MakeNewGame(void) SetupColorsAndInitialWindow(); // Randomize world - GenerateWorld(0, 1<<_patches.map_x, 1<<_patches.map_y); + GenerateWorld(GW_NEWGAME, 1<<_patches.map_x, 1<<_patches.map_y); // In a dedicated server, the server does not play if (_network_dedicated) { @@ -616,7 +616,7 @@ static void MakeNewEditorWorld(void) SetupColorsAndInitialWindow(); // Startup the game system - GenerateWorld(1, 1 << _patches.map_x, 1 << _patches.map_y); + GenerateWorld(GW_EMPTY, 1 << _patches.map_x, 1 << _patches.map_y); _local_player = OWNER_NONE; MarkWholeScreenDirty(); @@ -797,7 +797,7 @@ void SwitchMode(int new_mode) break; case SM_GENRANDLAND: /* Generate random land within scenario editor */ - GenerateWorld(2, 1<<_patches.map_x, 1<<_patches.map_y); + GenerateWorld(GW_RANDOM, 1<<_patches.map_x, 1<<_patches.map_y); // XXX: set date _local_player = OWNER_NONE; MarkWholeScreenDirty(); diff --git a/openttd.h b/openttd.h index 81ed0b908c..f2ae7684e9 100644 --- a/openttd.h +++ b/openttd.h @@ -93,6 +93,21 @@ enum SwitchModes { SM_START_SCENARIO = 10, }; + +/* Modes for GenerateWorld */ +enum GenerateWorldModes { + GW_NEWGAME = 0, /* Generate a map for a new game */ + GW_EMPTY = 1, /* Generate an empty map (sea-level) */ + GW_RANDOM = 2, /* Generate a random map for SE */ +}; + +/* Modes for InitializeGame, those are _bits_! */ +enum InitializeGameModes { + IG_NONE = 0, /* Don't do anything special */ + IG_DATE_RESET = 1, /* Reset the date when initializing a game */ +}; + + typedef enum TransportTypes { /* These constants are for now linked to the representation of bridges * and tunnels, so they can be used by GetTileTrackStatus_TunnelBridge diff --git a/saveload.c b/saveload.c index 339746342b..827abe6979 100644 --- a/saveload.c +++ b/saveload.c @@ -1232,7 +1232,7 @@ static const SaveLoadFormat *GetSavegameFormat(const char *s) } // actual loader/saver function -void InitializeGame(uint size_x, uint size_y); +void InitializeGame(int mode, uint size_x, uint size_y); extern bool AfterLoadGame(void); extern void BeforeSaveGame(void); extern bool LoadOldSaveGame(const char *file); @@ -1363,7 +1363,7 @@ SaveOrLoadResult SaveOrLoad(const char *filename, int mode) /* Load a TTDLX or TTDPatch game */ if (mode == SL_OLD_LOAD) { - InitializeGame(256, 256); // set a mapsize of 256x256 for TTDPatch games or it might get confused + InitializeGame(IG_DATE_RESET, 256, 256); // set a mapsize of 256x256 for TTDPatch games or it might get confused if (!LoadOldSaveGame(filename)) return SL_REINIT; _sl_version = 0; AfterLoadGame(); @@ -1487,7 +1487,7 @@ SaveOrLoadResult SaveOrLoad(const char *filename, int mode) /* 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); + InitializeGame(IG_DATE_RESET, 256, 256); SlLoadChunks(); fmt->uninit_read();