# tunnel_map.h File Reference

Map accessors for tunnels. More...

`#include "direction_func.h"`
`#include "rail_type.h"`
`#include "road_type.h"`
`#include "transport_type.h"`
`#include "road_map.h"`

Go to the source code of this file.

## Functions
static bool | IsTunnel (TileIndex t)
| Is this a tunnel (entrance)?
static bool | IsTunnelTile (TileIndex t)
| Is this a tunnel (entrance)?
TileIndex | GetOtherTunnelEnd (TileIndex)
| Gets the other end of the tunnel.
bool | IsTunnelInWay (TileIndex, uint z)
| Is there a tunnel in the way in any direction?
bool | IsTunnelInWayDir (TileIndex tile, uint z, DiagDirection dir)
| Is there a tunnel in the way in the given direction?
static void | MakeRoadTunnel (TileIndex t, Owner o, DiagDirection d, RoadTypes r)
| Makes a road tunnel entrance.
static void | MakeRailTunnel (TileIndex t, Owner o, DiagDirection d, RailType r)
| Makes a rail tunnel entrance.

## Detailed Description

Map accessors for tunnels.

Definition in file tunnel_map.h.

## Function Documentation

TileIndex GetOtherTunnelEnd | ( | TileIndex | tile | ) |

Gets the other end of the tunnel.

Where a vehicle would reappear when it enters at the given tile.

Parameters:

  | tile | the tile to search from.

Returns:
  the tile of the other end of the tunnel.

Definition at line 22 of file tunnel_map.cpp.

References GetTileZ(), GetTunnelBridgeDirection(), IsTunnelTile(), ReverseDiagDir(), and TileOffsByDiagDir().

Referenced by CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::FollowTileExit(), GetOtherTunnelBridgeEnd(), and AITunnel::GetOtherTunnelEnd().

static bool IsTunnel | ( | TileIndex | t | ) | `[inline, static]`

Is this a tunnel (entrance)?

Parameters:

  | t | the tile that might be a tunnel

Precondition:
  IsTileType(t, MP_TUNNELBRIDGE)

Returns:
  true if and only if this tile is a tunnel (entrance)

Definition at line 28 of file tunnel_map.h.

References _m, HasBit(), IsTileType(), and MP_TUNNELBRIDGE.

Referenced by AdjustTileh(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::CanEnterNewTile(), CmdBuildBridge(), DrawTile_TunnelBridge(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::FollowTileExit(), GetOtherTunnelBridgeEnd(), GetRailTrackBitsUniversal(), and IsTunnelTile().

bool IsTunnelInWay | ( | TileIndex | tile,
|  | uint | z |
| ) |  |  |

Is there a tunnel in the way in any direction?

Parameters:

  | tile | the tile to search from.
  | z | the 'z' to search on.

Returns:
  true if and only if there is a tunnel.

Definition at line 71 of file tunnel_map.cpp.

References DIAGDIR_NE, DIAGDIR_NW, DIAGDIR_SE, DIAGDIR_SW, IsTunnelInWayDir(), MapMaxX(), MapMaxY(), TileX(), and TileY().

Referenced by CmdTerraformLand().

bool IsTunnelInWayDir | ( | TileIndex | tile,
|  | uint | z,
|  | DiagDirection | dir |
| ) |  |  |

Is there a tunnel in the way in the given direction?

Parameters:

  | tile | the tile to search from.
  | z | the 'z' to search on.
  | dir | the direction to start searching to.

Returns:
  true if and only if there is a tunnel.

Definition at line 48 of file tunnel_map.cpp.

References GetTileZ(), GetTunnelBridgeDirection(), IsTunnelTile(), IsValidTile(), and TileOffsByDiagDir().

Referenced by CmdBuildTunnel(), and IsTunnelInWay().

static bool IsTunnelTile | ( | TileIndex | t | ) | `[inline, static]`

Is this a tunnel (entrance)?

Parameters:

  | t | the tile that might be a tunnel

Returns:
  true if and only if this tile is a tunnel (entrance)

Definition at line 39 of file tunnel_map.h.

References IsTileType(), IsTunnel(), and MP_TUNNELBRIDGE.

Referenced by DrawCatenaryRailway(), GetOtherTunnelEnd(), IsTunnelInWayDir(), and AITunnel::IsTunnelTile().

static void MakeRailTunnel | ( | TileIndex | t,
|  | Owner | o,
|  | DiagDirection | d,
|  | RailType | r |
| ) |  |  | `[inline, static]`

Makes a rail tunnel entrance.

Parameters:

  | t | the entrance of the tunnel
  | o | the owner of the entrance
  | d | the direction facing out of the tunnel
  | r | the rail type used in the tunnel

Definition at line 77 of file tunnel_map.h.

References _m, _me, Tile::m2, Tile::m3, Tile::m4, Tile::m5, TileExtended::m7, MP_TUNNELBRIDGE, SB(), SetTileOwner(), SetTileType(), and TRANSPORT_RAIL.

Referenced by CmdBuildTunnel().

static void MakeRoadTunnel | ( | TileIndex | t,
|  | Owner | o,
|  | DiagDirection | d,
|  | RoadTypes | r |
| ) |  |  | `[inline, static]`

Makes a road tunnel entrance.

Parameters:

  | t | the entrance of the tunnel
  | o | the owner of the entrance
  | d | the direction facing out of the tunnel
  | r | the road type used in the tunnel

Definition at line 55 of file tunnel_map.h.

References _m, _me, Tile::m2, Tile::m3, Tile::m4, Tile::m5, TileExtended::m7, MP_TUNNELBRIDGE, OWNER_TOWN, ROADTYPE_ROAD, ROADTYPE_TRAM, SB(), SetTileOwner(), SetTileType(), and TRANSPORT_ROAD.

Referenced by CmdBuildTunnel().