(svn r3779) Move CheckTunnelInWay() to a more appropriate place, invert its result and give it a less ambiguous name (IsTunnelInWay)

This commit is contained in:
tron
2006-03-07 07:51:05 +00:00
parent a172b194c2
commit 313754011d
5 changed files with 32 additions and 34 deletions

View File

@@ -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);
}