OpenTTD Source 20260531-master-g0e951f3528
direction_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
9
10#ifndef DIRECTION_TYPE_H
11#define DIRECTION_TYPE_H
12
13#include "core/enum_type.hpp"
14
24enum class Direction : uint8_t {
25 Begin = 0,
26 N = 0,
27 NE = 1,
28 E = 2,
29 SE = 3,
30 S = 4,
31 SW = 5,
32 W = 6,
33 NW = 7,
35 Invalid = 0xFF,
36};
37
40
42
45
50template <typename T>
52
70enum class DirDiff : uint8_t {
71 Same = 0,
72 Right45 = 1,
73 Right90 = 2,
74 Reverse = 4,
75 Left90 = 6,
76 Left45 = 7,
77};
78
79
85enum class DiagDirection : uint8_t {
86 Begin = 0,
87 NE = 0,
88 SE = 1,
89 SW = 2,
90 NW = 3,
92 Invalid = 0xFF,
93};
96
97
99
102
107template <typename T>
109
120enum class DiagDirDiff : uint8_t {
121 Same = 0,
124 Left90 = 3,
125};
126
135enum class Axis : uint8_t {
136 X = 0,
137 Y = 1,
139 Invalid = 0xFF,
140};
142
143
147template <typename T>
149
150#endif /* DIRECTION_TYPE_H */
Enum-as-bit-set wrapper.
DirDiff
Enumeration for the difference between two directions.
@ Left45
Angle of 45 degrees left.
@ Reverse
One direction is the opposite of the other one.
@ Left90
Angle of 90 degrees left.
@ Same
Both directions faces to the same direction.
@ Right45
Angle of 45 degrees right.
@ Right90
Angle of 90 degrees right.
EnumIndexArray< T, Axis, Axis::End > AxisIndexArray
Array with Axis as index.
EnumIndexArray< T, DiagDirection, DiagDirection::End > DiagDirectionIndexArray
Array with DiagDirection as index.
Direction
Defines the 8 directions on the map.
@ Begin
Used to iterate.
@ Invalid
Flag for an invalid direction.
@ SW
Southwest.
@ NW
Northwest.
@ NE
Northeast.
@ SE
Southeast.
DiagDirDiff
Enumeration for the difference between to DiagDirection.
EnumIndexArray< T, Direction, Direction::End > DirectionIndexArray
Array with Direction as index.
EnumBitSet< Direction, uint8_t > Directions
Allow incrementing of Direction variables.
static constexpr DiagDirections DIAGDIRECTIONS_ALL
All possible diagonal directions.
Axis
Enumeration for the two axis X and Y.
@ X
The X axis.
DiagDirection
Enumeration for diagonal directions.
@ SW
Southwest.
@ NW
Northwest.
@ NE
Northeast, upper right on your monitor.
@ SE
Southeast.
static constexpr Directions DIRECTIONS_ALL
All possible directions.
EnumBitSet< DiagDirection, uint8_t > DiagDirections
Bitset of DiagDirection elements.
#define Y
Climate toyland.
Definition engines.h:97
#define S
Climate sub-tropic.
Definition engines.h:95
Type (helpers) for enums.
#define DECLARE_ENUM_AS_ADDABLE(EnumType)
Operator that allows this enumeration to be added to any other enumeration.
#define DECLARE_INCREMENT_DECREMENT_OPERATORS(enum_type)
For some enums it is useful to have pre/post increment/decrement operators.
Definition enum_type.hpp:86
EnumClassIndexContainer< std::array< T, to_underlying(N)>, Index > EnumIndexArray
A typedef for EnumClassIndexContainer using std::array as the backing container type.
@ End
End marker.
Definition vehicle.cpp:2829