changeset 14299:20dba7df2223 draft

(svn r18851) -Codechange: enumify number of steps needed to generate landscape
author smatz <smatz@openttd.org>
date Sun, 17 Jan 2010 21:40:35 +0000
parents 35244bbcc585
children a63d087cc4ad
files src/landscape.cpp
diffstat 1 files changed, 12 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/landscape.cpp
+++ b/src/landscape.cpp
@@ -857,23 +857,31 @@
 
 void GenerateLandscape(byte mode)
 {
-	static const int gwp_desert_amount = 4 + 8;
+	/** Number of steps of landscape generation */
+	enum GenLandscapeSteps {
+		GLS_HEIGHTMAP    =  3, ///< Loading a heightmap
+		GLS_TERRAGENESIS =  5, ///< Terragenesis generator
+		GLS_ORIGINAL     =  2, ///< Original generator
+		GLS_TROPIC       = 12, ///< Extra steps needed for tropic landscape
+		GLS_OTHER        =  0, ///< Extra steps for other landscapes
+	};
+	uint steps = (_settings_game.game_creation.landscape == LT_TROPIC) ? GLS_TROPIC : GLS_OTHER;
 
 	if (mode == GW_HEIGHTMAP) {
-		SetGeneratingWorldProgress(GWP_LANDSCAPE, (_settings_game.game_creation.landscape == LT_TROPIC) ? 3 + gwp_desert_amount : 3);
+		SetGeneratingWorldProgress(GWP_LANDSCAPE, steps + GLS_HEIGHTMAP);
 		LoadHeightmap(_file_to_saveload.name);
 		IncreaseGeneratingWorldProgress(GWP_LANDSCAPE);
 	} else if (_settings_game.game_creation.land_generator == LG_TERRAGENESIS) {
-		SetGeneratingWorldProgress(GWP_LANDSCAPE, (_settings_game.game_creation.landscape == LT_TROPIC) ? 5 + gwp_desert_amount : 5);
+		SetGeneratingWorldProgress(GWP_LANDSCAPE, steps + GLS_TERRAGENESIS);
 		GenerateTerrainPerlin();
 	} else {
+		SetGeneratingWorldProgress(GWP_LANDSCAPE, steps + GLS_ORIGINAL);
 		if (_settings_game.construction.freeform_edges) {
 			for (uint x = 0; x < MapSizeX(); x++) MakeVoid(TileXY(x, 0));
 			for (uint y = 0; y < MapSizeY(); y++) MakeVoid(TileXY(0, y));
 		}
 		switch (_settings_game.game_creation.landscape) {
 			case LT_ARCTIC: {
-				SetGeneratingWorldProgress(GWP_LANDSCAPE, 2);
 				uint32 r = Random();
 
 				for (uint i = ScaleByMapSize(GB(r, 0, 7) + 950); i != 0; --i) {
@@ -887,8 +895,6 @@
 			} break;
 
 			case LT_TROPIC: {
-				SetGeneratingWorldProgress(GWP_LANDSCAPE, 2 + gwp_desert_amount);
-
 				uint32 r = Random();
 
 				for (uint i = ScaleByMapSize(GB(r, 0, 7) + 170); i != 0; --i) {
@@ -908,8 +914,6 @@
 			} break;
 
 			default: {
-				SetGeneratingWorldProgress(GWP_LANDSCAPE, 2);
-
 				uint32 r = Random();
 
 				uint i = ScaleByMapSize(GB(r, 0, 7) + (3 - _settings_game.difficulty.quantity_sea_lakes) * 256 + 100);