changeset 16051:fa9a88329064 draft

(svn r20744) -Fix: overbuilding an object with water under it failed
author yexo <yexo@openttd.org>
date Sun, 05 Sep 2010 14:53:20 +0000
parents 2f4db320e4bf
children 31ffe6e4f1e5
files src/object_cmd.cpp
diffstat 1 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/object_cmd.cpp
+++ b/src/object_cmd.cpp
@@ -166,12 +166,13 @@
 		bool allow_water = (spec->flags & (OBJECT_FLAG_BUILT_ON_WATER | OBJECT_FLAG_NOT_ON_LAND)) != 0;
 		bool allow_ground = (spec->flags & OBJECT_FLAG_NOT_ON_LAND) == 0;
 		TILE_AREA_LOOP(t, ta) {
-			if (IsWaterTile(t)) {
+			if (HasTileWaterClass(t) && IsTileOnWater(t)) {
 				if (!allow_water) return_cmd_error(STR_ERROR_CAN_T_BUILD_ON_WATER);
-				/* For water tiles we want to "just" check whether the tile is water and
-				 * can be cleared, i.e. it's not filled. We won't be paying though. */
-				CommandCost ret = DoCommand(t, 0, 0, flags & ~(DC_EXEC | DC_NO_WATER), CMD_LANDSCAPE_CLEAR);
-				if (ret.Failed()) return ret;
+				if (!IsWaterTile(t)) {
+					/* Normal water tiles don't have to be cleared. For all other tile types clear
+					 * the tile but leave the water. */
+					cost.AddCost(DoCommand(t, 0, 0, flags & ~DC_NO_WATER, CMD_LANDSCAPE_CLEAR));
+				}
 			} else {
 				if (!allow_ground) return_cmd_error(STR_ERROR_MUST_BE_BUILT_ON_WATER);
 				/* For non-water tiles, we'll have to clear it before building. */