OpenTTD Source: src/bridge.h Source File

OpenTTD Source 14.0-beta1

bridge.h
Go to the documentation of this file.
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 */
7
10 #ifndef BRIDGE_H
11 #define BRIDGE_H
12
13 #include "gfx_type.h"
14 #include "tile_cmd.h"
15 #include "timer/timer_game_calendar.h"
16
22 enum BridgePieces {
23 BRIDGE_PIECE_NORTH = 0,
24 BRIDGE_PIECE_SOUTH,
25 BRIDGE_PIECE_INNER_NORTH,
26 BRIDGE_PIECE_INNER_SOUTH,
27 BRIDGE_PIECE_MIDDLE_ODD,
28 BRIDGE_PIECE_MIDDLE_EVEN,
29 BRIDGE_PIECE_HEAD,
30 BRIDGE_PIECE_INVALID,
31 };
32
33 DECLARE_POSTFIX_INCREMENT(BridgePieces)
34
35 static const uint MAX_BRIDGES = 13;
36
37 typedef uint BridgeType;
38
42 struct BridgeSpec {
43 TimerGameCalendar::Year avail_year;
44 byte min_length;
45 uint16_t max_length;
46 uint16_t price;
47 uint16_t speed;
48 SpriteID sprite;
49 PaletteID pal;
50 StringID material;
51 StringID transport_name[2];
52 PalSpriteID **sprite_table;
53 byte flags;
54 };
55
56 extern BridgeSpec _bridge[MAX_BRIDGES];
57
58 Foundation GetBridgeFoundation(Slope tileh, Axis axis);
59 bool HasBridgeFlatRamp(Slope tileh, Axis axis);
60
66 inline const BridgeSpec *GetBridgeSpec(BridgeType i)
67 {
68 assert(i < lengthof(_bridge));
69 return &_bridge[i];
70 }
71
72 void DrawBridgeMiddle(const TileInfo *ti);
73
74 CommandCost CheckBridgeAvailability(BridgeType bridge_type, uint bridge_len, DoCommandFlag flags = DC_NONE);
75 int CalcBridgeLenCostFactor(int x);
76
77 void ResetBridges();
78
79 #endif /* BRIDGE_H */
CalcBridgeLenCostFactor
int CalcBridgeLenCostFactor(int x)
Calculate the price factor for building a long bridge.
Definition: tunnelbridge_cmd.cpp:108
GetBridgeFoundation
Foundation GetBridgeFoundation(Slope tileh, Axis axis)
Get the foundation for a bridge.
Definition: tunnelbridge_cmd.cpp:129
BridgeSpec::flags
byte flags
bit 0 set: disable drawing of far pillars.
Definition: bridge.h:53
TileInfo
Tile information, used while rendering the tile.
Definition: tile_cmd.h:43
timer_game_calendar.h
Axis
Axis
Allow incrementing of DiagDirDiff variables.
Definition: direction_type.h:116
StringID
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
BridgeSpec::sprite_table
PalSpriteID ** sprite_table
table of sprites for drawing the bridge
Definition: bridge.h:52
_bridge
BridgeSpec _bridge[MAX_BRIDGES]
The specification of all bridges.
Definition: tunnelbridge_cmd.cpp:52
DrawBridgeMiddle
void DrawBridgeMiddle(const TileInfo *ti)
Draw the middle bits of a bridge.
Definition: tunnelbridge_cmd.cpp:1544
StrongType::Typedef
Templated helper to make a type-safe 'typedef' representing a single POD value.
Definition: strong_typedef_type.hpp:150
PaletteID
uint32_t PaletteID
The number of the palette.
Definition: gfx_type.h:18
DoCommandFlag
DoCommandFlag
List of flags for a command.
Definition: command_type.h:369
Foundation
Foundation
Enumeration for Foundations.
Definition: slope_type.h:93
tile_cmd.h
BridgeSpec
Struct containing information about a single bridge type.
Definition: bridge.h:42
DECLARE_POSTFIX_INCREMENT
#define DECLARE_POSTFIX_INCREMENT(enum_type)
Some enums need to have allowed incrementing (i.e.
Definition: enum_type.hpp:14
Slope
Slope
Enumeration for the slope-type.
Definition: slope_type.h:48
BridgeSpec::sprite
SpriteID sprite
the sprite which is used in the GUI
Definition: bridge.h:48
CommandCost
Common return value for all commands.
Definition: command_type.h:23
GetBridgeSpec
const BridgeSpec * GetBridgeSpec(BridgeType i)
Get the specification of a bridge type.
Definition: bridge.h:66
MAX_BRIDGES
static const uint MAX_BRIDGES
Maximal number of available bridge specs.
Definition: bridge.h:35
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:200
BridgeSpec::pal
PaletteID pal
the palette which is used in the GUI
Definition: bridge.h:49
BridgeType
uint BridgeType
Bridge spec number.
Definition: bridge.h:37
SpriteID
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition: gfx_type.h:17
BridgeSpec::min_length
byte min_length
the minimum length (not counting start and end tile)
Definition: bridge.h:44
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:145
PalSpriteID
Combination of a palette sprite and a 'real' sprite.
Definition: gfx_type.h:22
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:300
BridgeSpec::avail_year
TimerGameCalendar::Year avail_year
the year where it becomes available
Definition: bridge.h:43
BridgeSpec::material
StringID material
the string that contains the bridge description
Definition: bridge.h:50
DC_NONE
@ DC_NONE
no flag is set
Definition: command_type.h:370
ResetBridges
void ResetBridges()
Reset the data been eventually changed by the grf loaded.
Definition: tunnelbridge_cmd.cpp:86
gfx_type.h
BridgePieces
BridgePieces
This enum is related to the definition of bridge pieces, which is used to determine the proper sprite...
Definition: bridge.h:22