summaryrefslogtreecommitdiff
path: root/tunnelbridge_cmd.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-03-07 07:51:05 +0000
committertron <tron@openttd.org>2006-03-07 07:51:05 +0000
commit3027b8673e31b52f50201e9571612a946cb3aade (patch)
tree99b7d8d8952db8e2911e906960659f1307c048e5 /tunnelbridge_cmd.c
parent9c1856d8f17317950bad0dd57e2997f683e94824 (diff)
downloadopenttd-3027b8673e31b52f50201e9571612a946cb3aade.tar.xz
(svn r3779) Move CheckTunnelInWay() to a more appropriate place, invert its result and give it a less ambiguous name (IsTunnelInWay)
Diffstat (limited to 'tunnelbridge_cmd.c')
-rw-r--r--tunnelbridge_cmd.c34
1 files changed, 2 insertions, 32 deletions
diff --git a/tunnelbridge_cmd.c b/tunnelbridge_cmd.c
index 50f38f16e..42c54a621 100644
--- a/tunnelbridge_cmd.c
+++ b/tunnelbridge_cmd.c
@@ -428,36 +428,6 @@ not_valid_below:;
return cost;
}
-static bool DoCheckTunnelInWay(TileIndex tile, uint z, DiagDirection dir)
-{
- TileIndexDiff delta = TileOffsByDir(dir);
- uint height;
-
- do {
- tile -= delta;
- height = GetTileZ(tile);
- } while (z < height);
-
- if (z == height &&
- IsTileType(tile, MP_TUNNELBRIDGE) &&
- GB(_m[tile].m5, 4, 4) == 0 &&
- GetTunnelDirection(tile) == dir) {
- _error_message = STR_5003_ANOTHER_TUNNEL_IN_THE_WAY;
- return false;
- }
-
- return true;
-}
-
-bool CheckTunnelInWay(TileIndex tile, int z)
-{
- return
- DoCheckTunnelInWay(tile, z, DIAGDIR_NE) &&
- DoCheckTunnelInWay(tile, z, DIAGDIR_SE) &&
- DoCheckTunnelInWay(tile, z, DIAGDIR_SW) &&
- DoCheckTunnelInWay(tile, z, DIAGDIR_NW);
-}
-
/** Build Tunnel.
* @param x,y start tile coord of tunnel
@@ -504,8 +474,8 @@ int32 CmdBuildTunnel(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (start_z == end_z) break;
- if (!_cheats.crossing_tunnels.value && !CheckTunnelInWay(end_tile, start_z)) {
- return CMD_ERROR;
+ if (!_cheats.crossing_tunnels.value && IsTunnelInWay(end_tile, start_z)) {
+ return_cmd_error(STR_5003_ANOTHER_TUNNEL_IN_THE_WAY);
}
cost += _price.build_tunnel;