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/>.
10 /** @file direction_type.h Different types to 'show' directions. */
12 #ifndef DIRECTION_TYPE_H
13 #define DIRECTION_TYPE_H
15 #include "core/enum_type.hpp"
18 * Defines the 8 directions on the map.
20 * This enum defines 8 possible directions which are used for
21 * the vehicles in the game. The directions are aligned straight
22 * to the viewport, not to the map. So north points to the top of
23 * your viewport and not rotated by 45 degrees left or right to get
24 * a "north" used in you games.
27 DIR_BEGIN
= 0, ///< Used to iterate
29 DIR_NE
= 1, ///< Northeast
31 DIR_SE
= 3, ///< Southeast
33 DIR_SW
= 5, ///< Southwest
35 DIR_NW
= 7, ///< Northwest
36 DIR_END
, ///< Used to iterate
37 INVALID_DIR
= 0xFF, ///< Flag for an invalid direction
40 /** Allow incrementing of Direction variables */
41 DECLARE_POSTFIX_INCREMENT(Direction
)
43 /** Define basic enum properties */
44 template <> struct EnumPropsT
<Direction
> : MakeEnumPropsT
<Direction
, byte
, DIR_BEGIN
, DIR_END
, INVALID_DIR
, 3> {};
45 typedef TinyEnumT
<Direction
> DirectionByte
; ///< typedefing-enumification of Direction
49 * Enumeration for the difference between two directions.
51 * This enumeration is used to mark differences between
52 * two directions. If you get one direction you can align
53 * a second direction in 8 different ways. This enumeration
54 * only contains 6 of these 8 differences, but the remaining
55 * two can be calculated by adding to differences together.
56 * This also means you can add two differences together and
57 * get the difference you really want to get. The difference
58 * of 45 degrees left + the difference of 45 degrees right results in the
59 * difference of 0 degrees.
61 * @note To get this mentioned addition of direction you must use
62 * modulo DIR_END or use the #ChangeDirDiff(DirDiff, DirDiff) function.
63 * @see ChangeDirDiff(DirDiff, DirDiff)
66 DIRDIFF_SAME
= 0, ///< Both directions faces to the same direction
67 DIRDIFF_45RIGHT
= 1, ///< Angle of 45 degrees right
68 DIRDIFF_90RIGHT
= 2, ///< Angle of 90 degrees right
69 DIRDIFF_REVERSE
= 4, ///< One direction is the opposite of the other one
70 DIRDIFF_90LEFT
= 6, ///< Angle of 90 degrees left
71 DIRDIFF_45LEFT
= 7, ///< Angle of 45 degrees left
76 * Enumeration for diagonal directions.
78 * This enumeration is used for the 4 direction of the tile-edges.
81 DIAGDIR_BEGIN
= 0, ///< Used for iterations
82 DIAGDIR_NE
= 0, ///< Northeast, upper right on your monitor
83 DIAGDIR_SE
= 1, ///< Southeast
84 DIAGDIR_SW
= 2, ///< Southwest
85 DIAGDIR_NW
= 3, ///< Northwest
86 DIAGDIR_END
, ///< Used for iterations
87 INVALID_DIAGDIR
= 0xFF, ///< Flag for an invalid DiagDirection
90 /** Allow incrementing of DiagDirection variables */
91 DECLARE_POSTFIX_INCREMENT(DiagDirection
)
93 /** Define basic enum properties */
94 template <> struct EnumPropsT
<DiagDirection
> : MakeEnumPropsT
<DiagDirection
, byte
, DIAGDIR_BEGIN
, DIAGDIR_END
, INVALID_DIAGDIR
, 2> {};
95 typedef TinyEnumT
<DiagDirection
> DiagDirectionByte
; ///< typedefing-enumification of DiagDirection
99 * Enumeration for the difference between to DiagDirection.
101 * As the DiagDirection only contains 4 possible directions the
102 * difference between two of these directions can only be in 4 ways.
103 * As the DirDiff enumeration the values can be added together and
104 * you will get the resulting difference (use modulo DIAGDIR_END).
109 DIAGDIRDIFF_SAME
= 0, ///< Same directions
110 DIAGDIRDIFF_90RIGHT
= 1, ///< 90 degrees right
111 DIAGDIRDIFF_REVERSE
= 2, ///< Reverse directions
112 DIAGDIRDIFF_90LEFT
= 3, ///< 90 degrees left
115 /** Allow incrementing of DiagDirDiff variables */
116 DECLARE_POSTFIX_INCREMENT(DiagDirDiff
)
120 * Enumeration for the two axis X and Y
122 * This enumeration represents the two axis X and Y in the game.
123 * The X axis is the one which goes align the north-west edge
124 * (and south-east edge). The Y axis must be so the one which goes
125 * align the north-east edge (and south-west) edge.
128 AXIS_X
= 0, ///< The X axis
129 AXIS_Y
= 1, ///< The y axis
130 AXIS_END
, ///< Used for iterations
131 INVALID_AXIS
= 0xFF, ///< Flag for an invalid Axis
133 /** Helper information for extract tool. */
134 template <> struct EnumPropsT
<Axis
> : MakeEnumPropsT
<Axis
, byte
, AXIS_X
, AXIS_END
, INVALID_AXIS
, 1> {};
136 #endif /* DIRECTION_TYPE_H */