4 * This file is part of OpenTTD.
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
10 /** @file bridge.h Header file for bridges */
19 * This enum is related to the definition of bridge pieces,
20 * which is used to determine the proper sprite table to use
21 * while drawing a given bridge part.
24 BRIDGE_PIECE_NORTH
= 0,
26 BRIDGE_PIECE_INNER_NORTH
,
27 BRIDGE_PIECE_INNER_SOUTH
,
28 BRIDGE_PIECE_MIDDLE_ODD
,
29 BRIDGE_PIECE_MIDDLE_EVEN
,
34 DECLARE_POSTFIX_INCREMENT(BridgePieces
)
36 static const uint MAX_BRIDGES
= 13; ///< Maximal number of available bridge specs.
38 typedef uint BridgeType
; ///< Bridge spec number.
41 * Struct containing information about a single bridge type
44 Year avail_year
; ///< the year where it becomes available
45 byte min_length
; ///< the minimum length (not counting start and end tile)
46 uint16 max_length
; ///< the maximum length (not counting start and end tile)
47 uint16 price
; ///< the price multiplier
48 uint16 speed
; ///< maximum travel speed (1 unit = 1/1.6 mph = 1 km-ish/h)
49 SpriteID sprite
; ///< the sprite which is used in the GUI
50 PaletteID pal
; ///< the palette which is used in the GUI
51 StringID material
; ///< the string that contains the bridge description
52 StringID transport_name
[2]; ///< description of the bridge, when built for road or rail
53 PalSpriteID
**sprite_table
; ///< table of sprites for drawing the bridge
54 byte flags
; ///< bit 0 set: disable drawing of far pillars.
57 extern BridgeSpec _bridge
[MAX_BRIDGES
];
59 Foundation
GetBridgeFoundation(Slope tileh
, Axis axis
);
60 bool HasBridgeFlatRamp(Slope tileh
, Axis axis
);
63 * Get the specification of a bridge type.
64 * @param i The type of bridge to get the specification for.
65 * @return The specification.
67 static inline const BridgeSpec
*GetBridgeSpec(BridgeType i
)
69 assert(i
< lengthof(_bridge
));
73 void DrawBridgeMiddle(const TileInfo
*ti
);
75 CommandCost
CheckBridgeAvailability(BridgeType bridge_type
, uint bridge_len
, DoCommandFlag flags
= DC_NONE
);
76 int CalcBridgeLenCostFactor(int x
);