OpenTTD Source  12.0-beta2
bridge_map.h File Reference
#include "rail_map.h"
#include "road_map.h"
#include "bridge.h"
#include "water_map.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. More...
 
static bool IsBridgeTile (TileIndex t)
 checks if there is a bridge on this tile More...
 
static bool IsBridgeAbove (TileIndex t)
 checks if a bridge is set above the ground of this tile More...
 
static BridgeType GetBridgeType (TileIndex t)
 Determines the type of bridge on a tile. More...
 
static Axis GetBridgeAxis (TileIndex t)
 Get the axis of the bridge that goes over the tile. More...
 
TileIndex GetNorthernBridgeEnd (TileIndex t)
 Finds the northern end of a bridge starting at a middle tile. More...
 
TileIndex GetSouthernBridgeEnd (TileIndex t)
 Finds the southern end of a bridge starting at a middle tile. More...
 
TileIndex GetOtherBridgeEnd (TileIndex t)
 Starting at one bridge end finds the other bridge end. More...
 
int GetBridgeHeight (TileIndex tile)
 Get the height ('z') of a bridge. More...
 
static int GetBridgePixelHeight (TileIndex tile)
 Get the height ('z') of a bridge in pixels. More...
 
static void ClearSingleBridgeMiddle (TileIndex t, Axis a)
 Remove the bridge over the given axis. More...
 
static void ClearBridgeMiddle (TileIndex t)
 Removes bridges from the given, that is bridges along the X and Y axis. More...
 
static void SetBridgeMiddle (TileIndex t, Axis a)
 Set that there is a bridge over the given axis. More...
 
static void MakeBridgeRamp (TileIndex t, Owner o, BridgeType bridgetype, DiagDirection d, TransportType tt)
 Generic part to make a bridge ramp for both roads and rails. More...
 
static void MakeRoadBridgeRamp (TileIndex 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. More...
 
static void MakeRailBridgeRamp (TileIndex t, Owner o, BridgeType bridgetype, DiagDirection d, RailType rt)
 Make a bridge ramp for rails. More...
 
static void MakeAqueductBridgeRamp (TileIndex t, Owner o, DiagDirection d)
 Make a bridge ramp for aqueducts. More...
 

Detailed Description

Map accessor functions for bridges.

Definition in file bridge_map.h.

Function Documentation

◆ ClearBridgeMiddle()

static void ClearBridgeMiddle ( TileIndex  t)
inlinestatic

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

Parameters
tthe tile to remove the bridge from

Definition at line 103 of file bridge_map.h.

References AXIS_X, AXIS_Y, and ClearSingleBridgeMiddle().

◆ ClearSingleBridgeMiddle()

static void ClearSingleBridgeMiddle ( TileIndex  t,
Axis  a 
)
inlinestatic

Remove the bridge over the given axis.

Parameters
tthe tile to remove the bridge from
athe axis of the bridge to remove

Definition at line 94 of file bridge_map.h.

References _m, and ClrBit().

Referenced by ClearBridgeMiddle().

◆ GetBridgeAxis()

static Axis GetBridgeAxis ( TileIndex  t)
inlinestatic

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

Not the axis or the ramp.

Parameters
tThe tile to analyze
Precondition
IsBridgeAbove(t)
Returns
the above mentioned axis

Definition at line 68 of file bridge_map.h.

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

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

◆ GetBridgeHeight()

int GetBridgeHeight ( TileIndex  t)

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

Parameters
tthe 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(), GetTileSlope(), and GetTunnelBridgeDirection().

Referenced by CmdTerraformLand(), DrawRoadTypeCatenary(), GetBridgePixelHeight(), and MarkBridgeDirty().

◆ GetBridgePixelHeight()

static int GetBridgePixelHeight ( TileIndex  tile)
inlinestatic

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

Parameters
tilethe 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 FloodVehicles().

◆ GetBridgeType()

static BridgeType GetBridgeType ( TileIndex  t)
inlinestatic

Determines the type of bridge on a tile.

Parameters
tThe tile to analyze
Precondition
IsBridgeTile(t)
Returns
The bridge type

Definition at line 56 of file bridge_map.h.

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

Referenced by DrawBridgeMiddle(), 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
tthe 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 DrawBridgeMiddle(), and DrawRoadTypeCatenary().

◆ GetOtherBridgeEnd()

TileIndex GetOtherBridgeEnd ( TileIndex  tile)

Starting at one bridge end finds the other bridge end.

Parameters
tilethe 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 DoClearBridge(), DrawRailCatenaryOnBridge(), FloodVehicles(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::FollowTileExit(), GetOtherTunnelBridgeEnd(), and GetRailTrackBitsUniversal().

◆ GetSouthernBridgeEnd()

TileIndex GetSouthernBridgeEnd ( TileIndex  t)

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

Parameters
tthe bridge tile to find the bridge ramp for

Definition at line 49 of file bridge_map.cpp.

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

Referenced by CmdTerraformLand(), DrawBridgeMiddle(), and DrawRailCatenaryOnBridge().

◆ IsBridge()

static bool IsBridge ( TileIndex  t)
inlinestatic

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

Parameters
tThe 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 _m, HasBit(), IsTileType(), and MP_TUNNELBRIDGE.

Referenced by ClearPathReservation(), CmdBuildLongRoad(), CmdConvertRail(), and IsBridgeTile().

◆ IsBridgeAbove()

static bool IsBridgeAbove ( TileIndex  t)
inlinestatic

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

Parameters
tThe tile to analyze
Returns
true if a bridge is detected above

Definition at line 45 of file bridge_map.h.

References _m, and GB().

Referenced by CanBuildHouseHere(), CanPlantTreesOnTile(), CheckBuildableTile(), CheckIfIndustryTilesAreFree(), CmdBuildBuoy(), CmdBuildShipDepot(), CmdTerraformLand(), DrawBridgeMiddle(), DrawRoadTypeCatenary(), GetBridgeAxis(), IsRoadAllowedHere(), SearchTileForStatue(), and TryBuildTransmitter().

◆ IsBridgeTile()

◆ MakeAqueductBridgeRamp()

static void MakeAqueductBridgeRamp ( TileIndex  t,
Owner  o,
DiagDirection  d 
)
inlinestatic

Make a bridge ramp for aqueducts.

Parameters
tthe tile to make a bridge ramp
othe new owner of the bridge ramp
dthe direction this ramp must be facing

Definition at line 181 of file bridge_map.h.

References MakeBridgeRamp(), and TRANSPORT_WATER.

◆ MakeBridgeRamp()

static void MakeBridgeRamp ( TileIndex  t,
Owner  o,
BridgeType  bridgetype,
DiagDirection  d,
TransportType  tt 
)
inlinestatic

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

Parameters
tthe tile to make a bridge ramp
othe new owner of the bridge ramp
bridgetypethe type of bridge this bridge ramp belongs to
dthe direction this ramp must be facing
ttthe transport type of the bridge
Note
this function should not be called directly.

Definition at line 128 of file bridge_map.h.

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

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

◆ MakeRailBridgeRamp()

static void MakeRailBridgeRamp ( TileIndex  t,
Owner  o,
BridgeType  bridgetype,
DiagDirection  d,
RailType  rt 
)
inlinestatic

Make a bridge ramp for rails.

Parameters
tthe tile to make a bridge ramp
othe new owner of the bridge ramp
bridgetypethe type of bridge this bridge ramp belongs to
dthe direction this ramp must be facing
rtthe rail type of the bridge

Definition at line 169 of file bridge_map.h.

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

◆ MakeRoadBridgeRamp()

static void MakeRoadBridgeRamp ( TileIndex  t,
Owner  o,
Owner  owner_road,
Owner  owner_tram,
BridgeType  bridgetype,
DiagDirection  d,
RoadType  road_rt,
RoadType  tram_rt 
)
inlinestatic

Make a bridge ramp for roads.

Parameters
tthe tile to make a bridge ramp
othe new owner of the bridge ramp
owner_roadthe new owner of the road on the bridge
owner_tramthe new owner of the tram on the bridge
bridgetypethe type of bridge this bridge ramp belongs to
dthe direction this ramp must be facing
road_rtthe road type of the bridge
tram_rtthe tram type of the bridge

Definition at line 153 of file bridge_map.h.

References MakeBridgeRamp(), SetRoadOwner(), and TRANSPORT_ROAD.

◆ SetBridgeMiddle()

static void SetBridgeMiddle ( TileIndex  t,
Axis  a 
)
inlinestatic

Set that there is a bridge over the given axis.

Parameters
tthe tile to add the bridge to
athe axis of the bridge to add

Definition at line 114 of file bridge_map.h.

References _m, and SetBit().