OpenTTD

direction_type.h
Go to the documentation of this file.
1 /* $Id: direction_type.h 24900 2013-01-08 22:46:42Z planetmaker $ */
2
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
8 */
9
12 #ifndef DIRECTION_TYPE_H
13 #define DIRECTION_TYPE_H
14
15 #include "core/enum_type.hpp"
16
26 enum Direction {
27 DIR_BEGIN = 0,
28 DIR_N = 0,
29 DIR_NE = 1,
30 DIR_E = 2,
31 DIR_SE = 3,
32 DIR_S = 4,
33 DIR_SW = 5,
34 DIR_W = 6,
35 DIR_NW = 7,
36 DIR_END,
37 INVALID_DIR = 0xFF,
38 };
39
41 DECLARE_POSTFIX_INCREMENT(Direction)
42
43
44 template <> struct EnumPropsT<Direction> : MakeEnumPropsT<Direction, byte, DIR_BEGIN, DIR_END, INVALID_DIR, 3> {};
45 typedef TinyEnumT<Direction> DirectionByte;
46
47
65 enum DirDiff {
66 DIRDIFF_SAME = 0,
67 DIRDIFF_45RIGHT = 1,
68 DIRDIFF_90RIGHT = 2,
69 DIRDIFF_REVERSE = 4,
70 DIRDIFF_90LEFT = 6,
71 DIRDIFF_45LEFT = 7,
72 };
73
74
80 enum DiagDirection {
81 DIAGDIR_BEGIN = 0,
82 DIAGDIR_NE = 0,
83 DIAGDIR_SE = 1,
84 DIAGDIR_SW = 2,
85 DIAGDIR_NW = 3,
86 DIAGDIR_END,
87 INVALID_DIAGDIR = 0xFF,
88 };
89
91 DECLARE_POSTFIX_INCREMENT(DiagDirection)
92
93
94 template <> struct EnumPropsT<DiagDirection> : MakeEnumPropsT<DiagDirection, byte, DIAGDIR_BEGIN, DIAGDIR_END, INVALID_DIAGDIR, 2> {};
95 typedef TinyEnumT<DiagDirection> DiagDirectionByte;
96
97
108 enum DiagDirDiff {
109 DIAGDIRDIFF_SAME = 0,
110 DIAGDIRDIFF_90RIGHT = 1,
111 DIAGDIRDIFF_REVERSE = 2,
112 DIAGDIRDIFF_90LEFT = 3,
113 };
114
116 DECLARE_POSTFIX_INCREMENT(DiagDirDiff)
117
118
119
127 enum Axis {
128 AXIS_X = 0,
129 AXIS_Y = 1,
130 AXIS_END,
131 INVALID_AXIS = 0xFF,
132 };
134 template <> struct EnumPropsT<Axis> : MakeEnumPropsT<Axis, byte, AXIS_X, AXIS_END, INVALID_AXIS, 1> {};
135
136 #endif /* DIRECTION_TYPE_H */
INVALID_DIR
Flag for an invalid direction.
Definition: direction_type.h:37
MakeEnumPropsT
Helper template class that makes basic properties of given enumeration type visible from outsize...
Definition: enum_type.hpp:66
DiagDirectionByte
TinyEnumT< DiagDirection > DiagDirectionByte
typedefing-enumification of DiagDirection
Definition: direction_type.h:95
DIR_E
East.
Definition: direction_type.h:30
INVALID_DIAGDIR
Flag for an invalid DiagDirection.
Definition: direction_type.h:87
DIRDIFF_45LEFT
Angle of 45 degrees left.
Definition: direction_type.h:71
DIRDIFF_90RIGHT
Angle of 90 degrees right.
Definition: direction_type.h:68
DIRDIFF_SAME
Both directions faces to the same direction.
Definition: direction_type.h:66
DIAGDIR_NE
Northeast, upper right on your monitor.
Definition: direction_type.h:82
DIAGDIR_BEGIN
Used for iterations.
Definition: direction_type.h:81
enum_type.hpp
Type (helpers) for enums.
Direction
Direction
Defines the 8 directions on the map.
Definition: direction_type.h:26
DIR_SE
Southeast.
Definition: direction_type.h:31
DIR_NE
Northeast.
Definition: direction_type.h:29
DIRDIFF_45RIGHT
Angle of 45 degrees right.
Definition: direction_type.h:67
DIAGDIRDIFF_90RIGHT
90 degrees right
Definition: direction_type.h:110
DIAGDIRDIFF_REVERSE
Reverse directions.
Definition: direction_type.h:111
AXIS_Y
The y axis.
Definition: direction_type.h:129
DIR_W
West.
Definition: direction_type.h:34
DIR_N
North.
Definition: direction_type.h:28
DIAGDIR_SE
Southeast.
Definition: direction_type.h:83
DIAGDIR_SW
Southwest.
Definition: direction_type.h:84
EnumPropsT
Informative template class exposing basic enumeration properties used by several other templates belo...
Definition: enum_type.hpp:52
DirDiff
DirDiff
Enumeration for the difference between two directions.
Definition: direction_type.h:65
AXIS_END
Used for iterations.
Definition: direction_type.h:130
DIAGDIR_END
Used for iterations.
Definition: direction_type.h:86
DIAGDIR_NW
Northwest.
Definition: direction_type.h:85
DiagDirDiff
DiagDirDiff
Enumeration for the difference between to DiagDirection.
Definition: direction_type.h:108
DiagDirection
DiagDirection
Enumeration for diagonal directions.
Definition: direction_type.h:80
TinyEnumT< Direction >
DIAGDIRDIFF_SAME
Same directions.
Definition: direction_type.h:109
DIR_END
Used to iterate.
Definition: direction_type.h:36
AXIS_X
The X axis.
Definition: direction_type.h:128
DIRDIFF_90LEFT
Angle of 90 degrees left.
Definition: direction_type.h:70
DirectionByte
TinyEnumT< Direction > DirectionByte
typedefing-enumification of Direction
Definition: direction_type.h:45
DIR_NW
Northwest.
Definition: direction_type.h:35
DIR_S
South.
Definition: direction_type.h:32
DIR_BEGIN
Used to iterate.
Definition: direction_type.h:27
DIRDIFF_REVERSE
One direction is the opposite of the other one.
Definition: direction_type.h:69
DECLARE_POSTFIX_INCREMENT
#define DECLARE_POSTFIX_INCREMENT(type)
Some enums need to have allowed incrementing (i.e.
Definition: enum_type.hpp:16
INVALID_AXIS
Flag for an invalid Axis.
Definition: direction_type.h:131
DIAGDIRDIFF_90LEFT
90 degrees left
Definition: direction_type.h:112
DIR_SW
Southwest.
Definition: direction_type.h:33
Axis
Axis
Allow incrementing of DiagDirDiff variables.
Definition: direction_type.h:127