OpenTTD Source 20250312-master-gcdcc6b491d
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#include "depot_type.h"
15#include "core/pool_type.hpp"
16#include "station_type.h"
17
18typedef uint8_t VehicleOrderID;
21
23 using BaseType = uint16_t;
24 BaseType value = 0;
25
26 explicit DestinationID() = default;
27 constexpr DestinationID(size_t index) : value(static_cast<BaseType>(index)) {}
28 constexpr DestinationID(DepotID depot) : value(depot.base()) {}
29 constexpr DestinationID(StationID station) : value(station.base()) {}
30
31 constexpr DepotID ToDepotID() const noexcept { return static_cast<DepotID>(this->value); }
32 constexpr StationID ToStationID() const noexcept { return static_cast<StationID>(this->value); }
33 constexpr BaseType base() const noexcept { return this->value; }
34
35 constexpr bool operator ==(const DestinationID &destination) const { return this->value == destination.value; }
36 constexpr bool operator ==(const StationID &station) const { return this->value == station; }
37};
38
43
48static const uint IMPLICIT_ORDER_ONLY_CAP = 32;
49
51enum OrderType : uint8_t {
52 OT_BEGIN = 0,
53 OT_NOTHING = 0,
54 OT_GOTO_STATION = 1,
55 OT_GOTO_DEPOT = 2,
56 OT_LOADING = 3,
57 OT_LEAVESTATION = 4,
58 OT_DUMMY = 5,
59 OT_GOTO_WAYPOINT = 6,
60 OT_CONDITIONAL = 7,
61 OT_IMPLICIT = 8,
62 OT_END
63};
64
68enum OrderUnloadFlags : uint8_t {
70 OUFB_UNLOAD = 1 << 0,
71 OUFB_TRANSFER = 1 << 1,
72 OUFB_NO_UNLOAD = 1 << 2,
73};
74
84
95
105
114
125
126
140
155
156
172
183
193
195enum CloneOptions : uint8_t {
196 CO_SHARE = 0,
197 CO_COPY = 1,
198 CO_UNSHARE = 2
199};
200
201struct Order;
202struct OrderList;
203
204#endif /* ORDER_TYPE_H */
Header files for depots (not hangars)
Type (helpers) for enums.
#define DECLARE_ENUM_AS_BIT_SET(enum_type)
Operators to allow to work with enum as with type safe bit set in C++.
Definition enum_type.hpp:70
OrderConditionVariable
Variables (of a vehicle) to 'cause' skipping on.
Definition order_type.h:129
@ OCV_AGE
Skip based on the age.
Definition order_type.h:133
@ OCV_UNCONDITIONALLY
Always skip.
Definition order_type.h:135
@ OCV_MAX_SPEED
Skip based on the maximum speed.
Definition order_type.h:132
@ OCV_LOAD_PERCENTAGE
Skip based on the amount of load.
Definition order_type.h:130
@ OCV_REQUIRES_SERVICE
Skip when the vehicle requires service.
Definition order_type.h:134
@ OCV_RELIABILITY
Skip based on the reliability.
Definition order_type.h:131
@ OCV_REMAINING_LIFETIME
Skip based on the remaining lifetime.
Definition order_type.h:136
@ OCV_MAX_RELIABILITY
Skip based on the maximum reliability.
Definition order_type.h:137
OrderStopLocation
Where to stop the trains.
Definition order_type.h:99
@ OSL_PLATFORM_MIDDLE
Stop at the middle of the platform.
Definition order_type.h:101
@ OSL_PLATFORM_FAR_END
Stop at the far end of the platform.
Definition order_type.h:102
@ OSL_PLATFORM_NEAR_END
Stop at the near end of the platform.
Definition order_type.h:100
ModifyOrderFlags
Enumeration for the data to set in CmdModifyOrder.
Definition order_type.h:160
@ MOF_COND_VARIABLE
A conditional variable changes.
Definition order_type.h:166
@ MOF_LOAD
Passes an OrderLoadType.
Definition order_type.h:164
@ MOF_UNLOAD
Passes an OrderUnloadType.
Definition order_type.h:163
@ MOF_STOP_LOCATION
Passes an OrderStopLocation.
Definition order_type.h:162
@ MOF_COND_DESTINATION
Change the destination of a conditional order.
Definition order_type.h:169
@ MOF_COND_COMPARATOR
A comparator changes.
Definition order_type.h:167
@ MOF_COND_VALUE
The value to set the condition to.
Definition order_type.h:168
@ MOF_DEPOT_ACTION
Selects the OrderDepotAction.
Definition order_type.h:165
@ MOF_NON_STOP
Passes an OrderNonStopFlags.
Definition order_type.h:161
OrderUnloadFlags
Flags related to the unloading order.
Definition order_type.h:68
@ OUFB_TRANSFER
Transfer all cargo onto the platform.
Definition order_type.h:71
@ OUFB_NO_UNLOAD
Totally no unloading will be done.
Definition order_type.h:72
@ OUF_UNLOAD_IF_POSSIBLE
Unload all cargo that the station accepts.
Definition order_type.h:69
@ OUFB_UNLOAD
Force unloading all cargo onto the platform, possibly not getting paid.
Definition order_type.h:70
OrderDepotAction
Depot action to switch to when doing a MOF_DEPOT_ACTION.
Definition order_type.h:176
@ DA_SERVICE
Service only if needed.
Definition order_type.h:178
@ DA_STOP
Go to the depot and stop there.
Definition order_type.h:179
@ DA_ALWAYS_GO
Always go to the depot.
Definition order_type.h:177
@ DA_UNBUNCH
Go to the depot and unbunch.
Definition order_type.h:180
OrderDepotTypeFlags
Reasons that could cause us to go to the depot.
Definition order_type.h:109
@ ODTFB_PART_OF_ORDERS
This depot order is because of a regular order.
Definition order_type.h:112
@ ODTFB_SERVICE
This depot order is because of the servicing limit.
Definition order_type.h:111
@ ODTF_MANUAL
Manually initiated order.
Definition order_type.h:110
uint8_t VehicleOrderID
The index of an order within its current vehicle (not pool related)
Definition order_type.h:18
OrderDepotActionFlags
Actions that can be performed when the vehicle enters the depot.
Definition order_type.h:118
@ ODATFB_UNBUNCH
Service the vehicle and then unbunch it.
Definition order_type.h:122
@ ODATFB_NEAREST_DEPOT
Send the vehicle to the nearest depot.
Definition order_type.h:121
@ ODATFB_HALT
Service the vehicle and then halt it.
Definition order_type.h:120
@ ODATF_SERVICE_ONLY
Only service the vehicle.
Definition order_type.h:119
static const VehicleOrderID MAX_VEH_ORDER_ID
Last valid VehicleOrderID.
Definition order_type.h:42
OrderLoadFlags
Flags related to the loading order.
Definition order_type.h:78
@ OLFB_FULL_LOAD
Full load all cargoes of the consist.
Definition order_type.h:80
@ OLFB_NO_LOAD
Do not load anything.
Definition order_type.h:82
@ OLF_LOAD_IF_POSSIBLE
Load as long as there is cargo that fits in the train.
Definition order_type.h:79
@ OLF_FULL_LOAD_ANY
Full load a single cargo of the consist.
Definition order_type.h:81
static const VehicleOrderID INVALID_VEH_ORDER_ID
Invalid vehicle order index (sentinel)
Definition order_type.h:40
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:48
OrderConditionComparator
Comparator for the skip reasoning.
Definition order_type.h:144
@ OCC_LESS_EQUALS
Skip if the value is less or equal to the limit.
Definition order_type.h:148
@ OCC_EQUALS
Skip if both values are equal.
Definition order_type.h:145
@ OCC_NOT_EQUALS
Skip if both values are not equal.
Definition order_type.h:146
@ OCC_MORE_THAN
Skip if the value is more than the limit.
Definition order_type.h:149
@ OCC_IS_TRUE
Skip if the variable is true.
Definition order_type.h:151
@ OCC_LESS_THAN
Skip if the value is less than the limit.
Definition order_type.h:147
@ OCC_MORE_EQUALS
Skip if the value is more or equal to the limit.
Definition order_type.h:150
@ OCC_IS_FALSE
Skip if the variable is false.
Definition order_type.h:152
OrderNonStopFlags
Non-stop order flags.
Definition order_type.h:88
@ ONSF_NO_STOP_AT_ANY_STATION
The vehicle will not stop at any stations it passes including the destination.
Definition order_type.h:92
@ ONSF_NO_STOP_AT_DESTINATION_STATION
The vehicle will stop at any station it passes except the destination.
Definition order_type.h:91
@ ONSF_STOP_EVERYWHERE
The vehicle will stop at any station it passes and the destination.
Definition order_type.h:89
@ ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS
The vehicle will not stop at any stations it passes except the destination.
Definition order_type.h:90
ModifyTimetableFlags
Enumeration for the data to set in CmdChangeTimetable.
Definition order_type.h:187
@ MTF_TRAVEL_TIME
Set travel time.
Definition order_type.h:189
@ MTF_WAIT_TIME
Set wait time.
Definition order_type.h:188
@ MTF_TRAVEL_SPEED
Set max travel speed.
Definition order_type.h:190
CloneOptions
Clone actions.
Definition order_type.h:195
OrderType
Order types.
Definition order_type.h:51
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:258