Fix #9521: Don't load at just removed docks that were part of a multi-dock station...
[openttd-github.git] / src / order_type.h
blob9f4d0ba22b6e635f034ae4093d49e468693a9da2
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 OrderID;
17 typedef uint16 OrderListID;
18 typedef uint16 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.
107 DECLARE_ENUM_AS_BIT_SET(OrderDepotActionFlags)
110 * Variables (of a vehicle) to 'cause' skipping on.
112 enum OrderConditionVariable {
113 OCV_LOAD_PERCENTAGE, ///< Skip based on the amount of load
114 OCV_RELIABILITY, ///< Skip based on the reliability
115 OCV_MAX_SPEED, ///< Skip based on the maximum speed
116 OCV_AGE, ///< Skip based on the age
117 OCV_REQUIRES_SERVICE, ///< Skip when the vehicle requires service
118 OCV_UNCONDITIONALLY, ///< Always skip
119 OCV_REMAINING_LIFETIME, ///< Skip based on the remaining lifetime
120 OCV_MAX_RELIABILITY, ///< Skip based on the maximum reliability
121 OCV_END
125 * Comparator for the skip reasoning.
127 enum OrderConditionComparator {
128 OCC_EQUALS, ///< Skip if both values are equal
129 OCC_NOT_EQUALS, ///< Skip if both values are not equal
130 OCC_LESS_THAN, ///< Skip if the value is less than the limit
131 OCC_LESS_EQUALS, ///< Skip if the value is less or equal to the limit
132 OCC_MORE_THAN, ///< Skip if the value is more than the limit
133 OCC_MORE_EQUALS, ///< Skip if the value is more or equal to the limit
134 OCC_IS_TRUE, ///< Skip if the variable is true
135 OCC_IS_FALSE, ///< Skip if the variable is false
136 OCC_END
141 * Enumeration for the data to set in #CmdModifyOrder.
143 enum ModifyOrderFlags {
144 MOF_NON_STOP, ///< Passes an OrderNonStopFlags.
145 MOF_STOP_LOCATION, ///< Passes an OrderStopLocation.
146 MOF_UNLOAD, ///< Passes an OrderUnloadType.
147 MOF_LOAD, ///< Passes an OrderLoadType
148 MOF_DEPOT_ACTION, ///< Selects the OrderDepotAction
149 MOF_COND_VARIABLE, ///< A conditional variable changes.
150 MOF_COND_COMPARATOR, ///< A comparator changes.
151 MOF_COND_VALUE, ///< The value to set the condition to.
152 MOF_COND_DESTINATION,///< Change the destination of a conditional order.
153 MOF_END
155 template <> struct EnumPropsT<ModifyOrderFlags> : MakeEnumPropsT<ModifyOrderFlags, byte, MOF_NON_STOP, MOF_END, MOF_END, 4> {};
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_END
168 * Enumeration for the data to set in #CmdChangeTimetable.
170 enum ModifyTimetableFlags {
171 MTF_WAIT_TIME, ///< Set wait time.
172 MTF_TRAVEL_TIME, ///< Set travel time.
173 MTF_TRAVEL_SPEED, ///< Set max travel speed.
174 MTF_END
176 template <> struct EnumPropsT<ModifyTimetableFlags> : MakeEnumPropsT<ModifyTimetableFlags, byte, MTF_WAIT_TIME, MTF_END, MTF_END, 2> {};
179 /** Clone actions. */
180 enum CloneOptions {
181 CO_SHARE = 0,
182 CO_COPY = 1,
183 CO_UNSHARE = 2
186 struct Order;
187 struct OrderList;
189 #endif /* ORDER_TYPE_H */