industries, unmoveables... everything but the landscape
authorterom@frrb.lan
Fri, 19 Dec 2008 01:38:09 +0200
changeset 10439 50f056aa3024
parent 10438 51bff16a04c9
child 10440 0a91ea45b0e8
industries, unmoveables... everything but the landscape
src/clear_cmd.cpp
src/genworld.cpp
src/industry_cmd.cpp
--- a/src/clear_cmd.cpp	Fri Dec 19 01:32:07 2008 +0200
+++ b/src/clear_cmd.cpp	Fri Dec 19 01:38:09 2008 +0200
@@ -299,10 +299,17 @@
 				TileIndex tile_new;
 
 				SetClearGroundDensity(tile, CLEAR_ROCKS, 3);
+
 				do {
 					if (--j == 0) goto get_out;
-					tile_new = tile + TileOffsByDiagDir((DiagDirection)GB(Random(), 0, 2));
+                    
+                    TileIndexDiff dt = TileOffsByDiagDir((DiagDirection)GB(Random(), 0, 2));
+
+                    if (!IsValidTile(tile + dt)) continue;
+
+					tile_new = tile + dt;
 				} while (!IsTileType(tile_new, MP_CLEAR) || IsClearGround(tile_new, CLEAR_DESERT));
+
 				tile = tile_new;
 			}
 get_out:;
--- a/src/genworld.cpp	Fri Dec 19 01:32:07 2008 +0200
+++ b/src/genworld.cpp	Fri Dec 19 01:38:09 2008 +0200
@@ -111,13 +111,13 @@
 			IncreaseGeneratingWorldProgress(GWP_UNMOVABLE);
 		} else {
 			//GenerateLandscape(_gw.mode);
-			//GenerateClearTile();
+			GenerateClearTile();
 
 			/* only generate towns, tree and industries in newgame mode. */
 			if (_game_mode != GM_EDITOR) {
 				GenerateTowns();
-				//GenerateIndustries();
-				//GenerateUnmovables();
+				GenerateIndustries();
+				GenerateUnmovables();
 				GenerateTrees();
 			}
 		}
--- a/src/industry_cmd.cpp	Fri Dec 19 01:32:07 2008 +0200
+++ b/src/industry_cmd.cpp	Fri Dec 19 01:38:09 2008 +0200
@@ -1753,7 +1753,7 @@
 	if (_settings_game.difficulty.number_industries != 0) {
 		CompanyID old_company = _current_company;
 		_current_company = OWNER_NONE;
-		assert(num > 0);
+		assert(num >= 0);
 
 		do {
 			uint i;
@@ -1763,7 +1763,7 @@
 			for (i = 0; i < 2000; i++) {
 				if (CreateNewIndustry(RandomTile(), type) != NULL) break;
 			}
-		} while (--num);
+		} while (num && --num);
 
 		_current_company = old_company;
 	}