summaryrefslogtreecommitdiff
path: root/tunnel_map.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 /tunnel_map.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 'tunnel_map.c')
-rw-r--r--tunnel_map.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/tunnel_map.c b/tunnel_map.c
index d39c7ef04..8752d8107 100644
--- a/tunnel_map.c
+++ b/tunnel_map.c
@@ -23,3 +23,30 @@ TileIndex GetOtherTunnelEnd(TileIndex tile)
return tile;
}
+
+
+static bool IsTunnelInWayDir(TileIndex tile, uint z, DiagDirection dir)
+{
+ TileIndexDiff delta = TileOffsByDir(dir);
+ uint height;
+
+ do {
+ tile -= delta;
+ height = GetTileZ(tile);
+ } while (z < height);
+
+ return
+ z == height &&
+ IsTileType(tile, MP_TUNNELBRIDGE) &&
+ GB(_m[tile].m5, 4, 4) == 0 &&
+ GetTunnelDirection(tile) == dir;
+}
+
+bool IsTunnelInWay(TileIndex tile, uint z)
+{
+ return
+ IsTunnelInWayDir(tile, z, DIAGDIR_NE) ||
+ IsTunnelInWayDir(tile, z, DIAGDIR_SE) ||
+ IsTunnelInWayDir(tile, z, DIAGDIR_SW) ||
+ IsTunnelInWayDir(tile, z, DIAGDIR_NW);
+}