OpenTTD Source 20251213-master-g1091fa6071
order_base.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_BASE_H
11#define ORDER_BASE_H
12
13#include "order_type.h"
14#include "core/pool_type.hpp"
15#include "core/bitmath_func.hpp"
16#include "cargo_type.h"
17#include "depot_type.h"
18#include "station_type.h"
19#include "vehicle_type.h"
21#include "saveload/saveload.h"
22
24extern OrderListPool _orderlist_pool;
25
26template <typename, typename>
28
29/* If you change this, keep in mind that it is saved on 3 places:
30 * - Load_ORDR, all the global orders
31 * - Vehicle -> current_order
32 */
33struct Order {
34private:
35 friend struct VEHSChunkHandler;
37 /* So we can use private/protected variables in the saveload code */
38 friend class SlVehicleCommon;
39 friend class SlVehicleDisaster;
40 template <typename T>
41 friend class SlOrders;
42
43 template <typename Tcont, typename Titer>
44 friend EndianBufferWriter<Tcont, Titer> &operator <<(EndianBufferWriter<Tcont, Titer> &buffer, const Order &data);
45 friend class EndianBufferReader &operator >>(class EndianBufferReader &buffer, Order &order);
46
47 uint8_t type = 0;
48 uint8_t flags = 0;
50
52
53 uint16_t wait_time = 0;
54 uint16_t travel_time = 0;
55 uint16_t max_speed = UINT16_MAX;
56
57public:
58 Order() {}
59 Order(uint8_t type, uint8_t flags, DestinationID dest) : type(type), flags(flags), dest(dest) {}
60
66 inline bool IsType(OrderType type) const { return this->GetType() == type; }
67
72 inline OrderType GetType() const { return (OrderType)GB(this->type, 0, 4); }
73
74 void Free();
75
76 void MakeGoToStation(StationID destination);
78 void MakeGoToWaypoint(StationID destination);
79 void MakeLoading(bool ordered);
80 void MakeLeaveStation();
81 void MakeDummy();
83 void MakeImplicit(StationID destination);
84
89 inline bool IsGotoOrder() const
90 {
91 return IsType(OT_GOTO_WAYPOINT) || IsType(OT_GOTO_DEPOT) || IsType(OT_GOTO_STATION);
92 }
93
99 inline DestinationID GetDestination() const { return this->dest; }
100
106 inline void SetDestination(DestinationID destination) { this->dest = destination; }
107
113 inline bool IsRefit() const { return this->refit_cargo < NUM_CARGO || this->refit_cargo == CARGO_AUTO_REFIT; }
114
120 inline bool IsAutoRefit() const { return this->refit_cargo == CARGO_AUTO_REFIT; }
121
127 inline CargoType GetRefitCargo() const { return this->refit_cargo; }
128
129 void SetRefit(CargoType cargo);
130
135 inline bool IsFullLoadOrder() const
136 {
139 }
140
142 inline OrderLoadType GetLoadType() const { return static_cast<OrderLoadType>(GB(this->flags, 4, 3)); }
144 inline OrderUnloadType GetUnloadType() const { return static_cast<OrderUnloadType>(GB(this->flags, 0, 3)); }
146 inline OrderNonStopFlags GetNonStopType() const { return static_cast<OrderNonStopFlags>(GB(this->type, 6, 2)); }
148 inline OrderStopLocation GetStopLocation() const { return static_cast<OrderStopLocation>(GB(this->type, 4, 2)); }
150 inline OrderDepotTypeFlags GetDepotOrderType() const { return static_cast<OrderDepotTypeFlags>(GB(this->flags, 0, 3)); }
152 inline OrderDepotActionFlags GetDepotActionType() const { return static_cast<OrderDepotActionFlags>(GB(this->flags, 3, 4)); }
154 inline OrderConditionVariable GetConditionVariable() const { return static_cast<OrderConditionVariable>(GB(this->dest.value, 11, 5)); }
156 inline OrderConditionComparator GetConditionComparator() const { return static_cast<OrderConditionComparator>(GB(this->type, 5, 3)); }
158 inline VehicleOrderID GetConditionSkipToOrder() const { return this->flags; }
160 inline uint16_t GetConditionValue() const { return GB(this->dest.value, 0, 11); }
161
163 inline void SetLoadType(OrderLoadType load_type) { SB(this->flags, 4, 3, to_underlying(load_type)); }
165 inline void SetUnloadType(OrderUnloadType unload_type) { SB(this->flags, 0, 3, to_underlying(unload_type)); }
167 inline void SetNonStopType(OrderNonStopFlags non_stop_type) { SB(this->type, 6, 2, non_stop_type.base()); }
169 inline void SetStopLocation(OrderStopLocation stop_location) { SB(this->type, 4, 2, to_underlying(stop_location)); }
171 inline void SetDepotOrderType(OrderDepotTypeFlags depot_order_type) { SB(this->flags, 0, 3, depot_order_type.base()); }
173 inline void SetDepotActionType(OrderDepotActionFlags depot_service_type) { SB(this->flags, 3, 4, depot_service_type.base()); }
175 inline void SetConditionVariable(OrderConditionVariable condition_variable) { SB(this->dest.value, 11, 5, to_underlying(condition_variable)); }
177 inline void SetConditionComparator(OrderConditionComparator condition_comparator) { SB(this->type, 5, 3, to_underlying(condition_comparator)); }
179 inline void SetConditionSkipToOrder(VehicleOrderID order_id) { this->flags = order_id; }
181 inline void SetConditionValue(uint16_t value) { SB(this->dest.value, 0, 11, value); }
182
183 /* As conditional orders write their "skip to" order all over the flags, we cannot check the
184 * flags to find out if timetabling is enabled. However, as conditional orders are never
185 * autofilled we can be sure that any non-zero values for their wait_time and travel_time are
186 * explicitly set (but travel_time is actually unused for conditionals). */
187
189 inline bool IsWaitTimetabled() const { return this->IsType(OT_CONDITIONAL) ? this->wait_time > 0 : HasBit(this->flags, 3); }
191 inline bool IsTravelTimetabled() const { return this->IsType(OT_CONDITIONAL) ? this->travel_time > 0 : HasBit(this->flags, 7); }
192
194 inline uint16_t GetTimetabledWait() const { return this->IsWaitTimetabled() ? this->wait_time : 0; }
196 inline uint16_t GetTimetabledTravel() const { return this->IsTravelTimetabled() ? this->travel_time : 0; }
198 inline uint16_t GetWaitTime() const { return this->wait_time; }
200 inline uint16_t GetTravelTime() const { return this->travel_time; }
201
207 inline uint16_t GetMaxSpeed() const { return this->max_speed; }
208
210 inline void SetWaitTimetabled(bool timetabled) { if (!this->IsType(OT_CONDITIONAL)) AssignBit(this->flags, 3, timetabled); }
212 inline void SetTravelTimetabled(bool timetabled) { if (!this->IsType(OT_CONDITIONAL)) AssignBit(this->flags, 7, timetabled); }
213
218 inline void SetWaitTime(uint16_t time) { this->wait_time = time; }
219
224 inline void SetTravelTime(uint16_t time) { this->travel_time = time; }
225
231 inline void SetMaxSpeed(uint16_t speed) { this->max_speed = speed; }
232
233 bool ShouldStopAtStation(const Vehicle *v, StationID station) const;
234 bool CanLoadOrUnload() const;
235 bool CanLeaveWithCargo(bool has_cargo) const;
236
237 TileIndex GetLocation(const Vehicle *v, bool airport = false) const;
238
240 inline bool IsCompletelyTimetabled() const
241 {
242 if (!this->IsTravelTimetabled() && !this->IsType(OT_CONDITIONAL)) return false;
243 if (!this->IsWaitTimetabled() && this->IsType(OT_GOTO_STATION) &&
245 return false;
246 }
247 return true;
248 }
249
250 void AssignOrder(const Order &other);
251 bool Equals(const Order &other) const;
252
253 uint16_t MapOldOrder() const;
255};
256
259 uint32_t index = 0;
260 uint32_t next = 0;
262};
263
264OldOrderSaveLoadItem *GetOldOrder(size_t pool_index);
265OldOrderSaveLoadItem &AllocateOldOrder(size_t pool_index);
266
267void InsertOrder(Vehicle *v, Order &&new_o, VehicleOrderID sel_ord);
268void DeleteOrder(Vehicle *v, VehicleOrderID sel_ord);
269
274struct OrderList : OrderListPool::PoolItem<&_orderlist_pool> {
275private:
276 friend void AfterLoadVehiclesPhase1(bool part_of_load);
278 friend struct ORDLChunkHandler;
279 template <typename T>
280 friend class SlOrders;
281
283 uint num_vehicles = 0;
285 std::vector<Order> orders;
286 uint32_t old_order_index = 0;
287
290
291public:
294
301 {
302 this->orders.emplace_back(std::move(order));
303 this->Initialize(v);
304 }
305
306 OrderList(std::vector<Order> &&orders, Vehicle *v)
307 {
308 this->orders = std::move(orders);
309 this->Initialize(v);
310 }
311
313 {
314 this->Initialize(v);
315 }
316
319
320 void Initialize(Vehicle *v);
321
323
328 inline VehicleOrderID GetFirstOrder() const { return this->orders.empty() ? INVALID_VEH_ORDER_ID : 0; }
329
330 inline std::span<const Order> GetOrders() const { return this->orders; }
331 inline std::span<Order> GetOrders() { return this->orders; }
332
339 {
340 if (index >= this->GetNumOrders()) return nullptr;
341 return &this->orders[index];
342 }
343
345 {
346 if (index >= this->GetNumOrders()) return nullptr;
347 return &this->orders[index];
348 }
349
354 inline VehicleOrderID GetLastOrder() const { return this->orders.empty() ? INVALID_VEH_ORDER_ID : (this->GetNumOrders() - 1); }
355
363 {
364 if (this->orders.empty()) return INVALID_VEH_ORDER_ID;
365 return static_cast<VehicleOrderID>((cur + 1) % this->GetNumOrders());
366 }
367
372 inline VehicleOrderID GetNumOrders() const { return static_cast<VehicleOrderID>(std::size(this->orders)); }
373
378 inline VehicleOrderID GetNumManualOrders() const { return this->num_manual_orders; }
379
380 void GetNextStoppingStation(std::vector<StationID> &next_station, const Vehicle *v, VehicleOrderID first = INVALID_VEH_ORDER_ID, uint hops = 0) const;
382
386
391 inline bool IsShared() const { return this->num_vehicles > 1; };
392
397 inline Vehicle *GetFirstSharedVehicle() const { return this->first_shared; }
398
403 inline uint GetNumVehicles() const { return this->num_vehicles; }
404
411 inline void AddVehicle([[maybe_unused]] Vehicle *v) { ++this->num_vehicles; }
412
413 void RemoveVehicle(Vehicle *v);
414
415 bool IsCompleteTimetable() const;
416
422
428
433 inline TimerGameTick::Ticks GetTotalDuration() const { return this->total_duration; }
434
440
446
447 void FreeChain(bool keep_orderlist = false);
448
449 void DebugCheckSanity() const;
450};
451
452#endif /* ORDER_BASE_H */
Functions related to bit mathematics.
constexpr T AssignBit(T &x, const uint8_t y, bool value)
Assigns a bit in a variable.
constexpr T SB(T &x, const uint8_t s, const uint8_t n, const U d)
Set n bits in x starting at bit s to d.
static constexpr uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
Types related to cargoes...
uint8_t CargoType
Cargo slots to indicate a cargo type within a game.
Definition cargo_type.h:21
static const CargoType CARGO_AUTO_REFIT
Automatically choose cargo type when doing auto refitting.
Definition cargo_type.h:76
static const CargoType NUM_CARGO
Maximum number of cargo types in a game.
Definition cargo_type.h:73
static const CargoType CARGO_NO_REFIT
Do not refit cargo of a vehicle (used in vehicle orders and auto-replace/auto-renew).
Definition cargo_type.h:77
constexpr Tstorage base() const noexcept
Retrieve the raw value behind this bit set.
Endian-aware buffer adapter that always reads values in little endian order.
Endian-aware buffer adapter that always writes values in little endian order.
Enum-as-bit-set wrapper.
static constexpr TimerGameTick::Ticks INVALID_TICKS
Representation of an invalid number of ticks.
int32_t Ticks
The type to store ticks in.
Header files for depots (not hangars)
constexpr std::underlying_type_t< enum_type > to_underlying(enum_type e)
Implementation of std::to_underlying (from C++23)
Definition enum_type.hpp:17
void InsertOrder(Vehicle *v, Order &&new_o, VehicleOrderID sel_ord)
Insert a new order but skip the validation.
OldOrderSaveLoadItem * GetOldOrder(size_t pool_index)
Get a pointer to an old order with the given reference index.
Definition order_sl.cpp:125
void DeleteOrder(Vehicle *v, VehicleOrderID sel_ord)
Delete an order but skip the parameter validation.
OldOrderSaveLoadItem & AllocateOldOrder(size_t pool_index)
Allocate an old order with the given pool index.
Definition order_sl.cpp:137
Types related to orders.
OrderUnloadType
Unloading order types.
Definition order_type.h:67
OrderConditionVariable
Variables (of a vehicle) to 'cause' skipping on.
Definition order_type.h:128
OrderStopLocation
Where to stop the trains.
Definition order_type.h:97
@ 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.
@ FullLoadAny
Full load a single cargo of the consist.
static const VehicleOrderID INVALID_VEH_ORDER_ID
Invalid vehicle order index (sentinel)
Definition order_type.h:39
OrderConditionComparator
Comparator for the skip reasoning.
Definition order_type.h:143
OrderType
Order types.
Definition order_type.h:50
Definition of Pool, structure used to access PoolItems, and PoolItem, base structure for Vehicle,...
Functions/types related to saving and loading games.
std::span< const struct SaveLoad > SaveLoadTable
A table of SaveLoad entries.
Definition saveload.h:531
Types related to stations.
Compatibility struct to allow saveload of pool-based orders.
Definition order_base.h:258
uint32_t index
This order's index (1-based).
Definition order_base.h:259
Order order
The order data.
Definition order_base.h:261
uint32_t next
The next order index (1-based).
Definition order_base.h:260
Shared order list linking together the linked list of orders and the list of vehicles sharing this or...
Definition order_base.h:274
TimerGameTick::Ticks GetTimetableDurationIncomplete() const
Gets the known duration of the vehicles timetable even if the timetable is not complete.
Definition order_base.h:427
friend void AfterLoadVehiclesPhase1(bool part_of_load)
For instantiating the shared vehicle chain.
void DeleteOrderAt(VehicleOrderID index)
Remove an order from the order list and delete it.
std::vector< Order > orders
Orders of the order list.
Definition order_base.h:285
bool IsCompleteTimetable() const
Checks whether all orders of the list have a filled timetable.
friend SaveLoadTable GetOrderListDescription()
Saving and loading of order lists.
Definition order_sl.cpp:240
void UpdateTotalDuration(TimerGameTick::Ticks delta)
Must be called if an order's timetable is changed to update internal book keeping.
Definition order_base.h:445
uint GetNumVehicles() const
Return the number of vehicles that share this orders list.
Definition order_base.h:403
void InsertOrderAt(Order &&order, VehicleOrderID index)
Insert a new order into the order chain.
~OrderList()
Destructor.
Definition order_base.h:318
void RemoveVehicle(Vehicle *v)
Removes the vehicle from the shared order list.
uint num_vehicles
NOSAVE: Number of vehicles that share this order list.
Definition order_base.h:283
void AddVehicle(Vehicle *v)
Adds the given vehicle to this shared order list.
Definition order_base.h:411
Vehicle * GetFirstSharedVehicle() const
Get the first vehicle of this vehicle chain.
Definition order_base.h:397
void Initialize(Vehicle *v)
Recomputes everything.
TimerGameTick::Ticks timetable_duration
NOSAVE: Total timetabled duration of the order list.
Definition order_base.h:288
void UpdateTimetableDuration(TimerGameTick::Ticks delta)
Must be called if an order's timetable is changed to update internal book keeping.
Definition order_base.h:439
Vehicle * first_shared
NOSAVE: pointer to the first vehicle in the shared order chain.
Definition order_base.h:284
OrderList(Order &&order, Vehicle *v)
Create an order list with the given order chain for the given vehicle.
Definition order_base.h:300
VehicleOrderID GetFirstOrder() const
Get the first order of the order chain.
Definition order_base.h:328
TimerGameTick::Ticks GetTimetableTotalDuration() const
Gets the total duration of the vehicles timetable or Ticks::INVALID_TICKS is the timetable is not com...
Definition order_base.h:421
VehicleOrderID num_manual_orders
NOSAVE: How many manually added orders are there in the list.
Definition order_base.h:282
void MoveOrder(VehicleOrderID from, VehicleOrderID to)
Move an order to another position within the order list.
void GetNextStoppingStation(std::vector< StationID > &next_station, const Vehicle *v, VehicleOrderID first=INVALID_VEH_ORDER_ID, uint hops=0) const
Recursively determine the next deterministic station to stop at.
VehicleOrderID GetNext(VehicleOrderID cur) const
Get the order after the given one or the first one, if the given one is the last one.
Definition order_base.h:362
VehicleOrderID GetNumOrders() const
Get number of orders in the order list.
Definition order_base.h:372
void RecalculateTimetableDuration()
Recomputes Timetable duration.
void FreeChain(bool keep_orderlist=false)
Free a complete order chain.
VehicleOrderID GetNumManualOrders() const
Get number of manually added orders in the order list.
Definition order_base.h:378
VehicleOrderID GetNextDecisionNode(VehicleOrderID next, uint hops) const
Get the next order which will make the given vehicle stop at a station or refit at a depot or evaluat...
TimerGameTick::Ticks GetTotalDuration() const
Gets the known duration of the vehicles orders, timetabled or not.
Definition order_base.h:433
bool IsShared() const
Is this a shared order list?
Definition order_base.h:391
TimerGameTick::Ticks total_duration
NOSAVE: Total (timetabled or not) duration of the order list.
Definition order_base.h:289
VehicleOrderID GetLastOrder() const
Get the last order of the order chain.
Definition order_base.h:354
OrderList()
Default constructor producing an invalid order list.
Definition order_base.h:293
const Order * GetOrderAt(VehicleOrderID index) const
Get a certain order of the order chain.
Definition order_base.h:338
TileIndex GetLocation(const Vehicle *v, bool airport=false) const
Returns a tile somewhat representing the order destination (not suitable for pathfinding).
bool IsGotoOrder() const
Is this a 'goto' order with a real destination?
Definition order_base.h:89
OrderDepotTypeFlags GetDepotOrderType() const
What caused us going to the depot?
Definition order_base.h:150
uint16_t GetTimetabledTravel() const
Get the time in ticks a vehicle should take to reach the destination or 0 if it's not timetabled.
Definition order_base.h:196
OrderConditionVariable GetConditionVariable() const
What variable do we have to compare?
Definition order_base.h:154
bool Equals(const Order &other) const
Does this order have the same type, flags and destination?
uint16_t MapOldOrder() const
Pack this order into a 16 bits integer as close to the TTD representation as possible.
uint16_t GetMaxSpeed() const
Get the maxmimum speed in km-ish/h a vehicle is allowed to reach on the way to the destination.
Definition order_base.h:207
uint16_t max_speed
How fast the vehicle may go on the way to the destination.
Definition order_base.h:55
void ConvertFromOldSavegame()
Converts this order from an old savegame's version; it moves all bits to the new location.
Definition order_sl.cpp:26
void SetTravelTimetabled(bool timetabled)
Set if the travel time is explicitly timetabled (unless the order is conditional).
Definition order_base.h:212
DestinationID GetDestination() const
Gets the destination of this order.
Definition order_base.h:99
bool IsType(OrderType type) const
Check whether this order is of the given type.
Definition order_base.h:66
void SetNonStopType(OrderNonStopFlags non_stop_type)
Set whether we must stop at stations or not.
Definition order_base.h:167
VehicleOrderID GetConditionSkipToOrder() const
Get the order to skip to.
Definition order_base.h:158
OrderStopLocation GetStopLocation() const
Where must we stop at the platform?
Definition order_base.h:148
uint16_t GetWaitTime() const
Get the time in ticks a vehicle will probably wait at the destination (timetabled or not).
Definition order_base.h:198
CargoType GetRefitCargo() const
Get the cargo to to refit to.
Definition order_base.h:127
OrderType GetType() const
Get the type of order of this order.
Definition order_base.h:72
bool IsFullLoadOrder() const
Is this order a OrderLoadType::FullLoad or OrderLoadType::FullLoadAny?
Definition order_base.h:135
void MakeGoToStation(StationID destination)
Makes this order a Go To Station order.
Definition order_cmd.cpp:58
uint8_t type
The type of order + non-stop flags.
Definition order_base.h:47
uint16_t wait_time
How long in ticks to wait at the destination.
Definition order_base.h:53
void SetRefit(CargoType cargo)
Make this depot/station order also a refit order.
void SetDepotOrderType(OrderDepotTypeFlags depot_order_type)
Set the cause to go to the depot.
Definition order_base.h:171
bool IsCompletelyTimetabled() const
Checks if travel_time and wait_time apply to this order and if they are timetabled.
Definition order_base.h:240
void SetWaitTime(uint16_t time)
Set the time in ticks to wait at the destination.
Definition order_base.h:218
void SetStopLocation(OrderStopLocation stop_location)
Set where we must stop at the platform.
Definition order_base.h:169
void MakeDummy()
Makes this order a Dummy order.
void MakeGoToWaypoint(StationID destination)
Makes this order a Go To Waypoint order.
Definition order_cmd.cpp:87
void SetConditionVariable(OrderConditionVariable condition_variable)
Set variable we have to compare.
Definition order_base.h:175
OrderUnloadType GetUnloadType() const
How must the consist be unloaded?
Definition order_base.h:144
uint8_t flags
Load/unload types, depot order/action types.
Definition order_base.h:48
void MakeGoToDepot(DestinationID destination, OrderDepotTypeFlags order, OrderNonStopFlags non_stop_type=OrderNonStopFlag::NoIntermediate, OrderDepotActionFlags action={}, CargoType cargo=CARGO_NO_REFIT)
Makes this order a Go To Depot order.
Definition order_cmd.cpp:73
bool IsWaitTimetabled() const
Does this order have an explicit wait time set?
Definition order_base.h:189
void SetTravelTime(uint16_t time)
Set the time in ticks to take for travelling to the destination.
Definition order_base.h:224
friend SaveLoadTable GetOrderDescription()
Saving and loading of orders.
Definition order_sl.cpp:144
DestinationID dest
The destination of the order.
Definition order_base.h:49
void SetDestination(DestinationID destination)
Sets the destination of this order.
Definition order_base.h:106
void SetWaitTimetabled(bool timetabled)
Set if the wait time is explicitly timetabled (unless the order is conditional).
Definition order_base.h:210
bool IsTravelTimetabled() const
Does this order have an explicit travel time set?
Definition order_base.h:191
void SetConditionComparator(OrderConditionComparator condition_comparator)
Set the comparator to use.
Definition order_base.h:177
void MakeConditional(VehicleOrderID order)
Makes this order an conditional order.
void SetDepotActionType(OrderDepotActionFlags depot_service_type)
Set what we are going to do in the depot.
Definition order_base.h:173
void SetConditionSkipToOrder(VehicleOrderID order_id)
Get the order to skip to.
Definition order_base.h:179
OrderLoadType GetLoadType() const
How must the consist be loaded?
Definition order_base.h:142
OrderDepotActionFlags GetDepotActionType() const
What are we going to do when in the depot.
Definition order_base.h:152
void MakeLeaveStation()
Makes this order a Leave Station order.
bool CanLeaveWithCargo(bool has_cargo) const
A vehicle can leave the current station with cargo if:
void SetConditionValue(uint16_t value)
Set the value to base the skip on.
Definition order_base.h:181
void SetUnloadType(OrderUnloadType unload_type)
Set how the consist must be unloaded.
Definition order_base.h:165
void Free()
'Free' the order
Definition order_cmd.cpp:47
uint16_t GetTimetabledWait() const
Get the time in ticks a vehicle should wait at the destination or 0 if it's not timetabled.
Definition order_base.h:194
bool ShouldStopAtStation(const Vehicle *v, StationID station) const
Check whether the given vehicle should stop at the given station based on this order and the non-stop...
CargoType refit_cargo
Refit CargoType.
Definition order_base.h:51
uint16_t GetTravelTime() const
Get the time in ticks a vehicle will probably take to reach the destination (timetabled or not).
Definition order_base.h:200
void MakeImplicit(StationID destination)
Makes this order an implicit order.
void SetLoadType(OrderLoadType load_type)
Set how the consist must be loaded.
Definition order_base.h:163
bool IsAutoRefit() const
Is this order a auto-refit order.
Definition order_base.h:120
void AssignOrder(const Order &other)
Assign data to an order (from another order) This function makes sure that the index is maintained co...
OrderConditionComparator GetConditionComparator() const
What is the comparator to use?
Definition order_base.h:156
OrderNonStopFlags GetNonStopType() const
At which stations must we stop?
Definition order_base.h:146
bool IsRefit() const
Is this order a refit order.
Definition order_base.h:113
void MakeLoading(bool ordered)
Makes this order a Loading order.
Definition order_cmd.cpp:98
uint16_t GetConditionValue() const
Get the value to base the skip on.
Definition order_base.h:160
void SetMaxSpeed(uint16_t speed)
Set the maxmimum speed in km-ish/h a vehicle is allowed to reach on the way to the destination.
Definition order_base.h:231
uint16_t travel_time
How long in ticks the journey to this destination should take.
Definition order_base.h:54
Base class for all PoolItems.
Tindex index
Index of this pool item.
Base class for all pools.
Vehicle data structure.
Definition of the tick-based game-timer.
Types related to vehicles.