diff options
author | rubidium <rubidium@openttd.org> | 2011-07-30 13:55:44 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2011-07-30 13:55:44 +0000 |
commit | cfc2c5db42c988875ec169157bf977c934034196 (patch) | |
tree | ff0184592658ae3efff338c6533f9a6cbe6d5b68 /src | |
parent | 9c239bb988199aba0380aafbb23a89b27626ab48 (diff) | |
download | openttd-cfc2c5db42c988875ec169157bf977c934034196.tar.xz |
(svn r22699) -Fix [FS#4681]: Cost of adding an extra road type to a bridge or tunnel was undercalculated (adf88)
Diffstat (limited to 'src')
-rw-r--r-- | src/road_cmd.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index 79f830fd1..75df89882 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -662,12 +662,14 @@ do_clear:; if (ret.Failed()) return ret; } - cost.AddCost(CountBits(pieces) * _price[PR_BUILD_ROAD]); - if (!need_to_clear && IsTileType(tile, MP_TUNNELBRIDGE)) { - /* Pay for *every* tile of the bridge or tunnel */ - cost.MultiplyCost(GetTunnelBridgeLength(GetOtherTunnelBridgeEnd(tile), tile) + 2); - } + uint num_pieces = (!need_to_clear && IsTileType(tile, MP_TUNNELBRIDGE)) ? + /* There are 2 pieces on *every* tile of the bridge or tunnel */ + 2 * (GetTunnelBridgeLength(GetOtherTunnelBridgeEnd(tile), tile) + 2) : + /* Count pieces */ + CountBits(pieces); + + cost.AddCost(num_pieces * _price[PR_BUILD_ROAD]); if (flags & DC_EXEC) { switch (GetTileType(tile)) { |