Update readme.md
[openttd-joker.git] / src / bridge.h
blobbadf045e391a4e44f5abeb6582747411e6c563dd
1 /* $Id$ */
3 /*
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/>.
8 */
10 /** @file bridge.h Header file for bridges */
12 #ifndef BRIDGE_H
13 #define BRIDGE_H
15 #include "gfx_type.h"
16 #include "tile_cmd.h"
18 /**
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.
23 enum BridgePieces {
24 BRIDGE_PIECE_NORTH = 0,
25 BRIDGE_PIECE_SOUTH,
26 BRIDGE_PIECE_INNER_NORTH,
27 BRIDGE_PIECE_INNER_SOUTH,
28 BRIDGE_PIECE_MIDDLE_ODD,
29 BRIDGE_PIECE_MIDDLE_EVEN,
30 BRIDGE_PIECE_HEAD,
31 BRIDGE_PIECE_INVALID,
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.
40 /**
41 * Struct containing information about a single bridge type
43 struct BridgeSpec {
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);
62 /**
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));
70 return &_bridge[i];
73 void DrawBridgeMiddle(const TileInfo *ti);
75 CommandCost CheckBridgeAvailability(BridgeType bridge_type, uint bridge_len, DoCommandFlag flags = DC_NONE);
76 int CalcBridgeLenCostFactor(int x);
78 void ResetBridges();
80 #endif /* BRIDGE_H */