OpenTTD Source 20260621-master-g720d10536d
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
43
48template <typename T>
50
68enum class DirDiff : uint8_t {
69 Same = 0,
70 Right45 = 1,
71 Right90 = 2,
72 Reverse = 4,
73 Left90 = 6,
74 Left45 = 7,
75};
76
77
83enum class DiagDirection : uint8_t {
84 Begin = 0,
85 NE = 0,
86 SE = 1,
87 SW = 2,
88 NW = 3,
90 Invalid = 0xFF,
91};
94
95
97
100
105template <typename T>
107
118enum class DiagDirDiff : uint8_t {
119 Same = 0,
122 Left90 = 3,
123};
124
133enum class Axis : uint8_t {
134 X = 0,
135 Y = 1,
137 Invalid = 0xFF,
138};
140
141
145template <typename T>
147
148#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.
@ End
Used to iterate.
@ 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
Bitset of Direction elements.
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.