# bridge_map.h File Reference

Map accessor functions for bridges. More...

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

Go to the source code of this file.

## Functions
static bool | IsBridge (TileIndex t)
| Checks if this is a bridge, instead of a tunnel.
static bool | IsBridgeTile (TileIndex t)
| checks if there is a bridge on this tile
static bool | MayHaveBridgeAbove (TileIndex t)
| checks for the possibility that a bridge may be on this tile These are in fact all the tile types on which a bridge can be found
static bool | IsBridgeAbove (TileIndex t)
| checks if a bridge is set above the ground of this tile
static BridgeType | GetBridgeType (TileIndex t)
| Determines the type of bridge on a tile.
static Axis | GetBridgeAxis (TileIndex t)
| Get the axis of the bridge that goes over the tile.
TileIndex | GetBridgeEnd (TileIndex t, DiagDirection d)
| Finds the end of a bridge in the specified direction starting at a middle tile.
TileIndex | GetNorthernBridgeEnd (TileIndex t)
| Finds the northern end of a bridge starting at a middle tile.
TileIndex | GetSouthernBridgeEnd (TileIndex t)
| Finds the southern end of a bridge starting at a middle tile.
TileIndex | GetOtherBridgeEnd (TileIndex t)
| Starting at one bridge end finds the other bridge end.
uint | GetBridgeHeight (TileIndex tile)
| Get the height ('z') of a bridge in pixels.
static void | ClearSingleBridgeMiddle (TileIndex t, Axis a)
| Remove the bridge over the given axis.
static void | ClearBridgeMiddle (TileIndex t)
| Removes bridges from the given, that is bridges along the X and Y axis.
static void | SetBridgeMiddle (TileIndex t, Axis a)
| Set that there is a bridge over the given axis.
static void | MakeBridgeRamp (TileIndex t, Owner o, BridgeType bridgetype, DiagDirection d, TransportType tt, uint rt)
| Generic part to make a bridge ramp for both roads and rails.
static void | MakeRoadBridgeRamp (TileIndex t, Owner o, BridgeType bridgetype, DiagDirection d, RoadTypes r)
| Make a bridge ramp for roads.
static void | MakeRailBridgeRamp (TileIndex t, Owner o, BridgeType bridgetype, DiagDirection d, RailType r)
| Make a bridge ramp for rails.
static void | MakeAqueductBridgeRamp (TileIndex t, Owner o, DiagDirection d)
| Make a bridge ramp for aqueducts.

## Detailed Description

Map accessor functions for bridges.

Definition in file bridge_map.h.

## Function Documentation

static void ClearBridgeMiddle | ( | TileIndex | t | ) | `[inline, static]`

Removes bridges from the given, that is bridges along the X and Y axis.

Parameters:

  | t | the tile to remove the bridge from

Precondition:
  MayHaveBridgeAbove(t)

Definition at line 139 of file bridge_map.h.

References AXIS_X, AXIS_Y, and ClearSingleBridgeMiddle().

static void ClearSingleBridgeMiddle | ( | TileIndex | t,
|  | Axis | a |
| ) |  |  | `[inline, static]`

Remove the bridge over the given axis.

Parameters:

  | t | the tile to remove the bridge from
  | a | the axis of the bridge to remove

Precondition:
  MayHaveBridgeAbove(t)

Definition at line 128 of file bridge_map.h.

References _m, ClrBit(), and MayHaveBridgeAbove().

Referenced by ClearBridgeMiddle().

static Axis GetBridgeAxis | ( | TileIndex | t | ) | `[inline, static]`

Get the axis of the bridge that goes over the tile.

Not the axis or the ramp.

Parameters:

  | t | The tile to analyze

Precondition:
  IsBridgeAbove(t)

Returns:
  the above mentioned axis

Definition at line 83 of file bridge_map.h.

References _m, GB(), and IsBridgeAbove().

Referenced by CmdBuildBridge(), DrawCatenaryRailway(), GetNorthernBridgeEnd(), and GetSouthernBridgeEnd().

TileIndex GetBridgeEnd | ( | TileIndex | t,
|  | DiagDirection | d |
| ) |  |  |

Finds the end of a bridge in the specified direction starting at a middle tile.

Parameters:

  | t | the bridge tile to find the bridge ramp for
  | d | the direction to search in

Definition at line 11 of file bridge_map.cpp.

References GetTunnelBridgeDirection(), IsBridgeTile(), ReverseDiagDir(), and TileOffsByDiagDir().

Referenced by GetNorthernBridgeEnd(), GetOtherBridgeEnd(), and GetSouthernBridgeEnd().

uint GetBridgeHeight | ( | TileIndex | tile | ) |

Get the height ('z') of a bridge in pixels.

Parameters:

  | tile | the bridge ramp tile to get the bridge height from

Returns:
  the height of the bridge in pixels

Definition at line 42 of file bridge_map.cpp.

References ApplyFoundationToSlope(), DiagDirToAxis(), GetTileSlope(), GetTunnelBridgeDirection(), and TILE_HEIGHT.

Referenced by CmdBuildBridge(), CmdTerraformLand(), DrawCatenaryRailway(), DrawRoadBits(), DrawTramCatenary(), and FloodVehicles().

static BridgeType GetBridgeType | ( | TileIndex | t | ) | `[inline, static]`

Determines the type of bridge on a tile.

Parameters:

  | t | The tile to analyze

Precondition:
  IsBridgeTile(t)

Returns:
  The bridge type

Definition at line 71 of file bridge_map.h.

References _m, GB(), and IsBridgeTile().

Referenced by CmdBuildBridge(), DrawTile_TunnelBridge(), and CFollowTrackT< Ttr_type_, T90deg_turns_allowed_, Tmask_reserved_tracks >::GetSpeedLimit().

TileIndex GetNorthernBridgeEnd | ( | TileIndex | t | ) |

Finds the northern end of a bridge starting at a middle tile.

Parameters:

  | t | the bridge tile to find the bridge ramp for

Definition at line 24 of file bridge_map.cpp.

References AxisToDiagDir(), GetBridgeAxis(), GetBridgeEnd(), and ReverseDiagDir().

Referenced by CmdBuildBridge(), DrawCatenaryRailway(), DrawRoadBits(), and DrawTramCatenary().

TileIndex GetOtherBridgeEnd | ( | TileIndex | t | ) |

Starting at one bridge end finds the other bridge end.

Parameters:

  | t | the bridge ramp tile to find the other bridge ramp for

Definition at line 36 of file bridge_map.cpp.

References GetBridgeEnd(), GetTunnelBridgeDirection(), and IsBridgeTile().

Referenced by CmdBuildBridge(), FloodVehicles(), CFollowTrackT< Ttr_type_, T90deg_turns_allowed_, Tmask_reserved_tracks >::FollowTileExit(), AIBridge::GetOtherBridgeEnd(), GetOtherTunnelBridgeEnd(), and GetRailTrackBitsUniversal().

TileIndex GetSouthernBridgeEnd | ( | TileIndex | t | ) |

Finds the southern end of a bridge starting at a middle tile.

Parameters:

  | t | the bridge tile to find the bridge ramp for

Definition at line 30 of file bridge_map.cpp.

References AxisToDiagDir(), GetBridgeAxis(), and GetBridgeEnd().

Referenced by CmdTerraformLand().

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

Checks if this is a bridge, instead of a tunnel.

Parameters:

  | t | The tile to analyze

Precondition:
  IsTileType(t, MP_TUNNELBRIDGE)

Returns:
  true if the structure is a bridge one

Definition at line 20 of file bridge_map.h.

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

Referenced by CmdBuildLongRoad(), CmdBuildRoad(), CmdConvertRail(), IsBridgeTile(), and RemoveRoad().

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

checks if a bridge is set above the ground of this tile

Parameters:

  | t | The tile to analyze

Precondition:
  MayHaveBridgeAbove(t)

Returns:
  true if a bridge is detected above

Definition at line 59 of file bridge_map.h.

References _m, GB(), and MayHaveBridgeAbove().

Referenced by CanBuildHouseHere(), CanPlantTreesOnTile(), CheckFlatLandBelow(), CmdBuildBridge(), CmdBuildBuoy(), CmdBuildDock(), CmdBuildRoadDepot(), CmdBuildShipDepot(), CmdBuildTrainDepot(), CmdBuildTrainWaypoint(), CmdPlantTree(), CmdTerraformLand(), DoBuildShiplift(), DrawCatenaryRailway(), DrawRoadBits(), DrawTramCatenary(), and GetBridgeAxis().

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

checks if there is a bridge on this tile

Parameters:

  | t | The tile to analyze

Returns:
  true if a bridge is present

Definition at line 31 of file bridge_map.h.

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

Referenced by CmdBuildBridge(), DrawCatenaryRailway(), FloodVehicles(), GetBridgeEnd(), GetBridgeType(), GetOtherBridgeEnd(), CFollowTrackT< Ttr_type_, T90deg_turns_allowed_, Tmask_reserved_tracks >::GetSpeedLimit(), and AIBridge::IsBridgeTile().

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

Make a bridge ramp for aqueducts.

Parameters:

  | t | the tile to make a bridge ramp
  | o | the new owner of the bridge ramp
  | d | the direction this ramp must be facing

Definition at line 214 of file bridge_map.h.

References MakeBridgeRamp(), and TRANSPORT_WATER.

Referenced by CmdBuildBridge().

static void MakeBridgeRamp | ( | TileIndex | t,
|  | Owner | o,
|  | BridgeType | bridgetype,
|  | DiagDirection | d,
|  | TransportType | tt,
|  | uint | rt |
| ) |  |  | `[inline, static]`

Generic part to make a bridge ramp for both roads and rails.

Parameters:

  | t | the tile to make a bridge ramp
  | o | the new owner of the bridge ramp
  | bridgetype | the type of bridge this bridge ramp belongs to
  | d | the direction this ramp must be facing
  | tt | the transport type of the bridge
  | rt | the road or rail type

Note:
  this function should not be called directly.

Definition at line 167 of file bridge_map.h.

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

Referenced by MakeAqueductBridgeRamp(), MakeRailBridgeRamp(), and MakeRoadBridgeRamp().

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

Make a bridge ramp for rails.

Parameters:

  | t | the tile to make a bridge ramp
  | o | the new owner of the bridge ramp
  | bridgetype | the type of bridge this bridge ramp belongs to
  | d | the direction this ramp must be facing
  | r | the rail type of the bridge

Definition at line 203 of file bridge_map.h.

References MakeBridgeRamp(), and TRANSPORT_RAIL.

Referenced by CmdBuildBridge().

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

Make a bridge ramp for roads.

Parameters:

  | t | the tile to make a bridge ramp
  | o | the new owner of the bridge ramp
  | bridgetype | the type of bridge this bridge ramp belongs to
  | d | the direction this ramp must be facing
  | r | the road type of the bridge

Definition at line 187 of file bridge_map.h.

References MakeBridgeRamp(), OWNER_TOWN, ROADTYPE_ROAD, ROADTYPE_TRAM, and TRANSPORT_ROAD.

Referenced by CmdBuildBridge().

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

checks for the possibility that a bridge may be on this tile These are in fact all the tile types on which a bridge can be found

Parameters:

  | t | The tile to analyze

Returns:
  true if a bridge migh be present

Definition at line 42 of file bridge_map.h.

References IsTileType(), MP_CLEAR, MP_RAILWAY, MP_ROAD, MP_TUNNELBRIDGE, MP_UNMOVABLE, and MP_WATER.

Referenced by CanBuildHouseHere(), CheckFlatLandBelow(), ClearSingleBridgeMiddle(), CmdBuildBridge(), CmdBuildBuoy(), CmdBuildDock(), CmdBuildRoadDepot(), CmdBuildTrainDepot(), CmdBuildTrainWaypoint(), CmdTerraformLand(), DoBuildShiplift(), DrawCatenaryRailway(), DrawRoadBits(), DrawTramCatenary(), IsBridgeAbove(), MakeClear(), and SetBridgeMiddle().

static void SetBridgeMiddle | ( | TileIndex | t,
|  | Axis | a |
| ) |  |  | `[inline, static]`

Set that there is a bridge over the given axis.

Parameters:

  | t | the tile to add the bridge to
  | a | the axis of the bridge to add

Precondition:
  MayHaveBridgeAbove(t)

Definition at line 151 of file bridge_map.h.

References _m, MayHaveBridgeAbove(), and SetBit().

Referenced by CmdBuildBridge().