OpenTTD Source  20240917-master-g9ab0a47812
tunnel_map.cpp File Reference
#include "stdafx.h"
#include "tunnelbridge_map.h"
#include "safeguards.h"

Go to the source code of this file.

Functions

TileIndex GetOtherTunnelEnd (TileIndex tile)
 Gets the other end of the tunnel. More...
 
bool IsTunnelInWayDir (TileIndex tile, int z, DiagDirection dir)
 Is there a tunnel in the way in the given direction? More...
 
bool IsTunnelInWay (TileIndex tile, int z)
 Is there a tunnel in the way in any direction? More...
 

Detailed Description

Map accessors for tunnels.

Definition in file tunnel_map.cpp.

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< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::FollowTileExit(), and GetOtherTunnelBridgeEnd().

◆ 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 IsTunnelInWay().