# bridge.h File Reference

Header file for bridges. More...

`#include "gfx_type.h"`
`#include "tile_cmd.h"`

Go to the source code of this file.

## Data Structures
struct | BridgeSpec
| Struct containing information about a single bridge type. More...
## Typedefs
typedef uint | BridgeType
## Enumerations
enum | BridgePieces { BRIDGE_PIECE_NORTH = 0, BRIDGE_PIECE_SOUTH, BRIDGE_PIECE_INNER_NORTH, BRIDGE_PIECE_INNER_SOUTH, BRIDGE_PIECE_MIDDLE_ODD, BRIDGE_PIECE_MIDDLE_EVEN, BRIDGE_PIECE_HEAD, BRIDGE_PIECE_INVALID }
| This enum is related to the definition of bridge pieces, which is used to determine the proper sprite table to use while drawing a given bridge part.
enum | { MAX_BRIDGES = 13 }
## Functions
| DECLARE_POSTFIX_INCREMENT (BridgePieces)
Foundation | GetBridgeFoundation (Slope tileh, Axis axis)
bool | HasBridgeFlatRamp (Slope tileh, Axis axis)
| Determines if the track on a bridge ramp is flat or goes up/down.
static const BridgeSpec * | GetBridgeSpec (BridgeType i)
void | DrawBridgeMiddle (const TileInfo *ti)
CommandCost | CheckBridgeAvailability (BridgeType bridge_type, uint bridge_len, DoCommandFlag flags=DC_NONE)
| Is a bridge of the specified type and length available?
int | CalcBridgeLenCostFactor (int x)
| calculate the price factor for building a long bridge.
void | ResetBridges ()
| Reset the data been eventually changed by the grf loaded.
## Variables
BridgeSpec | _bridge [MAX_BRIDGES]

## Detailed Description

Header file for bridges.

Definition in file bridge.h.

## Function Documentation

int CalcBridgeLenCostFactor | ( | int | x | ) |

calculate the price factor for building a long bridge.

basically the cost delta is 1,1, 1, 2,2, 3,3,3, 4,4,4,4, 5,5,5,5,5, 6,6,6,6,6,6, 7,7,7,7,7,7,7, 8,8,8,8,8,8,8,8,

Definition at line 73 of file tunnelbridge_cmd.cpp.

Referenced by CmdBuildBridge(), AIBridge::GetPrice(), and ShowBuildBridgeWindow().

CommandCost CheckBridgeAvailability | ( | BridgeType | bridge_type,
|  | uint | bridge_len,
|  | DoCommandFlag | flags |
| ) |  |  |

Is a bridge of the specified type and length available?

Parameters:

  | bridge_type | Wanted type of bridge.
  | bridge_len | Wanted length of the bridge.

Returns:
  A succeeded (the requested bridge is available) or failed (it cannot be built) command.

Definition at line 169 of file tunnelbridge_cmd.cpp.

References _cur_year, _settings_game, BridgeSpec::avail_year, CMD_ERROR, GameSettings::construction, DC_QUERY_COST, ConstructionSettings::longbridges, max(), BridgeSpec::max_length, BridgeSpec::min_length, and return_cmd_error.

Referenced by CmdBuildBridge(), and ShowBuildBridgeWindow().

bool HasBridgeFlatRamp | ( | Slope | tileh,
|  | Axis | axis |
| ) |  |  |

Determines if the track on a bridge ramp is flat or goes up/down.

Parameters:

  | tileh | Slope of the tile under the bridge head
  | axis | Orientation of bridge

Returns:
  true iff the track is flat.

Definition at line 103 of file tunnelbridge_cmd.cpp.

References ApplyFoundationToSlope(), and SLOPE_FLAT.

Referenced by DrawTile_TunnelBridge().

void ResetBridges | ( |  | ) |

Reset the data been eventually changed by the grf loaded.

Definition at line 54 of file tunnelbridge_cmd.cpp.

Referenced by ResetNewGRFData().