Fix #9521: Don't load at just removed docks that were part of a multi-dock station...
[openttd-github.git] / src / direction_type.h
blob55e430e8cd324c0a6abb12332d69daac9ba5243b
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 */
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"
15 /**
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
26 DIR_N = 0, ///< North
27 DIR_NE = 1, ///< Northeast
28 DIR_E = 2, ///< East
29 DIR_SE = 3, ///< Southeast
30 DIR_S = 4, ///< South
31 DIR_SW = 5, ///< Southwest
32 DIR_W = 6, ///< West
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)
41 /** Define basic enum properties */
42 template <> struct EnumPropsT<Direction> : MakeEnumPropsT<Direction, byte, DIR_BEGIN, DIR_END, INVALID_DIR, 3> {};
45 /**
46 * Enumeration for the difference between two directions.
48 * This enumeration is used to mark differences between
49 * two directions. If you get one direction you can align
50 * a second direction in 8 different ways. This enumeration
51 * only contains 6 of these 8 differences, but the remaining
52 * two can be calculated by adding to differences together.
53 * This also means you can add two differences together and
54 * get the difference you really want to get. The difference
55 * of 45 degrees left + the difference of 45 degrees right results in the
56 * difference of 0 degrees.
58 * @note To get this mentioned addition of direction you must use
59 * modulo DIR_END or use the #ChangeDirDiff(DirDiff, DirDiff) function.
60 * @see ChangeDirDiff(DirDiff, DirDiff)
62 enum DirDiff {
63 DIRDIFF_SAME = 0, ///< Both directions faces to the same direction
64 DIRDIFF_45RIGHT = 1, ///< Angle of 45 degrees right
65 DIRDIFF_90RIGHT = 2, ///< Angle of 90 degrees right
66 DIRDIFF_REVERSE = 4, ///< One direction is the opposite of the other one
67 DIRDIFF_90LEFT = 6, ///< Angle of 90 degrees left
68 DIRDIFF_45LEFT = 7, ///< Angle of 45 degrees left
72 /**
73 * Enumeration for diagonal directions.
75 * This enumeration is used for the 4 direction of the tile-edges.
77 enum DiagDirection : byte {
78 DIAGDIR_BEGIN = 0, ///< Used for iterations
79 DIAGDIR_NE = 0, ///< Northeast, upper right on your monitor
80 DIAGDIR_SE = 1, ///< Southeast
81 DIAGDIR_SW = 2, ///< Southwest
82 DIAGDIR_NW = 3, ///< Northwest
83 DIAGDIR_END, ///< Used for iterations
84 INVALID_DIAGDIR = 0xFF, ///< Flag for an invalid DiagDirection
87 /** Allow incrementing of DiagDirection variables */
88 DECLARE_POSTFIX_INCREMENT(DiagDirection)
90 /** Define basic enum properties */
91 template <> struct EnumPropsT<DiagDirection> : MakeEnumPropsT<DiagDirection, byte, DIAGDIR_BEGIN, DIAGDIR_END, INVALID_DIAGDIR, 2> {};
94 /**
95 * Enumeration for the difference between to DiagDirection.
97 * As the DiagDirection only contains 4 possible directions the
98 * difference between two of these directions can only be in 4 ways.
99 * As the DirDiff enumeration the values can be added together and
100 * you will get the resulting difference (use modulo DIAGDIR_END).
102 * @see DirDiff
104 enum DiagDirDiff {
105 DIAGDIRDIFF_SAME = 0, ///< Same directions
106 DIAGDIRDIFF_90RIGHT = 1, ///< 90 degrees right
107 DIAGDIRDIFF_REVERSE = 2, ///< Reverse directions
108 DIAGDIRDIFF_90LEFT = 3, ///< 90 degrees left
111 /** Allow incrementing of DiagDirDiff variables */
112 DECLARE_POSTFIX_INCREMENT(DiagDirDiff)
116 * Enumeration for the two axis X and Y
118 * This enumeration represents the two axis X and Y in the game.
119 * The X axis is the one which goes align the north-west edge
120 * (and south-east edge). The Y axis must be so the one which goes
121 * align the north-east edge (and south-west) edge.
123 enum Axis {
124 AXIS_X = 0, ///< The X axis
125 AXIS_Y = 1, ///< The y axis
126 AXIS_END, ///< Used for iterations
127 INVALID_AXIS = 0xFF, ///< Flag for an invalid Axis
129 /** Helper information for extract tool. */
130 template <> struct EnumPropsT<Axis> : MakeEnumPropsT<Axis, byte, AXIS_X, AXIS_END, INVALID_AXIS, 1> {};
132 #endif /* DIRECTION_TYPE_H */