OpenTTD Source: src/bridge_type.h Source File

OpenTTD Source 15.0-RC2

bridge_type.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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#ifndef BRIDGE_TYPE_H
11#define BRIDGE_TYPE_H
12
13#include "core/enum_type.hpp"
14
15 using BridgeType = uint;
16
22 enum 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
33 DECLARE_INCREMENT_DECREMENT_OPERATORS(BridgePieces)
34
35
36static constexpr uint NUM_BRIDGE_MIDDLE_PIECES = NUM_BRIDGE_PIECES - 1;
37
39enum class BridgePillarFlag : uint8_t {
40 /* Corners are in the same order as Corner enum. */
41 CornerW = 0,
42 CornerS = 1,
43 CornerE = 2,
44 CornerN = 3,
45 /* Edges are in the same order as DiagDirection enum. */
46 EdgeNE = 4, //< Northeast edge is obstructed.
47 EdgeSE = 5, //< Southeast edge is obstructed.
48 EdgeSW = 6, //< Southwest edge is obstructed.
49 EdgeNW = 7, //< Northwest edge is obstructed.
50};
51using BridgePillarFlags = EnumBitSet<BridgePillarFlag, uint8_t>;
52
53static constexpr BridgePillarFlags BRIDGEPILLARFLAGS_ALL{
54 BridgePillarFlag::CornerW, BridgePillarFlag::CornerS, BridgePillarFlag::CornerE, BridgePillarFlag::CornerN,
55 BridgePillarFlag::EdgeNE, BridgePillarFlag::EdgeSE, BridgePillarFlag::EdgeSW, BridgePillarFlag::EdgeNW,
56};
57
59 struct BridgeableTileInfo {
60 uint8_t height = 0;
61 BridgePillarFlags disallowed_pillars = BRIDGEPILLARFLAGS_ALL;
62};
63
64#endif /* BRIDGE_TYPE_H */
NUM_BRIDGE_MIDDLE_PIECES
static constexpr uint NUM_BRIDGE_MIDDLE_PIECES
Number of bridge middles pieces.
Definition bridge_type.h:36
BridgePieces
BridgePieces
This enum is related to the definition of bridge pieces, which is used to determine the proper sprite...
Definition bridge_type.h:22
BridgePillarFlag
BridgePillarFlag
Obstructed bridge pillars information.
Definition bridge_type.h:39
BridgePillarFlag::CornerN
@ CornerN
North corner is obstructed.
BridgePillarFlag::CornerS
@ CornerS
South corner is obstructed.
BridgePillarFlag::CornerE
@ CornerE
East corner is obstructed.
BridgePillarFlag::CornerW
@ CornerW
West corner is obstructed.
BridgeType
uint BridgeType
Bridge spec number.
Definition bridge_type.h:15
EnumBitSet< BridgePillarFlag, uint8_t >
enum_type.hpp
Type (helpers) for enums.
DECLARE_INCREMENT_DECREMENT_OPERATORS
#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
BridgeableTileInfo
Information about a tile structure that may have a bridge above.
Definition bridge_type.h:59
BridgeableTileInfo::height
uint8_t height
Minimum height for a bridge above. 0 means a bridge is not allowed.
Definition bridge_type.h:60
BridgeableTileInfo::disallowed_pillars
BridgePillarFlags disallowed_pillars
Disallowed pillar flags for a bridge above.
Definition bridge_type.h:61