From 313754011d04ad4913bf4028b78d75ceb359e9b3 Mon Sep 17 00:00:00 2001 From: tron Date: Tue, 7 Mar 2006 07:51:05 +0000 Subject: (svn r3779) Move CheckTunnelInWay() to a more appropriate place, invert its result and give it a less ambiguous name (IsTunnelInWay) --- tunnel_map.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'tunnel_map.c') 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); +} -- cgit v1.2.3-54-g00ecf