OpenTTD Source: src/order_type.h Source File

OpenTTD Source 14.1

order_type.h
Go to the documentation of this file.
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 */
7
10 #ifndef ORDER_TYPE_H
11 #define ORDER_TYPE_H
12
13 #include "core/enum_type.hpp"
14
15 typedef byte VehicleOrderID;
16 typedef uint32_t OrderID;
17 typedef uint16_t OrderListID;
18 typedef uint16_t DestinationID;
19
21 static const VehicleOrderID INVALID_VEH_ORDER_ID = 0xFF;
23 static const VehicleOrderID MAX_VEH_ORDER_ID = INVALID_VEH_ORDER_ID - 1;
24
26 static const OrderID INVALID_ORDER = 0xFFFFFF;
27
32 static const uint IMPLICIT_ORDER_ONLY_CAP = 32;
33
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
47 };
48
52 enum OrderUnloadFlags {
53 OUF_UNLOAD_IF_POSSIBLE = 0,
54 OUFB_UNLOAD = 1 << 0,
55 OUFB_TRANSFER = 1 << 1,
56 OUFB_NO_UNLOAD = 1 << 2,
57 };
58
62 enum OrderLoadFlags {
63 OLF_LOAD_IF_POSSIBLE = 0,
64 OLFB_FULL_LOAD = 1 << 1,
65 OLF_FULL_LOAD_ANY = 3,
66 OLFB_NO_LOAD = 4,
67 };
68
72 enum OrderNonStopFlags {
73 ONSF_STOP_EVERYWHERE = 0,
74 ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS = 1,
75 ONSF_NO_STOP_AT_DESTINATION_STATION = 2,
76 ONSF_NO_STOP_AT_ANY_STATION = 3,
77 ONSF_END
78 };
79
83 enum OrderStopLocation {
84 OSL_PLATFORM_NEAR_END = 0,
85 OSL_PLATFORM_MIDDLE = 1,
86 OSL_PLATFORM_FAR_END = 2,
87 OSL_END
88 };
89
93 enum OrderDepotTypeFlags {
94 ODTF_MANUAL = 0,
95 ODTFB_SERVICE = 1 << 0,
96 ODTFB_PART_OF_ORDERS = 1 << 1,
97 };
98
102 enum OrderDepotActionFlags {
103 ODATF_SERVICE_ONLY = 0,
104 ODATFB_HALT = 1 << 0,
105 ODATFB_NEAREST_DEPOT = 1 << 1,
106 ODATFB_UNBUNCH = 1 << 2,
107 };
108 DECLARE_ENUM_AS_BIT_SET(OrderDepotActionFlags)
109
110
113 enum OrderConditionVariable {
114 OCV_LOAD_PERCENTAGE,
115 OCV_RELIABILITY,
116 OCV_MAX_SPEED,
117 OCV_AGE,
118 OCV_REQUIRES_SERVICE,
119 OCV_UNCONDITIONALLY,
120 OCV_REMAINING_LIFETIME,
121 OCV_MAX_RELIABILITY,
122 OCV_END
123 };
124
128 enum OrderConditionComparator {
129 OCC_EQUALS,
130 OCC_NOT_EQUALS,
131 OCC_LESS_THAN,
132 OCC_LESS_EQUALS,
133 OCC_MORE_THAN,
134 OCC_MORE_EQUALS,
135 OCC_IS_TRUE,
136 OCC_IS_FALSE,
137 OCC_END
138 };
139
140
144 enum ModifyOrderFlags : byte {
145 MOF_NON_STOP,
146 MOF_STOP_LOCATION,
147 MOF_UNLOAD,
148 MOF_LOAD,
149 MOF_DEPOT_ACTION,
150 MOF_COND_VARIABLE,
151 MOF_COND_COMPARATOR,
152 MOF_COND_VALUE,
153 MOF_COND_DESTINATION,
154 MOF_END
155 };
156
160 enum OrderDepotAction {
161 DA_ALWAYS_GO,
162 DA_SERVICE,
163 DA_STOP,
164 DA_UNBUNCH,
165 DA_END
166 };
167
171 enum ModifyTimetableFlags : byte {
172 MTF_WAIT_TIME,
173 MTF_TRAVEL_TIME,
174 MTF_TRAVEL_SPEED,
175 MTF_END
176 };
177
179 enum CloneOptions : byte {
180 CO_SHARE = 0,
181 CO_COPY = 1,
182 CO_UNSHARE = 2
183 };
184
185 struct Order;
186 struct OrderList;
187
188 #endif /* ORDER_TYPE_H */
MTF_TRAVEL_SPEED
@ MTF_TRAVEL_SPEED
Set max travel speed.
Definition: order_type.h:174
DA_STOP
@ DA_STOP
Go to the depot and stop there.
Definition: order_type.h:163
VehicleOrderID
byte VehicleOrderID
The index of an order within its current vehicle (not pool related)
Definition: order_type.h:15
OUFB_UNLOAD
@ OUFB_UNLOAD
Force unloading all cargo onto the platform, possibly not getting paid.
Definition: order_type.h:54
CloneOptions
CloneOptions
Clone actions.
Definition: order_type.h:179
OCC_NOT_EQUALS
@ OCC_NOT_EQUALS
Skip if both values are not equal.
Definition: order_type.h:130
MTF_WAIT_TIME
@ MTF_WAIT_TIME
Set wait time.
Definition: order_type.h:172
ODTFB_SERVICE
@ ODTFB_SERVICE
This depot order is because of the servicing limit.
Definition: order_type.h:95
ModifyTimetableFlags
ModifyTimetableFlags
Enumeration for the data to set in CmdChangeTimetable.
Definition: order_type.h:171
MOF_COND_VARIABLE
@ MOF_COND_VARIABLE
A conditional variable changes.
Definition: order_type.h:150
OrderLoadFlags
OrderLoadFlags
Flags related to the loading order.
Definition: order_type.h:62
ModifyOrderFlags
ModifyOrderFlags
Enumeration for the data to set in CmdModifyOrder.
Definition: order_type.h:144
OUFB_TRANSFER
@ OUFB_TRANSFER
Transfer all cargo onto the platform.
Definition: order_type.h:55
OLFB_FULL_LOAD
@ OLFB_FULL_LOAD
Full load all cargoes of the consist.
Definition: order_type.h:64
IMPLICIT_ORDER_ONLY_CAP
static const uint IMPLICIT_ORDER_ONLY_CAP
Maximum number of orders in implicit-only lists before we start searching harder for duplicates.
Definition: order_type.h:32
OSL_PLATFORM_MIDDLE
@ OSL_PLATFORM_MIDDLE
Stop at the middle of the platform.
Definition: order_type.h:85
MOF_STOP_LOCATION
@ MOF_STOP_LOCATION
Passes an OrderStopLocation.
Definition: order_type.h:146
ODTF_MANUAL
@ ODTF_MANUAL
Manually initiated order.
Definition: order_type.h:94
OrderDepotTypeFlags
OrderDepotTypeFlags
Reasons that could cause us to go to the depot.
Definition: order_type.h:93
OCC_MORE_THAN
@ OCC_MORE_THAN
Skip if the value is more than the limit.
Definition: order_type.h:133
MOF_NON_STOP
@ MOF_NON_STOP
Passes an OrderNonStopFlags.
Definition: order_type.h:145
OrderStopLocation
OrderStopLocation
Where to stop the trains.
Definition: order_type.h:83
ODATFB_UNBUNCH
@ ODATFB_UNBUNCH
Service the vehicle and then unbunch it.
Definition: order_type.h:106
INVALID_ORDER
static const OrderID INVALID_ORDER
Invalid order (sentinel)
Definition: order_type.h:26
ONSF_NO_STOP_AT_ANY_STATION
@ ONSF_NO_STOP_AT_ANY_STATION
The vehicle will not stop at any stations it passes including the destination.
Definition: order_type.h:76
ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS
@ ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS
The vehicle will not stop at any stations it passes except the destination.
Definition: order_type.h:74
OLF_FULL_LOAD_ANY
@ OLF_FULL_LOAD_ANY
Full load a single cargo of the consist.
Definition: order_type.h:65
ONSF_STOP_EVERYWHERE
@ ONSF_STOP_EVERYWHERE
The vehicle will stop at any station it passes and the destination.
Definition: order_type.h:73
INVALID_VEH_ORDER_ID
static const VehicleOrderID INVALID_VEH_ORDER_ID
Invalid vehicle order index (sentinel)
Definition: order_type.h:21
MOF_COND_COMPARATOR
@ MOF_COND_COMPARATOR
A comparator changes.
Definition: order_type.h:151
OUF_UNLOAD_IF_POSSIBLE
@ OUF_UNLOAD_IF_POSSIBLE
Unload all cargo that the station accepts.
Definition: order_type.h:53
ODATFB_NEAREST_DEPOT
@ ODATFB_NEAREST_DEPOT
Send the vehicle to the nearest depot.
Definition: order_type.h:105
OCC_IS_TRUE
@ OCC_IS_TRUE
Skip if the variable is true.
Definition: order_type.h:135
OCC_LESS_EQUALS
@ OCC_LESS_EQUALS
Skip if the value is less or equal to the limit.
Definition: order_type.h:132
DA_ALWAYS_GO
@ DA_ALWAYS_GO
Always go to the depot.
Definition: order_type.h:161
ODTFB_PART_OF_ORDERS
@ ODTFB_PART_OF_ORDERS
This depot order is because of a regular order.
Definition: order_type.h:96
OCC_MORE_EQUALS
@ OCC_MORE_EQUALS
Skip if the value is more or equal to the limit.
Definition: order_type.h:134
MOF_COND_DESTINATION
@ MOF_COND_DESTINATION
Change the destination of a conditional order.
Definition: order_type.h:153
OrderDepotAction
OrderDepotAction
Depot action to switch to when doing a MOF_DEPOT_ACTION.
Definition: order_type.h:160
OLF_LOAD_IF_POSSIBLE
@ OLF_LOAD_IF_POSSIBLE
Load as long as there is cargo that fits in the train.
Definition: order_type.h:63
OSL_PLATFORM_NEAR_END
@ OSL_PLATFORM_NEAR_END
Stop at the near end of the platform.
Definition: order_type.h:84
ODATFB_HALT
@ ODATFB_HALT
Service the vehicle and then halt it.
Definition: order_type.h:104
ONSF_NO_STOP_AT_DESTINATION_STATION
@ ONSF_NO_STOP_AT_DESTINATION_STATION
The vehicle will stop at any station it passes except the destination.
Definition: order_type.h:75
OrderUnloadFlags
OrderUnloadFlags
Flags related to the unloading order.
Definition: order_type.h:52
OrderNonStopFlags
OrderNonStopFlags
Non-stop order flags.
Definition: order_type.h:72
OCC_EQUALS
@ OCC_EQUALS
Skip if both values are equal.
Definition: order_type.h:129
OCV_MAX_SPEED
@ OCV_MAX_SPEED
Skip based on the maximum speed.
Definition: order_type.h:116
OSL_PLATFORM_FAR_END
@ OSL_PLATFORM_FAR_END
Stop at the far end of the platform.
Definition: order_type.h:86
MOF_UNLOAD
@ MOF_UNLOAD
Passes an OrderUnloadType.
Definition: order_type.h:147
OCV_RELIABILITY
@ OCV_RELIABILITY
Skip based on the reliability.
Definition: order_type.h:115
OCV_REMAINING_LIFETIME
@ OCV_REMAINING_LIFETIME
Skip based on the remaining lifetime.
Definition: order_type.h:120
OUFB_NO_UNLOAD
@ OUFB_NO_UNLOAD
Totally no unloading will be done.
Definition: order_type.h:56
OrderList
Shared order list linking together the linked list of orders and the list of vehicles sharing this or...
Definition: order_base.h:260
MOF_COND_VALUE
@ MOF_COND_VALUE
The value to set the condition to.
Definition: order_type.h:152
MAX_VEH_ORDER_ID
static const VehicleOrderID MAX_VEH_ORDER_ID
Last valid VehicleOrderID.
Definition: order_type.h:23
OCV_LOAD_PERCENTAGE
@ OCV_LOAD_PERCENTAGE
Skip based on the amount of load.
Definition: order_type.h:114
enum_type.hpp
DECLARE_ENUM_AS_BIT_SET
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
Definition: company_manager_face.h:29
OrderType
OrderType
Order types.
Definition: order_type.h:35
OrderConditionVariable
OrderConditionVariable
Variables (of a vehicle) to 'cause' skipping on.
Definition: order_type.h:113
ODATF_SERVICE_ONLY
@ ODATF_SERVICE_ONLY
Only service the vehicle.
Definition: order_type.h:103
DA_UNBUNCH
@ DA_UNBUNCH
Go to the depot and unbunch.
Definition: order_type.h:164
OCV_REQUIRES_SERVICE
@ OCV_REQUIRES_SERVICE
Skip when the vehicle requires service.
Definition: order_type.h:118
OCV_MAX_RELIABILITY
@ OCV_MAX_RELIABILITY
Skip based on the maximum reliability.
Definition: order_type.h:121
MOF_LOAD
@ MOF_LOAD
Passes an OrderLoadType.
Definition: order_type.h:148
OCC_IS_FALSE
@ OCC_IS_FALSE
Skip if the variable is false.
Definition: order_type.h:136
OrderDepotActionFlags
OrderDepotActionFlags
Actions that can be performed when the vehicle enters the depot.
Definition: order_type.h:102
MOF_DEPOT_ACTION
@ MOF_DEPOT_ACTION
Selects the OrderDepotAction.
Definition: order_type.h:149
Order
Definition: order_base.h:36
DA_SERVICE
@ DA_SERVICE
Service only if needed.
Definition: order_type.h:162
OCV_AGE
@ OCV_AGE
Skip based on the age.
Definition: order_type.h:117
OrderConditionComparator
OrderConditionComparator
Comparator for the skip reasoning.
Definition: order_type.h:128
OCC_LESS_THAN
@ OCC_LESS_THAN
Skip if the value is less than the limit.
Definition: order_type.h:131
OCV_UNCONDITIONALLY
@ OCV_UNCONDITIONALLY
Always skip.
Definition: order_type.h:119
OLFB_NO_LOAD
@ OLFB_NO_LOAD
Do not load anything.
Definition: order_type.h:66
MTF_TRAVEL_TIME
@ MTF_TRAVEL_TIME
Set travel time.
Definition: order_type.h:173