summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2006-01-06 21:57:37 +0000
committertruelight <truelight@openttd.org>2006-01-06 21:57:37 +0000
commit45a0cc607c355ea699f9013a39b23be6a12badb0 (patch)
treefd96410bf56810a2dd8d3cc1147612e1fee71db2
parenta1f83094538f72dd7c8a9eb9bc3b62e8cfa8402a (diff)
downloadopenttd-45a0cc607c355ea699f9013a39b23be6a12badb0.tar.xz
(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)
-rw-r--r--main_gui.c2
-rw-r--r--misc.c12
-rw-r--r--openttd.c10
-rw-r--r--openttd.h15
-rw-r--r--saveload.c6
5 files changed, 30 insertions, 15 deletions
diff --git a/main_gui.c b/main_gui.c
index 89f2611bf..2c8c1a2ae 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 1e2993a21..8abbc5bf8 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 b18850069..f6daae393 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 81ed0b908..f2ae7684e 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 339746342..827abe697 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();