Mercurial > hg > openttd
changeset 15092:43aa8105fc82 draft
(svn r19718) -Fix: The cost of clearing tiles was not taken into account when building locks.
author | terkhen <terkhen@openttd.org> |
---|---|
date | Sun, 25 Apr 2010 13:50:15 +0000 |
parents | 7ae492c43c9a |
children | e5e511b46e2b |
files | src/water_cmd.cpp |
diffstat | 1 files changed, 15 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -198,16 +198,22 @@ */ 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 @@ /* 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 @@ 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.