OpenTTD Source: src/road_type.h Source File

OpenTTD Source 15.0-RC2

road_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 ROAD_TYPE_H
11#define ROAD_TYPE_H
12
13#include "core/enum_type.hpp"
14
15typedef uint32_t RoadTypeLabel;
16
17static const RoadTypeLabel ROADTYPE_LABEL_ROAD = 'ROAD';
18static const RoadTypeLabel ROADTYPE_LABEL_TRAM = 'ELRL';
19
23 enum RoadType : uint8_t {
24 ROADTYPE_BEGIN = 0,
25 ROADTYPE_ROAD = 0,
26 ROADTYPE_TRAM = 1,
27 ROADTYPE_END = 63,
28 INVALID_ROADTYPE = 63,
29};
30 DECLARE_INCREMENT_DECREMENT_OPERATORS(RoadType)
31
32using RoadTypes = EnumBitSet<RoadType, uint64_t>;
33
37 enum RoadTramType : bool {
38 RTT_ROAD,
39 RTT_TRAM,
40};
41
42 enum RoadTramTypes : uint8_t {
43 RTTB_ROAD = 1 << RTT_ROAD,
44 RTTB_TRAM = 1 << RTT_TRAM,
45};
46 DECLARE_ENUM_AS_BIT_SET(RoadTramTypes)
47
48static const RoadTramType _roadtramtypes[] = { RTT_ROAD, RTT_TRAM };
49
56 enum RoadBits : uint8_t {
57 ROAD_NONE = 0U,
58 ROAD_NW = 1U,
59 ROAD_SW = 2U,
60 ROAD_SE = 4U,
61 ROAD_NE = 8U,
62 ROAD_X = ROAD_SW | ROAD_NE,
63 ROAD_Y = ROAD_NW | ROAD_SE,
64
65 ROAD_N = ROAD_NE | ROAD_NW,
66 ROAD_E = ROAD_NE | ROAD_SE,
67 ROAD_S = ROAD_SE | ROAD_SW,
68 ROAD_W = ROAD_NW | ROAD_SW,
69
70 ROAD_ALL = ROAD_X | ROAD_Y,
71
72 ROAD_END = ROAD_ALL + 1,
73};
74 DECLARE_ENUM_AS_BIT_SET(RoadBits)
75
76
77enum DisallowedRoadDirections : uint8_t {
78 DRD_NONE,
79 DRD_SOUTHBOUND,
80 DRD_NORTHBOUND,
81 DRD_BOTH,
82 DRD_END,
83};
84 DECLARE_ENUM_AS_BIT_SET(DisallowedRoadDirections)
85
86#endif /* ROAD_TYPE_H */
EnumBitSet< RoadType, uint64_t >
enum_type.hpp
Type (helpers) for enums.
DECLARE_ENUM_AS_BIT_SET
#define DECLARE_ENUM_AS_BIT_SET(enum_type)
Operators to allow to work with enum as with type safe bit set in C++.
Definition enum_type.hpp:119
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
RoadBits
RoadBits
Enumeration for the road parts on a tile.
Definition road_type.h:56
ROAD_SW
@ ROAD_SW
South-west part.
Definition road_type.h:59
ROAD_ALL
@ ROAD_ALL
Full 4-way crossing.
Definition road_type.h:70
ROAD_NONE
@ ROAD_NONE
No road-part is build.
Definition road_type.h:57
ROAD_E
@ ROAD_E
Road at the two eastern edges.
Definition road_type.h:66
ROAD_NE
@ ROAD_NE
North-east part.
Definition road_type.h:61
ROAD_N
@ ROAD_N
Road at the two northern edges.
Definition road_type.h:65
ROAD_SE
@ ROAD_SE
South-east part.
Definition road_type.h:60
ROAD_Y
@ ROAD_Y
Full road along the y-axis (north-west + south-east)
Definition road_type.h:63
ROAD_S
@ ROAD_S
Road at the two southern edges.
Definition road_type.h:67
ROAD_W
@ ROAD_W
Road at the two western edges.
Definition road_type.h:68
ROAD_NW
@ ROAD_NW
North-west part.
Definition road_type.h:58
ROAD_X
@ ROAD_X
Full road along the x-axis (south-west + north-east)
Definition road_type.h:62
ROAD_END
@ ROAD_END
Out-of-range roadbits, used for iterations.
Definition road_type.h:72
RoadTramType
RoadTramType
The different types of road type.
Definition road_type.h:37
RTT_ROAD
@ RTT_ROAD
Road road type.
Definition road_type.h:38
RTT_TRAM
@ RTT_TRAM
Tram road type.
Definition road_type.h:39
RoadTramTypes
RoadTramTypes
Definition road_type.h:42
RTTB_ROAD
@ RTTB_ROAD
Road road type bit.
Definition road_type.h:43
RTTB_TRAM
@ RTTB_TRAM
Tram road type bit.
Definition road_type.h:44
RoadType
RoadType
The different roadtypes we support.
Definition road_type.h:23
INVALID_ROADTYPE
@ INVALID_ROADTYPE
flag for invalid roadtype
Definition road_type.h:28
ROADTYPE_TRAM
@ ROADTYPE_TRAM
Trams.
Definition road_type.h:26
ROADTYPE_ROAD
@ ROADTYPE_ROAD
Basic road type.
Definition road_type.h:25
ROADTYPE_END
@ ROADTYPE_END
Used for iterations.
Definition road_type.h:27
ROADTYPE_BEGIN
@ ROADTYPE_BEGIN
Used for iterations.
Definition road_type.h:24
DisallowedRoadDirections
DisallowedRoadDirections
Which directions are disallowed ?
Definition road_type.h:77
DRD_NORTHBOUND
@ DRD_NORTHBOUND
All northbound traffic is disallowed.
Definition road_type.h:80
DRD_END
@ DRD_END
Sentinel.
Definition road_type.h:82
DRD_BOTH
@ DRD_BOTH
All directions are disallowed.
Definition road_type.h:81
DRD_NONE
@ DRD_NONE
None of the directions are disallowed.
Definition road_type.h:78
DRD_SOUTHBOUND
@ DRD_SOUTHBOUND
All southbound traffic is disallowed.
Definition road_type.h:79