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/>.
8 /** @file direction_type.h Different types to 'show' directions. */
10 #ifndef DIRECTION_TYPE_H
11 #define DIRECTION_TYPE_H
13 #include "core/enum_type.hpp"
16 * Defines the 8 directions on the map.
18 * This enum defines 8 possible directions which are used for
19 * the vehicles in the game. The directions are aligned straight
20 * to the viewport, not to the map. So north points to the top of
21 * your viewport and not rotated by 45 degrees left or right to get
22 * a "north" used in you games.
24 enum Direction
: byte
{
25 DIR_BEGIN
= 0, ///< Used to iterate
27 DIR_NE
= 1, ///< Northeast
29 DIR_SE
= 3, ///< Southeast
31 DIR_SW
= 5, ///< Southwest
33 DIR_NW
= 7, ///< Northwest
34 DIR_END
, ///< Used to iterate
35 INVALID_DIR
= 0xFF, ///< Flag for an invalid direction
38 /** Allow incrementing of Direction variables */
39 DECLARE_POSTFIX_INCREMENT(Direction
)
42 * Enumeration for the difference between two directions.
44 * This enumeration is used to mark differences between
45 * two directions. If you get one direction you can align
46 * a second direction in 8 different ways. This enumeration
47 * only contains 6 of these 8 differences, but the remaining
48 * two can be calculated by adding to differences together.
49 * This also means you can add two differences together and
50 * get the difference you really want to get. The difference
51 * of 45 degrees left + the difference of 45 degrees right results in the
52 * difference of 0 degrees.
54 * @note To get this mentioned addition of direction you must use
55 * modulo DIR_END or use the #ChangeDirDiff(DirDiff, DirDiff) function.
56 * @see ChangeDirDiff(DirDiff, DirDiff)
59 DIRDIFF_SAME
= 0, ///< Both directions faces to the same direction
60 DIRDIFF_45RIGHT
= 1, ///< Angle of 45 degrees right
61 DIRDIFF_90RIGHT
= 2, ///< Angle of 90 degrees right
62 DIRDIFF_REVERSE
= 4, ///< One direction is the opposite of the other one
63 DIRDIFF_90LEFT
= 6, ///< Angle of 90 degrees left
64 DIRDIFF_45LEFT
= 7, ///< Angle of 45 degrees left
69 * Enumeration for diagonal directions.
71 * This enumeration is used for the 4 direction of the tile-edges.
73 enum DiagDirection
: byte
{
74 DIAGDIR_BEGIN
= 0, ///< Used for iterations
75 DIAGDIR_NE
= 0, ///< Northeast, upper right on your monitor
76 DIAGDIR_SE
= 1, ///< Southeast
77 DIAGDIR_SW
= 2, ///< Southwest
78 DIAGDIR_NW
= 3, ///< Northwest
79 DIAGDIR_END
, ///< Used for iterations
80 INVALID_DIAGDIR
= 0xFF, ///< Flag for an invalid DiagDirection
82 DECLARE_POSTFIX_INCREMENT(DiagDirection
)
83 DECLARE_ENUM_AS_ADDABLE(DiagDirection
)
86 * Enumeration for the difference between to DiagDirection.
88 * As the DiagDirection only contains 4 possible directions the
89 * difference between two of these directions can only be in 4 ways.
90 * As the DirDiff enumeration the values can be added together and
91 * you will get the resulting difference (use modulo DIAGDIR_END).
96 DIAGDIRDIFF_BEGIN
= 0, ///< Used for iterations
97 DIAGDIRDIFF_SAME
= 0, ///< Same directions
98 DIAGDIRDIFF_90RIGHT
= 1, ///< 90 degrees right
99 DIAGDIRDIFF_REVERSE
= 2, ///< Reverse directions
100 DIAGDIRDIFF_90LEFT
= 3, ///< 90 degrees left
101 DIAGDIRDIFF_END
, ///< Used for iterations
104 /** Allow incrementing of DiagDirDiff variables */
105 DECLARE_POSTFIX_INCREMENT(DiagDirDiff
)
109 * Enumeration for the two axis X and Y
111 * This enumeration represents the two axis X and Y in the game.
112 * The X axis is the one which goes align the north-west edge
113 * (and south-east edge). The Y axis must be so the one which goes
114 * align the north-east edge (and south-west) edge.
117 AXIS_X
= 0, ///< The X axis
118 AXIS_Y
= 1, ///< The y axis
119 AXIS_END
, ///< Used for iterations
120 INVALID_AXIS
= 0xFF, ///< Flag for an invalid Axis
122 DECLARE_ENUM_AS_ADDABLE(Axis
)
124 #endif /* DIRECTION_TYPE_H */