OpenTTD Source: src/direction_type.h Source File

OpenTTD Source 12.0-beta1

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 <http://www.gnu.org/licenses/>.
6 */
7
10 #ifndef DIRECTION_TYPE_H
11 #define DIRECTION_TYPE_H
12
13 #include "core/enum_type.hpp"
14
24 enum Direction : byte {
25 DIR_BEGIN = 0,
26 DIR_N = 0,
27 DIR_NE = 1,
28 DIR_E = 2,
29 DIR_SE = 3,
30 DIR_S = 4,
31 DIR_SW = 5,
32 DIR_W = 6,
33 DIR_NW = 7,
34 DIR_END,
35 INVALID_DIR = 0xFF,
36 };
37
39 DECLARE_POSTFIX_INCREMENT(Direction)
40
41
42 template <> struct EnumPropsT<Direction> : MakeEnumPropsT<Direction, byte, DIR_BEGIN, DIR_END, INVALID_DIR, 3> {};
43
44
62 enum DirDiff {
63 DIRDIFF_SAME = 0,
64 DIRDIFF_45RIGHT = 1,
65 DIRDIFF_90RIGHT = 2,
66 DIRDIFF_REVERSE = 4,
67 DIRDIFF_90LEFT = 6,
68 DIRDIFF_45LEFT = 7,
69 };
70
71
77 enum DiagDirection : byte {
78 DIAGDIR_BEGIN = 0,
79 DIAGDIR_NE = 0,
80 DIAGDIR_SE = 1,
81 DIAGDIR_SW = 2,
82 DIAGDIR_NW = 3,
83 DIAGDIR_END,
84 INVALID_DIAGDIR = 0xFF,
85 };
86
88 DECLARE_POSTFIX_INCREMENT(DiagDirection)
89
90
91 template <> struct EnumPropsT<DiagDirection> : MakeEnumPropsT<DiagDirection, byte, DIAGDIR_BEGIN, DIAGDIR_END, INVALID_DIAGDIR, 2> {};
92
93
104 enum DiagDirDiff {
105 DIAGDIRDIFF_SAME = 0,
106 DIAGDIRDIFF_90RIGHT = 1,
107 DIAGDIRDIFF_REVERSE = 2,
108 DIAGDIRDIFF_90LEFT = 3,
109 };
110
112 DECLARE_POSTFIX_INCREMENT(DiagDirDiff)
113
114
115
123 enum Axis {
124 AXIS_X = 0,
125 AXIS_Y = 1,
126 AXIS_END,
127 INVALID_AXIS = 0xFF,
128 };
130 template <> struct EnumPropsT<Axis> : MakeEnumPropsT<Axis, byte, AXIS_X, AXIS_END, INVALID_AXIS, 1> {};
131
132 #endif /* DIRECTION_TYPE_H */
DIAGDIR_SE
@ DIAGDIR_SE
Southeast.
Definition: direction_type.h:80
DIR_SW
@ DIR_SW
Southwest.
Definition: direction_type.h:31
DIRDIFF_REVERSE
@ DIRDIFF_REVERSE
One direction is the opposite of the other one.
Definition: direction_type.h:66
Direction
Direction
Defines the 8 directions on the map.
Definition: direction_type.h:24
DIR_BEGIN
@ DIR_BEGIN
Used to iterate.
Definition: direction_type.h:25
DIRDIFF_45LEFT
@ DIRDIFF_45LEFT
Angle of 45 degrees left.
Definition: direction_type.h:68
DIR_SE
@ DIR_SE
Southeast.
Definition: direction_type.h:29
DIRDIFF_SAME
@ DIRDIFF_SAME
Both directions faces to the same direction.
Definition: direction_type.h:63
DiagDirDiff
DiagDirDiff
Enumeration for the difference between to DiagDirection.
Definition: direction_type.h:104
DIR_NW
@ DIR_NW
Northwest.
Definition: direction_type.h:33
DIAGDIR_END
@ DIAGDIR_END
Used for iterations.
Definition: direction_type.h:83
DIAGDIRDIFF_90LEFT
@ DIAGDIRDIFF_90LEFT
90 degrees left
Definition: direction_type.h:108
DIAGDIR_NW
@ DIAGDIR_NW
Northwest.
Definition: direction_type.h:82
DIAGDIRDIFF_SAME
@ DIAGDIRDIFF_SAME
Same directions.
Definition: direction_type.h:105
DIR_W
@ DIR_W
West.
Definition: direction_type.h:32
DIR_N
@ DIR_N
North.
Definition: direction_type.h:26
DECLARE_POSTFIX_INCREMENT
#define DECLARE_POSTFIX_INCREMENT(enum_type)
Some enums need to have allowed incrementing (i.e.
Definition: enum_type.hpp:14
DIAGDIR_SW
@ DIAGDIR_SW
Southwest.
Definition: direction_type.h:81
EnumPropsT
Informative template class exposing basic enumeration properties used by several other templates belo...
Definition: enum_type.hpp:48
AXIS_Y
@ AXIS_Y
The y axis.
Definition: direction_type.h:125
DIRDIFF_90LEFT
@ DIRDIFF_90LEFT
Angle of 90 degrees left.
Definition: direction_type.h:67
DIR_E
@ DIR_E
East.
Definition: direction_type.h:28
DIR_NE
@ DIR_NE
Northeast.
Definition: direction_type.h:27
DIAGDIRDIFF_90RIGHT
@ DIAGDIRDIFF_90RIGHT
90 degrees right
Definition: direction_type.h:106
DIR_S
@ DIR_S
South.
Definition: direction_type.h:30
INVALID_DIAGDIR
@ INVALID_DIAGDIR
Flag for an invalid DiagDirection.
Definition: direction_type.h:84
DirDiff
DirDiff
Enumeration for the difference between two directions.
Definition: direction_type.h:62
DiagDirection
DiagDirection
Enumeration for diagonal directions.
Definition: direction_type.h:77
DIAGDIRDIFF_REVERSE
@ DIAGDIRDIFF_REVERSE
Reverse directions.
Definition: direction_type.h:107
DIRDIFF_45RIGHT
@ DIRDIFF_45RIGHT
Angle of 45 degrees right.
Definition: direction_type.h:64
DIR_END
@ DIR_END
Used to iterate.
Definition: direction_type.h:34
DIAGDIR_BEGIN
@ DIAGDIR_BEGIN
Used for iterations.
Definition: direction_type.h:78
DIRDIFF_90RIGHT
@ DIRDIFF_90RIGHT
Angle of 90 degrees right.
Definition: direction_type.h:65
enum_type.hpp
MakeEnumPropsT
Helper template class that makes basic properties of given enumeration type visible from outsize.
Definition: enum_type.hpp:62
Axis
Axis
Allow incrementing of DiagDirDiff variables.
Definition: direction_type.h:123
AXIS_END
@ AXIS_END
Used for iterations.
Definition: direction_type.h:126
INVALID_AXIS
@ INVALID_AXIS
Flag for an invalid Axis.
Definition: direction_type.h:127
INVALID_DIR
@ INVALID_DIR
Flag for an invalid direction.
Definition: direction_type.h:35
DIAGDIR_NE
@ DIAGDIR_NE
Northeast, upper right on your monitor.
Definition: direction_type.h:79
AXIS_X
@ AXIS_X
The X axis.
Definition: direction_type.h:124