summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2006-08-15 00:14:57 +0000
committerDarkvater <darkvater@openttd.org>2006-08-15 00:14:57 +0000
commit3801e890c0a8e41cfa8d703d56bf35705cc3ade2 (patch)
tree37c58022ffdb0257affcb0c3e1b9a1b1b01e388e
parent939e334ce29e74b47639db32667e1dcb7400310e (diff)
downloadopenttd-3801e890c0a8e41cfa8d703d56bf35705cc3ade2.tar.xz
(svn r5901) -Fix [FS#253]: Differing price calculation for tunnels depending on starting point
-rw-r--r--tunnelbridge_cmd.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/tunnelbridge_cmd.c b/tunnelbridge_cmd.c
index 00c8f33a1..9d95de830 100644
--- a/tunnelbridge_cmd.c
+++ b/tunnelbridge_cmd.c
@@ -465,8 +465,12 @@ int32 CmdBuildTunnel(TileIndex start_tile, uint32 flags, uint32 p1, uint32 p2)
ret = DoCommand(start_tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(ret)) return ret;
- cost = _price.build_tunnel + ret;
+ /* XXX - do NOT change 'ret' in the loop, as it is used as the price
+ * for the clearing of the entrance of the tunnel. Assigning it to
+ * cost before the loop will yield different costs depending on start-
+ * position, because of increased-cost-by-length: 'cost += cost >> 3' */
+ cost = 0;
delta = TileOffsByDir(direction);
end_tile = start_tile;
for (;;) {
@@ -480,10 +484,13 @@ int32 CmdBuildTunnel(TileIndex start_tile, uint32 flags, uint32 p1, uint32 p2)
}
cost += _price.build_tunnel;
- cost += cost >> 3;
+ cost += cost >> 3; // add a multiplier for longer tunnels
if (cost >= 400000000) cost = 400000000;
}
+ /* Add the cost of the entrance */
+ cost += _price.build_tunnel + ret;
+
// if the command fails from here on we want the end tile to be highlighted
_build_tunnel_endtile = end_tile;