(svn r11194) -Fix: industries with not all tiles custom slope checked (but at least one) would be build on wrongly sloped tiles.
authorrubidium
Tue, 02 Oct 2007 17:48:17 +0000
changeset 7663 798fd9251f8e
parent 7662 b9da9d79a9a9
child 7664 7cf2085c7392
(svn r11194) -Fix: industries with not all tiles custom slope checked (but at least one) would be build on wrongly sloped tiles.
src/industry_cmd.cpp
--- a/src/industry_cmd.cpp	Tue Oct 02 16:56:45 2007 +0000
+++ b/src/industry_cmd.cpp	Tue Oct 02 17:48:17 2007 +0000
@@ -1198,6 +1198,8 @@
 static bool CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTileTable *it, uint itspec_index, int type, bool *custom_shape_check = NULL)
 {
 	_error_message = STR_0239_SITE_UNSUITABLE;
+	bool refused_slope = false;
+	bool custom_shape = false;
 
 	do {
 		IndustryGfx gfx = GetTranslatedIndustryTileID(it->gfx);
@@ -1222,7 +1224,7 @@
 			IndustyBehaviour ind_behav = GetIndustrySpec(type)->behaviour;
 
 			if (HASBIT(its->callback_flags, CBM_INDT_SHAPE_CHECK)) {
-				if (custom_shape_check != NULL) *custom_shape_check = true;
+				custom_shape = true;
 				if (!PerformIndustryTileSlopeCheck(tile, cur_tile, its, type, gfx, itspec_index)) return false;
 			} else {
 				if (ind_behav & INDUSTRYBEH_BUILT_ONWATER) {
@@ -1238,12 +1240,7 @@
 					tileh = GetTileSlope(cur_tile, NULL);
 					if (IsSteepSlope(tileh)) return false;
 
-					if (_patches.land_generator != LG_TERRAGENESIS || !_generating_world) {
-						/* It is almost impossible to have a fully flat land in TG, so what we
-						*  do is that we check if we can make the land flat later on. See
-						*  CheckIfCanLevelIndustryPlatform(). */
-						if (IsSlopeRefused(tileh, its->slopes_refused)) return false;
-					}
+					refused_slope |= IsSlopeRefused(tileh, its->slopes_refused);
 				}
 			}
 
@@ -1259,7 +1256,12 @@
 		}
 	} while ((++it)->ti.x != -0x80);
 
-	return true;
+	if (custom_shape_check != NULL) *custom_shape_check = custom_shape;
+
+	/* It is almost impossible to have a fully flat land in TG, so what we
+	 *  do is that we check if we can make the land flat later on. See
+	 *  CheckIfCanLevelIndustryPlatform(). */
+	return !refused_slope || (_patches.land_generator == LG_TERRAGENESIS && _generating_world && !custom_shape);
 }
 
 static bool CheckIfIndustryIsAllowed(TileIndex tile, int type, const Town *t)