Fix #10490: Allow ships to exit depots if another is not moving at the exit point...
[openttd-github.git] / src / order_type.h
blob99a2467d26761ab8a26709827719e0471d14c70d
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 order_type.h Types related to orders. */
10 #ifndef ORDER_TYPE_H
11 #define ORDER_TYPE_H
13 #include "core/enum_type.hpp"
15 typedef byte VehicleOrderID; ///< The index of an order within its current vehicle (not pool related)
16 typedef uint32_t OrderID;
17 typedef uint16_t OrderListID;
18 typedef uint16_t DestinationID;
20 /** Invalid vehicle order index (sentinel) */
21 static const VehicleOrderID INVALID_VEH_ORDER_ID = 0xFF;
22 /** Last valid VehicleOrderID. */
23 static const VehicleOrderID MAX_VEH_ORDER_ID = INVALID_VEH_ORDER_ID - 1;
25 /** Invalid order (sentinel) */
26 static const OrderID INVALID_ORDER = 0xFFFFFF;
28 /**
29 * Maximum number of orders in implicit-only lists before we start searching
30 * harder for duplicates.
32 static const uint IMPLICIT_ORDER_ONLY_CAP = 32;
34 /** Order types. It needs to be 8bits, because we save and load it as such */
35 enum OrderType : byte {
36 OT_BEGIN = 0,
37 OT_NOTHING = 0,
38 OT_GOTO_STATION = 1,
39 OT_GOTO_DEPOT = 2,
40 OT_LOADING = 3,
41 OT_LEAVESTATION = 4,
42 OT_DUMMY = 5,
43 OT_GOTO_WAYPOINT = 6,
44 OT_CONDITIONAL = 7,
45 OT_IMPLICIT = 8,
46 OT_END
49 /**
50 * Flags related to the unloading order.
52 enum OrderUnloadFlags {
53 OUF_UNLOAD_IF_POSSIBLE = 0, ///< Unload all cargo that the station accepts.
54 OUFB_UNLOAD = 1 << 0, ///< Force unloading all cargo onto the platform, possibly not getting paid.
55 OUFB_TRANSFER = 1 << 1, ///< Transfer all cargo onto the platform.
56 OUFB_NO_UNLOAD = 1 << 2, ///< Totally no unloading will be done.
59 /**
60 * Flags related to the loading order.
62 enum OrderLoadFlags {
63 OLF_LOAD_IF_POSSIBLE = 0, ///< Load as long as there is cargo that fits in the train.
64 OLFB_FULL_LOAD = 1 << 1, ///< Full load all cargoes of the consist.
65 OLF_FULL_LOAD_ANY = 3, ///< Full load a single cargo of the consist.
66 OLFB_NO_LOAD = 4, ///< Do not load anything.
69 /**
70 * Non-stop order flags.
72 enum OrderNonStopFlags {
73 ONSF_STOP_EVERYWHERE = 0, ///< The vehicle will stop at any station it passes and the destination.
74 ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS = 1, ///< The vehicle will not stop at any stations it passes except the destination.
75 ONSF_NO_STOP_AT_DESTINATION_STATION = 2, ///< The vehicle will stop at any station it passes except the destination.
76 ONSF_NO_STOP_AT_ANY_STATION = 3, ///< The vehicle will not stop at any stations it passes including the destination.
77 ONSF_END
80 /**
81 * Where to stop the trains.
83 enum OrderStopLocation {
84 OSL_PLATFORM_NEAR_END = 0, ///< Stop at the near end of the platform
85 OSL_PLATFORM_MIDDLE = 1, ///< Stop at the middle of the platform
86 OSL_PLATFORM_FAR_END = 2, ///< Stop at the far end of the platform
87 OSL_END
90 /**
91 * Reasons that could cause us to go to the depot.
93 enum OrderDepotTypeFlags {
94 ODTF_MANUAL = 0, ///< Manually initiated order.
95 ODTFB_SERVICE = 1 << 0, ///< This depot order is because of the servicing limit.
96 ODTFB_PART_OF_ORDERS = 1 << 1, ///< This depot order is because of a regular order.
99 /**
100 * Actions that can be performed when the vehicle enters the depot.
102 enum OrderDepotActionFlags {
103 ODATF_SERVICE_ONLY = 0, ///< Only service the vehicle.
104 ODATFB_HALT = 1 << 0, ///< Service the vehicle and then halt it.
105 ODATFB_NEAREST_DEPOT = 1 << 1, ///< Send the vehicle to the nearest depot.
106 ODATFB_UNBUNCH = 1 << 2, ///< Service the vehicle and then unbunch it.
108 DECLARE_ENUM_AS_BIT_SET(OrderDepotActionFlags)
111 * Variables (of a vehicle) to 'cause' skipping on.
113 enum OrderConditionVariable {
114 OCV_LOAD_PERCENTAGE, ///< Skip based on the amount of load
115 OCV_RELIABILITY, ///< Skip based on the reliability
116 OCV_MAX_SPEED, ///< Skip based on the maximum speed
117 OCV_AGE, ///< Skip based on the age
118 OCV_REQUIRES_SERVICE, ///< Skip when the vehicle requires service
119 OCV_UNCONDITIONALLY, ///< Always skip
120 OCV_REMAINING_LIFETIME, ///< Skip based on the remaining lifetime
121 OCV_MAX_RELIABILITY, ///< Skip based on the maximum reliability
122 OCV_END
126 * Comparator for the skip reasoning.
128 enum OrderConditionComparator {
129 OCC_EQUALS, ///< Skip if both values are equal
130 OCC_NOT_EQUALS, ///< Skip if both values are not equal
131 OCC_LESS_THAN, ///< Skip if the value is less than the limit
132 OCC_LESS_EQUALS, ///< Skip if the value is less or equal to the limit
133 OCC_MORE_THAN, ///< Skip if the value is more than the limit
134 OCC_MORE_EQUALS, ///< Skip if the value is more or equal to the limit
135 OCC_IS_TRUE, ///< Skip if the variable is true
136 OCC_IS_FALSE, ///< Skip if the variable is false
137 OCC_END
142 * Enumeration for the data to set in #CmdModifyOrder.
144 enum ModifyOrderFlags : byte {
145 MOF_NON_STOP, ///< Passes an OrderNonStopFlags.
146 MOF_STOP_LOCATION, ///< Passes an OrderStopLocation.
147 MOF_UNLOAD, ///< Passes an OrderUnloadType.
148 MOF_LOAD, ///< Passes an OrderLoadType
149 MOF_DEPOT_ACTION, ///< Selects the OrderDepotAction
150 MOF_COND_VARIABLE, ///< A conditional variable changes.
151 MOF_COND_COMPARATOR, ///< A comparator changes.
152 MOF_COND_VALUE, ///< The value to set the condition to.
153 MOF_COND_DESTINATION,///< Change the destination of a conditional order.
154 MOF_END
158 * Depot action to switch to when doing a #MOF_DEPOT_ACTION.
160 enum OrderDepotAction {
161 DA_ALWAYS_GO, ///< Always go to the depot
162 DA_SERVICE, ///< Service only if needed
163 DA_STOP, ///< Go to the depot and stop there
164 DA_UNBUNCH, ///< Go to the depot and unbunch
165 DA_END
169 * Enumeration for the data to set in #CmdChangeTimetable.
171 enum ModifyTimetableFlags : byte {
172 MTF_WAIT_TIME, ///< Set wait time.
173 MTF_TRAVEL_TIME, ///< Set travel time.
174 MTF_TRAVEL_SPEED, ///< Set max travel speed.
175 MTF_END
178 /** Clone actions. */
179 enum CloneOptions : byte {
180 CO_SHARE = 0,
181 CO_COPY = 1,
182 CO_UNSHARE = 2
185 struct Order;
186 struct OrderList;
188 #endif /* ORDER_TYPE_H */