Fix 03cc0d6: Mark level crossings dirty when removing road from them, not from bridge...
[openttd-github.git] / src / bridge.h
blob3da95751df4d84d72ec9c4f189311a20528abb08
1 /*
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/>.
6 */
8 /** @file bridge.h Header file for bridges */
10 #ifndef BRIDGE_H
11 #define BRIDGE_H
13 #include "gfx_type.h"
14 #include "tile_cmd.h"
16 /**
17 * This enum is related to the definition of bridge pieces,
18 * which is used to determine the proper sprite table to use
19 * while drawing a given bridge part.
21 enum BridgePieces {
22 BRIDGE_PIECE_NORTH = 0,
23 BRIDGE_PIECE_SOUTH,
24 BRIDGE_PIECE_INNER_NORTH,
25 BRIDGE_PIECE_INNER_SOUTH,
26 BRIDGE_PIECE_MIDDLE_ODD,
27 BRIDGE_PIECE_MIDDLE_EVEN,
28 BRIDGE_PIECE_HEAD,
29 BRIDGE_PIECE_INVALID,
32 DECLARE_POSTFIX_INCREMENT(BridgePieces)
34 static const uint MAX_BRIDGES = 13; ///< Maximal number of available bridge specs.
36 typedef uint BridgeType; ///< Bridge spec number.
38 /**
39 * Struct containing information about a single bridge type
41 struct BridgeSpec {
42 Year avail_year; ///< the year where it becomes available
43 byte min_length; ///< the minimum length (not counting start and end tile)
44 uint16 max_length; ///< the maximum length (not counting start and end tile)
45 uint16 price; ///< the price multiplier
46 uint16 speed; ///< maximum travel speed (1 unit = 1/1.6 mph = 1 km-ish/h)
47 SpriteID sprite; ///< the sprite which is used in the GUI
48 PaletteID pal; ///< the palette which is used in the GUI
49 StringID material; ///< the string that contains the bridge description
50 StringID transport_name[2]; ///< description of the bridge, when built for road or rail
51 PalSpriteID **sprite_table; ///< table of sprites for drawing the bridge
52 byte flags; ///< bit 0 set: disable drawing of far pillars.
55 extern BridgeSpec _bridge[MAX_BRIDGES];
57 Foundation GetBridgeFoundation(Slope tileh, Axis axis);
58 bool HasBridgeFlatRamp(Slope tileh, Axis axis);
60 /**
61 * Get the specification of a bridge type.
62 * @param i The type of bridge to get the specification for.
63 * @return The specification.
65 static inline const BridgeSpec *GetBridgeSpec(BridgeType i)
67 assert(i < lengthof(_bridge));
68 return &_bridge[i];
71 void DrawBridgeMiddle(const TileInfo *ti);
73 CommandCost CheckBridgeAvailability(BridgeType bridge_type, uint bridge_len, DoCommandFlag flags = DC_NONE);
74 int CalcBridgeLenCostFactor(int x);
76 void ResetBridges();
78 #endif /* BRIDGE_H */