OpenTTD Source: src/bridge_map.h File Reference

OpenTTD Source 15.3

Functions
bridge_map.h File Reference

Map accessor functions for bridges. More...

`#include "rail_map.h"`
`#include "road_map.h"`
`#include "bridge.h"`
`#include "water_map.h"`

Go to the source code of this file.

## Functions
bool | IsBridge (Tile t)
| Checks if this is a bridge, instead of a tunnel.
bool | IsBridgeTile (Tile t)
| checks if there is a bridge on this tile
bool | IsBridgeAbove (Tile t)
| checks if a bridge is set above the ground of this tile
BridgeType | GetBridgeType (Tile t)
| Determines the type of bridge on a tile.
Axis | GetBridgeAxis (Tile t)
| Get the axis of the bridge that goes over the 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.
int | GetBridgeHeight (TileIndex tile)
| Get the height ('z') of a bridge.
int | GetBridgePixelHeight (TileIndex tile)
| Get the height ('z') of a bridge in pixels.
void | ClearSingleBridgeMiddle (Tile t, Axis a)
| Remove the bridge over the given axis.
void | ClearBridgeMiddle (Tile t)
| Removes bridges from the given, that is bridges along the X and Y axis.
void | SetBridgeMiddle (Tile t, Axis a)
| Set that there is a bridge over the given axis.
void | MakeBridgeRamp (Tile t, Owner o, BridgeType bridgetype, DiagDirection d, TransportType tt)
| Generic part to make a bridge ramp for both roads and rails.
void | MakeRoadBridgeRamp (Tile t, Owner o, Owner owner_road, Owner owner_tram, BridgeType bridgetype, DiagDirection d, RoadType road_rt, RoadType tram_rt)
| Make a bridge ramp for roads.
void | MakeRailBridgeRamp (Tile t, Owner o, BridgeType bridgetype, DiagDirection d, RailType rt)
| Make a bridge ramp for rails.
void | MakeAqueductBridgeRamp (Tile 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

## ◆ ClearBridgeMiddle()

void ClearBridgeMiddle | ( | Tile | t | ) |
| inline

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

Parameters

  t | the tile to remove the bridge from

Definition at line 103 of file bridge_map.h.

References AXIS_X, AXIS_Y, and ClearSingleBridgeMiddle().

Referenced by AfterLoadGame(), and DoClearBridge().

## ◆ ClearSingleBridgeMiddle()

void ClearSingleBridgeMiddle | ( | Tile | t,
|  | Axis | a
| ) |  |
| inline

Remove the bridge over the given axis.

Parameters

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

Definition at line 94 of file bridge_map.h.

References ClrBit(), and Tile::type().

Referenced by ClearBridgeMiddle().

## ◆ GetBridgeAxis()

Axis GetBridgeAxis | ( | Tile | t | ) |
| inline

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 68 of file bridge_map.h.

References GB(), IsBridgeAbove(), and Tile::type().

Referenced by CmdBuildBridge(), DrawBridgeMiddle(), DrawRailCatenaryOnBridge(), DrawRailCatenaryRailway(), GetNorthernBridgeEnd(), GetSouthernBridgeEnd(), and IsRoadAllowedHere().

## ◆ GetBridgeHeight()

int GetBridgeHeight | ( | TileIndex | t | ) |

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

Parameters

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

Returns
  the height of the bridge.

Definition at line 70 of file bridge_map.cpp.

References ApplyFoundationToSlope(), DiagDirToAxis(), GetBridgeFoundation(), GetTileSlopeZ(), and GetTunnelBridgeDirection().

Referenced by CmdBuildBridge(), CmdBuildObject(), CmdTerraformLand(), DoBuildLock(), DoClearBridge(), DrawRailCatenaryRailway(), DrawRoadBits(), DrawRoadTypeCatenary(), GetBridgePixelHeight(), GetTerrainType(), IsBuoyBridgeAboveOk(), IsDockBridgeAboveOk(), IsRailStationBridgeAboveOk(), IsRoadStationBridgeAboveOk(), and MarkBridgeDirty().

## ◆ GetBridgePixelHeight()

int GetBridgePixelHeight | ( | TileIndex | tile | ) |
| inline

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 84 of file bridge_map.h.

References GetBridgeHeight(), and TILE_HEIGHT.

Referenced by DrawBridgeMiddle(), DrawRailCatenaryOnBridge(), FloodVehicles(), and ViewportAddLandscape().

## ◆ GetBridgeType()

BridgeType GetBridgeType | ( | Tile | t | ) |
| inline

Determines the type of bridge on a tile.

Parameters

  t | The tile to analyze

Precondition
  IsBridgeTile(t)

Returns
  The bridge type

Definition at line 56 of file bridge_map.h.

References GB(), IsBridgeTile(), and Tile::m6().

Referenced by CmdBuildBridge(), DrawBridgeMiddle(), DrawTile_TunnelBridge(), RoadVehicle::GetCurrentMaxSpeed(), Train::GetCurrentMaxSpeed(), and CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::GetSpeedLimit().

## ◆ GetNorthernBridgeEnd()

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 39 of file bridge_map.cpp.

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

Referenced by AfterLoadGame(), CmdBuildBridge(), DrawBridgeMiddle(), DrawRailCatenaryRailway(), DrawRoadBits(), DrawRoadTypeCatenary(), and ViewportAddLandscape().

## ◆ GetOtherBridgeEnd()

TileIndex GetOtherBridgeEnd | ( | TileIndex | tile | ) |

Starting at one bridge end finds the other bridge end.

Parameters

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

Definition at line 59 of file bridge_map.cpp.

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

Referenced by CmdBuildBridge(), DoClearBridge(), DrawRailCatenaryOnBridge(), FloodVehicles(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::FollowTileExit(), GetOtherTunnelBridgeEnd(), GetRailTrackBitsUniversal(), and VisitWaterRegionPatchNeighbours().

## ◆ GetSouthernBridgeEnd()

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 49 of file bridge_map.cpp.

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

Referenced by CmdBuildObject(), CmdTerraformLand(), DoBuildLock(), DrawBridgeMiddle(), DrawRailCatenaryOnBridge(), IsBuoyBridgeAboveOk(), IsDockBridgeAboveOk(), IsRailStationBridgeAboveOk(), and IsRoadStationBridgeAboveOk().

## ◆ IsBridge()

bool IsBridge | ( | Tile | t | ) |
| inline

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 24 of file bridge_map.h.

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

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

## ◆ IsBridgeAbove()

bool IsBridgeAbove | ( | Tile | t | ) |
| inline

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

Parameters

  t | The tile to analyze

Returns
  true if a bridge is detected above

Definition at line 45 of file bridge_map.h.

References GB(), and Tile::type().

Referenced by CanBuildHouseHere(), CanPlantTreesOnTile(), CheckBuildableTile(), CheckIfIndustryTilesAreFree(), CmdBuildBridge(), CmdBuildObject(), CmdBuildRailStation(), CmdBuildRoadDepot(), CmdBuildShipDepot(), CmdBuildTrainDepot(), CmdPlaceHouse(), CmdPlantTree(), CmdTerraformLand(), DoBuildLock(), DrawBridgeMiddle(), DrawRailCatenaryRailway(), DrawRoadBits(), DrawRoadTypeCatenary(), DrawTile_Road(), GetBridgeAxis(), IsBridgeAboveVehicle(), IsBuoyBridgeAboveOk(), IsDockBridgeAboveOk(), IsRailStationBridgeAboveOk(), IsRoadAllowedHere(), IsRoadStationBridgeAboveOk(), TownActionBuildStatue(), TryBuildLightHouse(), TryBuildTransmitter(), and ViewportAddLandscape().

## ◆ IsBridgeTile()

bool IsBridgeTile | ( | Tile | t | ) |
| inline

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 35 of file bridge_map.h.

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

Referenced by AfterLoadGame(), CmdBuildBridge(), DrawRailCatenaryRailway(), FloodVehicles(), GetBridgeEnd(), GetBridgeType(), GetOtherBridgeEnd(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::GetSpeedLimit(), GrowTownWithBridge(), IsBridgeAboveVehicle(), PlaceRail_Bridge(), PlaceRoad_Bridge(), ShowBuildBridgeWindow(), CYapfCostBase::stSlopeCost(), TryReserveRailTrack(), UnreserveRailTrack(), and UpdateStatusAfterSwap().

## ◆ MakeAqueductBridgeRamp()

void MakeAqueductBridgeRamp | ( | Tile | t,
|  | Owner | o,
|  | DiagDirection | d
| ) |  |
| inline

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 182 of file bridge_map.h.

References MakeBridgeRamp(), and TRANSPORT_WATER.

Referenced by CmdBuildBridge().

## ◆ MakeBridgeRamp()

void MakeBridgeRamp | ( | Tile | t,
|  | Owner | o,
|  | BridgeType | bridgetype,
|  | DiagDirection | d,
|  | TransportType | tt
| ) |  |
| inline

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

Note
  this function should not be called directly.

Definition at line 128 of file bridge_map.h.

References Tile::m2(), Tile::m3(), Tile::m4(), Tile::m5(), Tile::m6(), Tile::m7(), Tile::m8(), MP_TUNNELBRIDGE, SB(), SetDockingTile(), SetTileOwner(), and SetTileType().

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

## ◆ MakeRailBridgeRamp()

void MakeRailBridgeRamp | ( | Tile | t,
|  | Owner | o,
|  | BridgeType | bridgetype,
|  | DiagDirection | d,
|  | RailType | rt
| ) |  |
| inline

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
  rt | the rail type of the bridge

Definition at line 170 of file bridge_map.h.

References MakeBridgeRamp(), SetRailType(), and TRANSPORT_RAIL.

Referenced by CmdBuildBridge().

## ◆ MakeRoadBridgeRamp()

void MakeRoadBridgeRamp | ( | Tile | t,
|  | Owner | o,
|  | Owner | owner_road,
|  | Owner | owner_tram,
|  | BridgeType | bridgetype,
|  | DiagDirection | d,
|  | RoadType | road_rt,
|  | RoadType | tram_rt
| ) |  |
| inline

Make a bridge ramp for roads.

Parameters

  t | the tile to make a bridge ramp
  o | the new owner of the bridge ramp
  owner_road | the new owner of the road on the bridge
  owner_tram | the new owner of the tram on the bridge
  bridgetype | the type of bridge this bridge ramp belongs to
  d | the direction this ramp must be facing
  road_rt | the road type of the bridge
  tram_rt | the tram type of the bridge

Definition at line 154 of file bridge_map.h.

References MakeBridgeRamp(), OWNER_TOWN, RTT_ROAD, RTT_TRAM, SetRoadOwner(), SetRoadTypes(), and TRANSPORT_ROAD.

Referenced by CmdBuildBridge().

## ◆ SetBridgeMiddle()

void SetBridgeMiddle | ( | Tile | t,
|  | Axis | a
| ) |  |
| inline

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

Definition at line 114 of file bridge_map.h.

References SetBit(), and Tile::type().

Referenced by AfterLoadGame(), and CmdBuildBridge().