MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / IsTunnelInWayDir

Function IsTunnelInWayDir

src/tunnel_map.cpp:48–60  ·  view source on GitHub ↗

* Is there a tunnel in the way in the given direction? * @param tile the tile to search from. * @param z the 'z' to search on. * @param dir the direction to start searching to. * @return true if and only if there is a tunnel. */

Source from the content-addressed store, hash-verified

46 * @return true if and only if there is a tunnel.
47 */
48bool IsTunnelInWayDir(TileIndex tile, int z, DiagDirection dir)
49{
50 TileIndexDiff delta = TileOffsByDiagDir(dir);
51 int height;
52
53 do {
54 tile -= delta;
55 if (!IsValidTile(tile)) return false;
56 height = GetTileZ(tile);
57 } while (z < height);
58
59 return z == height && IsTunnelTile(tile) && GetTunnelBridgeDirection(tile) == dir;
60}
61
62/**
63 * Is there a tunnel in the way in any direction?

Callers 2

CmdBuildTunnelFunction · 0.85
IsTunnelInWayFunction · 0.85

Calls 5

TileOffsByDiagDirFunction · 0.85
IsValidTileFunction · 0.85
GetTileZFunction · 0.85
IsTunnelTileFunction · 0.85
GetTunnelBridgeDirectionFunction · 0.85

Tested by

no test coverage detected