OpenTTD Source 20250312-master-gcdcc6b491d
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"
16
22enum BridgePieces : uint8_t {
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 NUM_BRIDGE_PIECES,
31};
32
34
35static const uint MAX_BRIDGES = 13;
36constexpr uint SPRITES_PER_BRIDGE_PIECE = 32;
37
38typedef uint BridgeType;
39
43struct BridgeSpec {
45 uint8_t min_length;
46 uint16_t max_length;
47 uint16_t price;
48 uint16_t speed;
52 StringID transport_name[2];
53 std::vector<std::vector<PalSpriteID>> sprite_table;
54 uint8_t flags;
55};
56
58
60bool HasBridgeFlatRamp(Slope tileh, Axis axis);
61
68{
69 assert(i < lengthof(_bridge));
70 return &_bridge[i];
71}
72
73void DrawBridgeMiddle(const TileInfo *ti);
74
75CommandCost CheckBridgeAvailability(BridgeType bridge_type, uint bridge_len, DoCommandFlags flags = {});
77
78void ResetBridges();
79
80#endif /* BRIDGE_H */
int CalcBridgeLenCostFactor(int x)
Calculate the price factor for building a long bridge.
const BridgeSpec * GetBridgeSpec(BridgeType i)
Get the specification of a bridge type.
Definition bridge.h:67
void DrawBridgeMiddle(const TileInfo *ti)
Draw the middle bits of a bridge.
Foundation GetBridgeFoundation(Slope tileh, Axis axis)
Get the foundation for a bridge.
constexpr uint SPRITES_PER_BRIDGE_PIECE
Number of sprites there are per bridge piece.
Definition bridge.h:36
uint BridgeType
Bridge spec number.
Definition bridge.h:38
static const uint MAX_BRIDGES
Maximal number of available bridge specs.
Definition bridge.h:35
BridgePieces
This enum is related to the definition of bridge pieces, which is used to determine the proper sprite...
Definition bridge.h:22
bool HasBridgeFlatRamp(Slope tileh, Axis axis)
Determines if the track on a bridge ramp is flat or goes up/down.
CommandCost CheckBridgeAvailability(BridgeType bridge_type, uint bridge_len, DoCommandFlags flags={})
Is a bridge of the specified type and length available?
BridgeSpec _bridge[MAX_BRIDGES]
The specification of all bridges.
void ResetBridges()
Reset the data been eventually changed by the grf loaded.
Common return value for all commands.
Enum-as-bit-set wrapper.
Axis
Allow incrementing of DiagDirDiff variables.
#define DECLARE_INCREMENT_DECREMENT_OPERATORS(enum_type)
For some enums it is useful to have pre/post increment/decrement operators.
Definition enum_type.hpp:63
Types related to the graphics and/or input devices.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition gfx_type.h:17
uint32_t PaletteID
The number of the palette.
Definition gfx_type.h:18
Slope
Enumeration for the slope-type.
Definition slope_type.h:48
Foundation
Enumeration for Foundations.
Definition slope_type.h:93
#define lengthof(array)
Return the length of an fixed size array.
Definition stdafx.h:277
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Struct containing information about a single bridge type.
Definition bridge.h:43
uint16_t price
the price multiplier
Definition bridge.h:47
PaletteID pal
the palette which is used in the GUI
Definition bridge.h:50
uint8_t min_length
the minimum length (not counting start and end tile)
Definition bridge.h:45
StringID material
the string that contains the bridge description
Definition bridge.h:51
std::vector< std::vector< PalSpriteID > > sprite_table
table of sprites for drawing the bridge
Definition bridge.h:53
TimerGameCalendar::Year avail_year
the year where it becomes available
Definition bridge.h:44
SpriteID sprite
the sprite which is used in the GUI
Definition bridge.h:49
uint8_t flags
bit 0 set: disable drawing of far pillars.
Definition bridge.h:54
uint16_t speed
maximum travel speed (1 unit = 1/1.6 mph = 1 km-ish/h)
Definition bridge.h:48
uint16_t max_length
the maximum length (not counting start and end tile)
Definition bridge.h:46
Templated helper to make a type-safe 'typedef' representing a single POD value.
Tile information, used while rendering the tile.
Definition tile_cmd.h:43
Generic 'commands' that can be performed on all tiles.
Definition of the game-calendar-timer.