summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-06-27 19:00:14 +0000
committerrubidium <rubidium@openttd.org>2007-06-27 19:00:14 +0000
commitb9db0b8cf1d3c2a108ac870ba3e05b6cea5249be (patch)
tree8b72a301cd9d7cfa12ae08c5973708cf30d73bb7 /src
parentc4596ada2dbb9f34cfd35d626ab4bb9500277fc3 (diff)
downloadopenttd-b9db0b8cf1d3c2a108ac870ba3e05b6cea5249be.tar.xz
(svn r10362) -Codechange: make tunnel costs less exponential for (very) long tunnels.
Diffstat (limited to 'src')
-rw-r--r--src/tunnelbridge_cmd.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
index e4ed8bf5f..82514656b 100644
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -499,6 +499,12 @@ CommandCost CmdBuildTunnel(TileIndex start_tile, uint32 flags, uint32 p1, uint32
}
end_tile = start_tile;
+
+ /** Tile shift coeficient. Will decrease for very long tunnels to avoid exponential growth of price*/
+ int tiles_coef = 3;
+ /** Number of tiles from start of tunnel */
+ int tiles = 0;
+
for (;;) {
end_tile += delta;
end_tileh = GetTileSlope(end_tile, &end_z);
@@ -509,8 +515,11 @@ CommandCost CmdBuildTunnel(TileIndex start_tile, uint32 flags, uint32 p1, uint32
return_cmd_error(STR_5003_ANOTHER_TUNNEL_IN_THE_WAY);
}
+ tiles++;
+ if (tiles == 25 || tiles == 50 || tiles == 100 || tiles == 200 || tiles == 400 || tiles == 800) tiles_coef++;
+
cost.AddCost(_price.build_tunnel);
- cost.AddCost(cost.GetCost() >> 3); // add a multiplier for longer tunnels
+ cost.AddCost(cost.GetCost() >> tiles_coef); // add a multiplier for longer tunnels
}
/* Add the cost of the entrance */