OpenTTD Source 20251213-master-g1091fa6071
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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#ifndef ORDER_TYPE_H
11#define ORDER_TYPE_H
12
13#include "core/enum_type.hpp"
14#include "depot_type.h"
15#include "core/pool_type.hpp"
16#include "station_type.h"
17
18typedef uint8_t VehicleOrderID;
20
22 using BaseType = uint16_t;
23 BaseType value = 0;
24
25 explicit DestinationID() = default;
26 constexpr DestinationID(size_t index) : value(static_cast<BaseType>(index)) {}
27 constexpr DestinationID(DepotID depot) : value(depot.base()) {}
28 constexpr DestinationID(StationID station) : value(station.base()) {}
29
30 constexpr DepotID ToDepotID() const noexcept { return static_cast<DepotID>(this->value); }
31 constexpr StationID ToStationID() const noexcept { return static_cast<StationID>(this->value); }
32 constexpr BaseType base() const noexcept { return this->value; }
33
34 constexpr bool operator ==(const DestinationID &destination) const { return this->value == destination.value; }
35 constexpr bool operator ==(const StationID &station) const { return this->value == station; }
36};
37
42
47static const uint IMPLICIT_ORDER_ONLY_CAP = 32;
48
50enum OrderType : uint8_t {
51 OT_BEGIN = 0,
52 OT_NOTHING = 0,
53 OT_GOTO_STATION = 1,
54 OT_GOTO_DEPOT = 2,
55 OT_LOADING = 3,
56 OT_LEAVESTATION = 4,
57 OT_DUMMY = 5,
58 OT_GOTO_WAYPOINT = 6,
59 OT_CONDITIONAL = 7,
60 OT_IMPLICIT = 8,
61 OT_END
62};
63
67enum class OrderUnloadType : uint8_t {
69 Unload = 1,
70 Transfer = 2,
71 NoUnload = 4,
72};
73
77enum class OrderLoadType : uint8_t {
78 LoadIfPossible = 0,
79 FullLoad = 2,
80 FullLoadAny = 3,
81 NoLoad = 4,
82};
83
87enum class OrderNonStopFlag : uint8_t {
88 NoIntermediate = 0,
89 NoDestination = 1,
90};
91
93
97enum class OrderStopLocation : uint8_t {
98 NearEnd = 0,
99 Middle = 1,
100 FarEnd = 2,
101 End,
102};
103
107enum class OrderDepotTypeFlag : uint8_t {
108 Service = 0,
109 PartOfOrders = 1,
110};
111
113
117enum class OrderDepotActionFlag : uint8_t {
118 Halt = 0,
119 NearestDepot = 1,
120 Unbunch = 2,
121};
122
124
128enum class OrderConditionVariable : uint8_t {
129 LoadPercentage = 0,
130 Reliability = 1,
131 MaxSpeed = 2,
132 Age = 3,
133 RequiresService = 4,
134 Unconditionally = 5,
136 MaxReliability = 7,
137 End,
138};
139
143enum class OrderConditionComparator : uint8_t {
144 Equal = 0,
145 NotEqual = 1,
146 LessThan = 2,
147 LessThanOrEqual = 3,
148 MoreThan = 4,
149 MoreThanOrEqual = 5,
150 IsTrue = 6,
151 IsFalse = 7,
152 End,
153};
154
155
171
175enum class OrderDepotAction : uint8_t {
176 AlwaysGo = 0,
177 Service = 1,
178 Stop = 2,
179 Unbunch = 3,
180 End
181};
182
192
194enum CloneOptions : uint8_t {
195 CO_SHARE = 0,
196 CO_COPY = 1,
197 CO_UNSHARE = 2
198};
199
200struct Order;
201struct OrderList;
202
203#endif /* ORDER_TYPE_H */
Enum-as-bit-set wrapper.
@ End
End marker.
Header files for depots (not hangars)
Type (helpers) for enums.
OrderUnloadType
Unloading order types.
Definition order_type.h:67
@ Transfer
Transfer all cargo onto the platform.
@ UnloadIfPossible
Unload all cargo that the station accepts.
@ NoUnload
Totally no unloading will be done.
@ Unload
Force unloading all cargo onto the platform, possibly not getting paid.
OrderConditionVariable
Variables (of a vehicle) to 'cause' skipping on.
Definition order_type.h:128
@ Unconditionally
Always skip.
@ MaxSpeed
Skip based on the maximum speed.
@ Reliability
Skip based on the reliability.
@ MaxReliability
Skip based on the maximum reliability.
@ RequiresService
Skip when the vehicle requires service.
@ LoadPercentage
Skip based on the amount of load.
@ Age
Skip based on the age.
@ RemainingLifetime
Skip based on the remaining lifetime.
OrderStopLocation
Where to stop the trains.
Definition order_type.h:97
@ NearEnd
Stop at the near end of the platform.
@ FarEnd
Stop at the far end of the platform.
@ Middle
Stop at the middle of the platform.
ModifyOrderFlags
Enumeration for the data to set in CmdModifyOrder.
Definition order_type.h:159
@ MOF_COND_VARIABLE
A conditional variable changes.
Definition order_type.h:165
@ MOF_LOAD
Passes an OrderLoadType.
Definition order_type.h:163
@ MOF_UNLOAD
Passes an OrderUnloadType.
Definition order_type.h:162
@ MOF_STOP_LOCATION
Passes an OrderStopLocation.
Definition order_type.h:161
@ MOF_COND_DESTINATION
Change the destination of a conditional order.
Definition order_type.h:168
@ MOF_COND_COMPARATOR
A comparator changes.
Definition order_type.h:166
@ MOF_COND_VALUE
The value to set the condition to.
Definition order_type.h:167
@ MOF_DEPOT_ACTION
Selects the OrderDepotAction.
Definition order_type.h:164
@ MOF_NON_STOP
Passes an OrderNonStopFlags.
Definition order_type.h:160
OrderDepotAction
Depot action to switch to when doing a MOF_DEPOT_ACTION.
Definition order_type.h:175
@ Stop
Go to the depot and stop there.
@ AlwaysGo
Always go to the depot.
OrderNonStopFlag
Non-stop order flags.
Definition order_type.h:87
@ NoDestination
The vehicle will stop at any station it passes except the destination, aka via.
@ NoIntermediate
The vehicle will not stop at any stations it passes except the destination, aka non-stop.
uint8_t VehicleOrderID
The index of an order within its current vehicle (not pool related)
Definition order_type.h:18
OrderLoadType
Loading order types.
Definition order_type.h:77
@ FullLoad
Full load all cargoes of the consist.
@ NoLoad
Do not load anything.
@ FullLoadAny
Full load a single cargo of the consist.
@ LoadIfPossible
Load as long as there is cargo that fits in the train.
static const VehicleOrderID MAX_VEH_ORDER_ID
Last valid VehicleOrderID.
Definition order_type.h:41
OrderDepotActionFlag
Actions that can be performed when the vehicle enters the depot.
Definition order_type.h:117
@ Halt
Service the vehicle and then halt it.
@ NearestDepot
Send the vehicle to the nearest depot.
@ Unbunch
Service the vehicle and then unbunch it.
OrderDepotTypeFlag
Reasons that could cause us to go to the depot.
Definition order_type.h:107
@ PartOfOrders
This depot order is because of a regular order.
@ Service
This depot order is because of the servicing limit.
static const VehicleOrderID INVALID_VEH_ORDER_ID
Invalid vehicle order index (sentinel)
Definition order_type.h:39
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:47
OrderConditionComparator
Comparator for the skip reasoning.
Definition order_type.h:143
@ IsTrue
Skip if the variable is true.
@ NotEqual
Skip if both values are not equal.
@ IsFalse
Skip if the variable is false.
@ LessThanOrEqual
Skip if the value is less or equal to the limit.
@ MoreThan
Skip if the value is more than the limit.
@ MoreThanOrEqual
Skip if the value is more or equal to the limit.
@ LessThan
Skip if the value is less than the limit.
@ Equal
Skip if both values are equal.
ModifyTimetableFlags
Enumeration for the data to set in CmdChangeTimetable.
Definition order_type.h:186
@ MTF_TRAVEL_TIME
Set travel time.
Definition order_type.h:188
@ MTF_WAIT_TIME
Set wait time.
Definition order_type.h:187
@ MTF_TRAVEL_SPEED
Set max travel speed.
Definition order_type.h:189
CloneOptions
Clone actions.
Definition order_type.h:194
OrderType
Order types.
Definition order_type.h:50
Definition of Pool, structure used to access PoolItems, and PoolItem, base structure for Vehicle,...
Types related to stations.
Shared order list linking together the linked list of orders and the list of vehicles sharing this or...
Definition order_base.h:274
Templated helper to make a PoolID a single POD value.
Definition pool_type.hpp:43