OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

bridge.h
Go to the documentation of this file.
1 /* $Id: bridge.h 22413 2011-05-02 20:59:54Z rubidium $ */
2
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 */
9
12 #ifndef BRIDGE_H
13 #define BRIDGE_H
14
15 #include "gfx_type.h"
16 #include "tile_cmd.h"
17
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,
32 };
33
34 DECLARE_POSTFIX_INCREMENT(BridgePieces)
35
36 static const uint MAX_BRIDGES = 13;
37
38 typedef uint BridgeType;
39
43 struct BridgeSpec {
44 Year avail_year;
45 byte min_length;
46 uint16 max_length;
47 uint16 price;
48 uint16 speed;
49 SpriteID sprite;
50 PaletteID pal;
51 StringID material;
52 StringID transport_name[2];
53 PalSpriteID **sprite_table;
54 byte flags;
55 };
56
57 extern BridgeSpec _bridge[MAX_BRIDGES];
58
59 Foundation GetBridgeFoundation(Slope tileh, Axis axis);
60 bool HasBridgeFlatRamp(Slope tileh, Axis axis);
61
67 static inline const BridgeSpec *GetBridgeSpec(BridgeType i)
68 {
69 assert(i < lengthof(_bridge));
70 return &_bridge[i];
71 }
72
73 void DrawBridgeMiddle(const TileInfo *ti);
74
75 CommandCost CheckBridgeAvailability(BridgeType bridge_type, uint bridge_len, DoCommandFlag flags = DC_NONE);
76 int CalcBridgeLenCostFactor(int x);
77
78 void ResetBridges();
79
80 #endif /* BRIDGE_H */