OpenTTD

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 */
ResetBridges
void ResetBridges()
Reset the data been eventually changed by the grf loaded.
Definition: tunnelbridge_cmd.cpp:83
PaletteID
uint32 PaletteID
The number of the palette.
Definition: gfx_type.h:20
BridgeSpec::avail_year
Year avail_year
the year where it becomes available
Definition: bridge.h:44
CalcBridgeLenCostFactor
int CalcBridgeLenCostFactor(int x)
Calculate the price factor for building a long bridge.
Definition: tunnelbridge_cmd.cpp:105
TileInfo
Tile information, used while rendering the tile.
Definition: tile_cmd.h:44
BridgeSpec::sprite_table
PalSpriteID ** sprite_table
table of sprites for drawing the bridge
Definition: bridge.h:53
BridgeSpec::flags
byte flags
bit 0 set: disable drawing of far pillars.
Definition: bridge.h:54
DC_NONE
no flag is set
Definition: command_type.h:341
PalSpriteID
Combination of a palette sprite and a &#39;real&#39; sprite.
Definition: gfx_type.h:24
BridgeSpec::speed
uint16 speed
maximum travel speed (1 unit = 1/1.6 mph = 1 km-ish/h)
Definition: bridge.h:48
CommandCost
Common return value for all commands.
Definition: command_type.h:25
Year
int32 Year
Type for the year, note: 0 based, i.e. starts at the year 0.
Definition: date_type.h:20
BridgeSpec
Struct containing information about a single bridge type.
Definition: bridge.h:43
_bridge
BridgeSpec _bridge[MAX_BRIDGES]
The specification of all bridges.
Definition: tunnelbridge_cmd.cpp:49
Foundation
Foundation
Enumeration for Foundations.
Definition: slope_type.h:95
GetBridgeFoundation
Foundation GetBridgeFoundation(Slope tileh, Axis axis)
Get the foundation for a bridge.
Definition: tunnelbridge_cmd.cpp:126
DoCommandFlag
DoCommandFlag
List of flags for a command.
Definition: command_type.h:340
GetBridgeSpec
static const BridgeSpec * GetBridgeSpec(BridgeType i)
Get the specification of a bridge type.
Definition: bridge.h:67
BridgeSpec::sprite
SpriteID sprite
the sprite which is used in the GUI
Definition: bridge.h:49
BridgeSpec::min_length
byte min_length
the minimum length (not counting start and end tile)
Definition: bridge.h:45
BridgeSpec::pal
PaletteID pal
the palette which is used in the GUI
Definition: bridge.h:50
BridgePieces
BridgePieces
This enum is related to the definition of bridge pieces, which is used to determine the proper sprite...
Definition: bridge.h:23
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: depend.cpp:42
CheckBridgeAvailability
CommandCost CheckBridgeAvailability(BridgeType bridge_type, uint bridge_len, DoCommandFlag flags=DC_NONE)
Is a bridge of the specified type and length available?
Definition: tunnelbridge_cmd.cpp:209
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:18
BridgeSpec::price
uint16 price
the price multiplier
Definition: bridge.h:47
BridgeSpec::material
StringID material
the string that contains the bridge description
Definition: bridge.h:51
HasBridgeFlatRamp
bool HasBridgeFlatRamp(Slope tileh, Axis axis)
Determines if the track on a bridge ramp is flat or goes up/down.
Definition: tunnelbridge_cmd.cpp:142
BridgeSpec::max_length
uint16 max_length
the maximum length (not counting start and end tile)
Definition: bridge.h:46
SpriteID
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition: gfx_type.h:19
MAX_BRIDGES
static const uint MAX_BRIDGES
Maximal number of available bridge specs.
Definition: bridge.h:36
Slope
Slope
Enumeration for the slope-type.
Definition: slope_type.h:50
BridgeType
uint BridgeType
Bridge spec number.
Definition: bridge.h:38
DECLARE_POSTFIX_INCREMENT
#define DECLARE_POSTFIX_INCREMENT(type)
Some enums need to have allowed incrementing (i.e.
Definition: enum_type.hpp:16
DrawBridgeMiddle
void DrawBridgeMiddle(const TileInfo *ti)
Draw the middle bits of a bridge.
Definition: tunnelbridge_cmd.cpp:1391
Axis
Axis
Allow incrementing of DiagDirDiff variables.
Definition: direction_type.h:127
gfx_type.h
Types related to the graphics and/or input devices.
tile_cmd.h
Generic &#39;commands&#39; that can be performed on all tiles.