Data Structures | Typedefs | Enumerations | Functions | Variables
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...


typedef uint BridgeType
 Bridge spec number.


enum  BridgePieces {
 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.


Foundation GetBridgeFoundation (Slope tileh, Axis axis)
 Get the foundation for a bridge. More...
bool HasBridgeFlatRamp (Slope tileh, Axis axis)
 Determines if the track on a bridge ramp is flat or goes up/down. More...
static const BridgeSpecGetBridgeSpec (BridgeType i)
 Get the specification of a bridge type. More...
void DrawBridgeMiddle (const TileInfo *ti)
 Draw the middle bits of a bridge. More...
CommandCost CheckBridgeAvailability (BridgeType bridge_type, uint bridge_len, DoCommandFlag flags=DC_NONE)
 Is a bridge of the specified type and length available? More...
int CalcBridgeLenCostFactor (int x)
 Calculate the price factor for building a long bridge. More...
void ResetBridges ()
 Reset the data been eventually changed by the grf loaded. More...


static const uint MAX_BRIDGES = 13
 Maximal number of available bridge specs.
BridgeSpec _bridge [MAX_BRIDGES]
 The specification of all bridges.

Detailed Description

Header file for bridges.

Definition in file bridge.h.

Function Documentation

◆ CalcBridgeLenCostFactor()

int CalcBridgeLenCostFactor ( int  length)

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,

lengthLength of the bridge.
Price factor for the bridge.

Definition at line 105 of file tunnelbridge_cmd.cpp.

Referenced by ShowBuildBridgeWindow().

◆ CheckBridgeAvailability()

CommandCost CheckBridgeAvailability ( BridgeType  bridge_type,
uint  bridge_len,
DoCommandFlag  flags 

Is a bridge of the specified type and length available?

bridge_typeWanted type of bridge.
bridge_lenWanted length of the bridge.
A succeeded (the requested bridge is available) or failed (it cannot be built) command.

Definition at line 209 of file tunnelbridge_cmd.cpp.

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

Referenced by ShowBuildBridgeWindow().

◆ DrawBridgeMiddle()

void DrawBridgeMiddle ( const TileInfo ti)

◆ GetBridgeFoundation()

Foundation GetBridgeFoundation ( Slope  tileh,
Axis  axis 

Get the foundation for a bridge.

tilehThe slope to build the bridge on.
axisThe axis of the bridge entrance.
The foundation required.

Definition at line 126 of file tunnelbridge_cmd.cpp.

References AXIS_X, AXIS_Y, FlatteningFoundation(), FOUNDATION_NONE, HasSlopeHighestCorner(), InclinedFoundation(), SLOPE_FLAT, SLOPE_NE, SLOPE_NW, SLOPE_SE, and SLOPE_SW.

Referenced by CheckBridgeSlopeNorth(), CheckBridgeSlopeSouth(), GetBridgeHeight(), and HasBridgeFlatRamp().

◆ GetBridgeSpec()

static const BridgeSpec* GetBridgeSpec ( BridgeType  i)

Get the specification of a bridge type.

iThe type of bridge to get the specification for.
The specification.

Definition at line 67 of file bridge.h.

Referenced by CheckBridgeAvailability(), DrawBridgeMiddle(), and CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::GetSpeedLimit().

◆ HasBridgeFlatRamp()

bool HasBridgeFlatRamp ( Slope  tileh,
Axis  axis 

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

tilehSlope of the tile under the bridge head
axisOrientation of bridge
true iff the track is flat.

Definition at line 142 of file tunnelbridge_cmd.cpp.

References ApplyFoundationToSlope(), GetBridgeFoundation(), and SLOPE_FLAT.

Referenced by CYapfCostBase::stSlopeCost().

◆ ResetBridges()

void ResetBridges ( )

Reset the data been eventually changed by the grf loaded.

Definition at line 83 of file tunnelbridge_cmd.cpp.

References MAX_BRIDGES.