diff options
Diffstat (limited to 'src/water_cmd.cpp')
-rw-r--r-- | src/water_cmd.cpp | 20 |
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. |