Fix #10490: Allow ships to exit depots if another is not moving at the exit point...
[openttd-github.git] / src / track_type.h
blobb93fe97d6045726d14371ccc395b1cbe0b25f101
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 track_type.h All types related to tracks */
10 #ifndef TRACK_TYPE_H
11 #define TRACK_TYPE_H
13 #include "core/enum_type.hpp"
15 /**
16 * These are used to specify a single track.
17 * Can be translated to a trackbit with TrackToTrackbit
19 enum Track : byte {
20 TRACK_BEGIN = 0, ///< Used for iterations
21 TRACK_X = 0, ///< Track along the x-axis (north-east to south-west)
22 TRACK_Y = 1, ///< Track along the y-axis (north-west to south-east)
23 TRACK_UPPER = 2, ///< Track in the upper corner of the tile (north)
24 TRACK_LOWER = 3, ///< Track in the lower corner of the tile (south)
25 TRACK_LEFT = 4, ///< Track in the left corner of the tile (west)
26 TRACK_RIGHT = 5, ///< Track in the right corner of the tile (east)
27 TRACK_END, ///< Used for iterations
28 INVALID_TRACK = 0xFF, ///< Flag for an invalid track
31 /** Allow incrementing of Track variables */
32 DECLARE_POSTFIX_INCREMENT(Track)
34 /** Bitfield corresponding to Track */
35 enum TrackBits : byte {
36 TRACK_BIT_NONE = 0U, ///< No track
37 TRACK_BIT_X = 1U << TRACK_X, ///< X-axis track
38 TRACK_BIT_Y = 1U << TRACK_Y, ///< Y-axis track
39 TRACK_BIT_UPPER = 1U << TRACK_UPPER, ///< Upper track
40 TRACK_BIT_LOWER = 1U << TRACK_LOWER, ///< Lower track
41 TRACK_BIT_LEFT = 1U << TRACK_LEFT, ///< Left track
42 TRACK_BIT_RIGHT = 1U << TRACK_RIGHT, ///< Right track
43 TRACK_BIT_CROSS = TRACK_BIT_X | TRACK_BIT_Y, ///< X-Y-axis cross
44 TRACK_BIT_HORZ = TRACK_BIT_UPPER | TRACK_BIT_LOWER, ///< Upper and lower track
45 TRACK_BIT_VERT = TRACK_BIT_LEFT | TRACK_BIT_RIGHT, ///< Left and right track
46 TRACK_BIT_3WAY_NE = TRACK_BIT_X | TRACK_BIT_UPPER | TRACK_BIT_RIGHT,///< "Arrow" to the north-east
47 TRACK_BIT_3WAY_SE = TRACK_BIT_Y | TRACK_BIT_LOWER | TRACK_BIT_RIGHT,///< "Arrow" to the south-east
48 TRACK_BIT_3WAY_SW = TRACK_BIT_X | TRACK_BIT_LOWER | TRACK_BIT_LEFT, ///< "Arrow" to the south-west
49 TRACK_BIT_3WAY_NW = TRACK_BIT_Y | TRACK_BIT_UPPER | TRACK_BIT_LEFT, ///< "Arrow" to the north-west
50 TRACK_BIT_ALL = TRACK_BIT_CROSS | TRACK_BIT_HORZ | TRACK_BIT_VERT, ///< All possible tracks
51 TRACK_BIT_MASK = 0x3FU, ///< Bitmask for the first 6 bits
52 TRACK_BIT_WORMHOLE = 0x40U, ///< Bitflag for a wormhole (used for tunnels)
53 TRACK_BIT_DEPOT = 0x80U, ///< Bitflag for a depot
54 INVALID_TRACK_BIT = 0xFF, ///< Flag for an invalid trackbits value
56 DECLARE_ENUM_AS_BIT_SET(TrackBits)
58 /**
59 * Enumeration for tracks and directions.
61 * These are a combination of tracks and directions. Values are 0-5 in one
62 * direction (corresponding to the Track enum) and 8-13 in the other direction.
63 * 6, 7, 14 and 15 are used to encode the reversing of road vehicles. Those
64 * reversing track dirs are not considered to be 'valid' except in a small
65 * corner in the road vehicle controller.
67 enum Trackdir : byte {
68 TRACKDIR_BEGIN = 0, ///< Used for iterations
69 TRACKDIR_X_NE = 0, ///< X-axis and direction to north-east
70 TRACKDIR_Y_SE = 1, ///< Y-axis and direction to south-east
71 TRACKDIR_UPPER_E = 2, ///< Upper track and direction to east
72 TRACKDIR_LOWER_E = 3, ///< Lower track and direction to east
73 TRACKDIR_LEFT_S = 4, ///< Left track and direction to south
74 TRACKDIR_RIGHT_S = 5, ///< Right track and direction to south
75 TRACKDIR_RVREV_NE = 6, ///< (Road vehicle) reverse direction north-east
76 TRACKDIR_RVREV_SE = 7, ///< (Road vehicle) reverse direction south-east
77 TRACKDIR_X_SW = 8, ///< X-axis and direction to south-west
78 TRACKDIR_Y_NW = 9, ///< Y-axis and direction to north-west
79 TRACKDIR_UPPER_W = 10, ///< Upper track and direction to west
80 TRACKDIR_LOWER_W = 11, ///< Lower track and direction to west
81 TRACKDIR_LEFT_N = 12, ///< Left track and direction to north
82 TRACKDIR_RIGHT_N = 13, ///< Right track and direction to north
83 TRACKDIR_RVREV_SW = 14, ///< (Road vehicle) reverse direction south-west
84 TRACKDIR_RVREV_NW = 15, ///< (Road vehicle) reverse direction north-west
85 TRACKDIR_END, ///< Used for iterations
86 INVALID_TRACKDIR = 0xFF, ///< Flag for an invalid trackdir
89 /** Allow incrementing of Trackdir variables */
90 DECLARE_POSTFIX_INCREMENT(Trackdir)
92 /**
93 * Enumeration of bitmasks for the TrackDirs
95 * These are a combination of tracks and directions. Values are 0-5 in one
96 * direction (corresponding to the Track enum) and 8-13 in the other direction.
98 enum TrackdirBits : uint16_t {
99 TRACKDIR_BIT_NONE = 0U, ///< No track build
100 TRACKDIR_BIT_X_NE = 1U << TRACKDIR_X_NE, ///< Track x-axis, direction north-east
101 TRACKDIR_BIT_Y_SE = 1U << TRACKDIR_Y_SE, ///< Track y-axis, direction south-east
102 TRACKDIR_BIT_UPPER_E = 1U << TRACKDIR_UPPER_E, ///< Track upper, direction east
103 TRACKDIR_BIT_LOWER_E = 1U << TRACKDIR_LOWER_E, ///< Track lower, direction east
104 TRACKDIR_BIT_LEFT_S = 1U << TRACKDIR_LEFT_S, ///< Track left, direction south
105 TRACKDIR_BIT_RIGHT_S = 1U << TRACKDIR_RIGHT_S, ///< Track right, direction south
106 /* Again, note the two missing values here. This enables trackdir -> track conversion by doing (trackdir & 0xFF) */
107 TRACKDIR_BIT_X_SW = 1U << TRACKDIR_X_SW, ///< Track x-axis, direction south-west
108 TRACKDIR_BIT_Y_NW = 1U << TRACKDIR_Y_NW, ///< Track y-axis, direction north-west
109 TRACKDIR_BIT_UPPER_W = 1U << TRACKDIR_UPPER_W, ///< Track upper, direction west
110 TRACKDIR_BIT_LOWER_W = 1U << TRACKDIR_LOWER_W, ///< Track lower, direction west
111 TRACKDIR_BIT_LEFT_N = 1U << TRACKDIR_LEFT_N, ///< Track left, direction north
112 TRACKDIR_BIT_RIGHT_N = 1U << TRACKDIR_RIGHT_N, ///< Track right, direction north
113 TRACKDIR_BIT_MASK = 0x3F3F, ///< Bitmask for bit-operations
114 INVALID_TRACKDIR_BIT = 0xFFFF, ///< Flag for an invalid trackdirbit value
116 DECLARE_ENUM_AS_BIT_SET(TrackdirBits)
118 typedef uint32_t TrackStatus;
120 #endif /* TRACK_TYPE_H */