2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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/>.
8 /** @file bridge.h Header file for bridges */
15 #include "timer/timer_game_calendar.h"
18 * This enum is related to the definition of bridge pieces,
19 * which is used to determine the proper sprite table to use
20 * while drawing a given bridge part.
23 BRIDGE_PIECE_NORTH
= 0,
25 BRIDGE_PIECE_INNER_NORTH
,
26 BRIDGE_PIECE_INNER_SOUTH
,
27 BRIDGE_PIECE_MIDDLE_ODD
,
28 BRIDGE_PIECE_MIDDLE_EVEN
,
33 DECLARE_POSTFIX_INCREMENT(BridgePieces
)
35 static const uint MAX_BRIDGES
= 13; ///< Maximal number of available bridge specs.
37 typedef uint BridgeType
; ///< Bridge spec number.
40 * Struct containing information about a single bridge type
43 TimerGameCalendar::Year avail_year
; ///< the year where it becomes available
44 byte min_length
; ///< the minimum length (not counting start and end tile)
45 uint16_t max_length
; ///< the maximum length (not counting start and end tile)
46 uint16_t price
; ///< the price multiplier
47 uint16_t speed
; ///< maximum travel speed (1 unit = 1/1.6 mph = 1 km-ish/h)
48 SpriteID sprite
; ///< the sprite which is used in the GUI
49 PaletteID pal
; ///< the palette which is used in the GUI
50 StringID material
; ///< the string that contains the bridge description
51 StringID transport_name
[2]; ///< description of the bridge, when built for road or rail
52 PalSpriteID
**sprite_table
; ///< table of sprites for drawing the bridge
53 byte flags
; ///< bit 0 set: disable drawing of far pillars.
56 extern BridgeSpec _bridge
[MAX_BRIDGES
];
58 Foundation
GetBridgeFoundation(Slope tileh
, Axis axis
);
59 bool HasBridgeFlatRamp(Slope tileh
, Axis axis
);
62 * Get the specification of a bridge type.
63 * @param i The type of bridge to get the specification for.
64 * @return The specification.
66 inline const BridgeSpec
*GetBridgeSpec(BridgeType i
)
68 assert(i
< lengthof(_bridge
));
72 void DrawBridgeMiddle(const TileInfo
*ti
);
74 CommandCost
CheckBridgeAvailability(BridgeType bridge_type
, uint bridge_len
, DoCommandFlag flags
= DC_NONE
);
75 int CalcBridgeLenCostFactor(int x
);