OpenTTD Source 20260208-master-g43af8e94d0
tunnel_map.h File Reference

Map accessors for tunnels. More...

#include "rail_map.h"
#include "road_map.h"

Go to the source code of this file.

Functions

bool IsTunnel (Tile t)
 Is this a tunnel (entrance)?
bool IsTunnelTile (Tile t)
 Is this a tunnel (entrance)?
TileIndex GetOtherTunnelEnd (TileIndex)
 Gets the other end of the tunnel.
bool IsTunnelInWay (TileIndex, int z)
 Is there a tunnel in the way in any direction?
bool IsTunnelInWayDir (TileIndex tile, int z, DiagDirection dir)
 Is there a tunnel in the way in the given direction?
void MakeRoadTunnel (Tile t, Owner o, DiagDirection d, RoadType road_rt, RoadType tram_rt)
 Makes a road tunnel entrance.
void MakeRailTunnel (Tile 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

◆ GetOtherTunnelEnd()

TileIndex GetOtherTunnelEnd ( TileIndex tile)

Gets the other end of the tunnel.

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

Parameters
tilethe 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 DoClearTunnel(), CFollowTrackT< TRANSPORT_WATER, Ship, true >::FollowTileExit(), and GetOtherTunnelBridgeEnd().

◆ IsTunnel()

bool IsTunnel ( Tile t)
inline

Is this a tunnel (entrance)?

Parameters
tthe tile that might be a tunnel
Precondition
IsTileType(t, TileType::TunnelBridge)
Returns
true if and only if this tile is a tunnel (entrance)

Definition at line 23 of file tunnel_map.h.

References HasBit(), IsTileType(), Tile::m5(), and TunnelBridge.

Referenced by AdjustTileh(), CFollowTrackT< TRANSPORT_WATER, Ship, true >::CanEnterNewTile(), ClearTile_TunnelBridge(), DrawTile_TunnelBridge(), CFollowTrackT< TRANSPORT_WATER, Ship, true >::FollowTileExit(), GetOtherTunnelBridgeEnd(), GetRailTrackBitsUniversal(), IsTunnelTile(), and TrainController().

◆ IsTunnelInWay()

bool IsTunnelInWay ( TileIndex tile,
int z )

Is there a tunnel in the way in any direction?

Parameters
tilethe tile to search from.
zthe 'z' to search on.
Returns
true if and only if there is a tunnel.

Definition at line 68 of file tunnel_map.cpp.

References DIAGDIR_NE, DIAGDIR_NW, DIAGDIR_SE, DIAGDIR_SW, IsTunnelInWayDir(), Map::MaxX(), Map::MaxY(), TileX(), and TileY().

Referenced by CmdTerraformLand().

◆ IsTunnelInWayDir()

bool IsTunnelInWayDir ( TileIndex tile,
int z,
DiagDirection dir )

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

Parameters
tilethe tile to search from.
zthe 'z' to search on.
dirthe 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().

◆ IsTunnelTile()

bool IsTunnelTile ( Tile t)
inline

Is this a tunnel (entrance)?

Parameters
tthe tile that might be a tunnel
Returns
true if and only if this tile is a tunnel (entrance)

Definition at line 34 of file tunnel_map.h.

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

Referenced by AfterLoadGame(), DrawRailCatenaryRailway(), GetOtherTunnelEnd(), IsTunnelInWayDir(), Vehicle::ShowVisualEffect(), and CYapfCostBase::stSlopeCost().

◆ MakeRailTunnel()

void MakeRailTunnel ( Tile t,
Owner o,
DiagDirection d,
RailType r )
inline

Makes a rail tunnel entrance.

Parameters
tthe entrance of the tunnel
othe owner of the entrance
dthe direction facing out of the tunnel
rthe rail type used in the tunnel

Definition at line 74 of file tunnel_map.h.

References Tile::m2(), Tile::m3(), Tile::m4(), Tile::m5(), Tile::m6(), Tile::m7(), Tile::m8(), SB(), SetRailType(), SetTileOwner(), SetTileType(), TRANSPORT_RAIL, and TunnelBridge.

Referenced by CmdBuildTunnel().

◆ MakeRoadTunnel()

void MakeRoadTunnel ( Tile t,
Owner o,
DiagDirection d,
RoadType road_rt,
RoadType tram_rt )
inline

Makes a road tunnel entrance.

Parameters
tthe entrance of the tunnel
othe owner of the entrance
dthe direction facing out of the tunnel
road_rtThe road type used in the tunnel.
tram_rtThe tram type used in the tunnel.

Definition at line 51 of file tunnel_map.h.

References Tile::m2(), Tile::m3(), Tile::m4(), Tile::m5(), Tile::m6(), Tile::m7(), Tile::m8(), OWNER_TOWN, RTT_ROAD, RTT_TRAM, SB(), SetRoadOwner(), SetRoadTypes(), SetTileOwner(), SetTileType(), TRANSPORT_ROAD, and TunnelBridge.

Referenced by CmdBuildTunnel().