Mercurial > hg > openttd
changeset 2828:e12c87420dcd draft
(svn r3376) -Codechange: made enums for GenerateWorld and InitializeGame 'mode'
-Fix: [ FS#30 ] don't reset date in SE when pressing RandomLand (rewrote patch of MeusH, but Peter warned me I should put his name in, so... oh well)
author | truelight <truelight@openttd.org> |
---|---|
date | Fri, 06 Jan 2006 21:57:37 +0000 |
parents | b948ed221db9 |
children | 29c943af24b3 |
files | main_gui.c misc.c openttd.c openttd.h saveload.c |
diffstat | 5 files changed, 30 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/main_gui.c +++ b/main_gui.c @@ -1067,7 +1067,7 @@ _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(); }
--- a/misc.c +++ b/misc.c @@ -122,7 +122,7 @@ 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 @@ _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 @@ _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 @@ GenerateClearTile(); // only generate towns, tree and industries in newgame mode. - if (mode == 0) { + if (mode == GW_NEWGAME) { GenerateTowns(); GenerateTrees(); GenerateIndustries(); @@ -219,7 +219,7 @@ _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(); }
--- a/openttd.c +++ b/openttd.c @@ -279,7 +279,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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();
--- a/openttd.h +++ b/openttd.h @@ -93,6 +93,21 @@ 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
--- a/saveload.c +++ b/saveload.c @@ -1232,7 +1232,7 @@ } // 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 @@ /* 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 @@ /* 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();