summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorterkhen <terkhen@openttd.org>2010-04-25 13:50:15 +0000
committerterkhen <terkhen@openttd.org>2010-04-25 13:50:15 +0000
commite83797d2e076c42d086b577dc7c95c96e3c17019 (patch)
treed1299118002170d12beb53b127c9b6c5bcb38591 /src
parent3be66a5e79e4046ea318c2a40a29c1eb308fae5a (diff)
downloadopenttd-e83797d2e076c42d086b577dc7c95c96e3c17019.tar.xz
(svn r19718) -Fix: The cost of clearing tiles was not taken into account when building locks.
Diffstat (limited to 'src')
-rw-r--r--src/water_cmd.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp
index d6ce6c482..e877618eb 100644
--- a/src/water_cmd.cpp
+++ b/src/water_cmd.cpp
@@ -198,16 +198,22 @@ static CommandCost RemoveShipDepot(TileIndex tile, DoCommandFlag flags)
*/
static CommandCost DoBuildLock(TileIndex tile, DiagDirection dir, DoCommandFlag flags)
{
+ CommandCost cost(EXPENSES_CONSTRUCTION);
+
/* middle tile */
CommandCost ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (ret.Failed()) return ret;
+ cost.AddCost(ret);
int delta = TileOffsByDiagDir(dir);
/* lower tile */
WaterClass wc_lower = IsWaterTile(tile - delta) ? GetWaterClass(tile - delta) : WATER_CLASS_CANAL;
- ret = DoCommand(tile - delta, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
- if (ret.Failed()) return ret;
+ if (!IsWaterTile(tile - delta)) {
+ ret = DoCommand(tile - delta, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
+ if (ret.Failed()) return ret;
+ cost.AddCost(ret);
+ }
if (GetTileSlope(tile - delta, NULL) != SLOPE_FLAT) {
return_cmd_error(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
}
@@ -215,8 +221,11 @@ static CommandCost DoBuildLock(TileIndex tile, DiagDirection dir, DoCommandFlag
/* upper tile */
WaterClass wc_upper = IsWaterTile(tile + delta) ? GetWaterClass(tile + delta) : WATER_CLASS_CANAL;
- ret = DoCommand(tile + delta, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
- if (ret.Failed()) return ret;
+ if (!IsWaterTile(tile + delta)) {
+ ret = DoCommand(tile + delta, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
+ if (ret.Failed()) return ret;
+ cost.AddCost(ret);
+ }
if (GetTileSlope(tile + delta, NULL) != SLOPE_FLAT) {
return_cmd_error(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
}
@@ -235,8 +244,9 @@ static CommandCost DoBuildLock(TileIndex tile, DiagDirection dir, DoCommandFlag
MarkCanalsAndRiversAroundDirty(tile - delta);
MarkCanalsAndRiversAroundDirty(tile + delta);
}
+ cost.AddCost(_price[PR_CLEAR_WATER] * 22 >> 3);
- return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_WATER] * 22 >> 3);
+ return cost;
}
/** Remove a lock.