26template <
typename,
typename>
43 template <
typename Tcont,
typename Titer>
208 inline void SetWaitTime(uint16_t time) { this->wait_time = time; }
221 inline void SetMaxSpeed(uint16_t speed) { this->max_speed = speed; }
224 bool CanLoadOrUnload()
const;
269 template <
typename T>
276 uint32_t old_order_index = 0;
292 this->orders.emplace_back(std::move(order));
298 this->orders = std::move(
orders);
320 inline std::span<const Order> GetOrders()
const {
return this->
orders; }
321 inline std::span<Order> GetOrders() {
return this->
orders; }
331 return &this->orders[
index];
337 return &this->orders[
index];
381 inline bool IsShared()
const {
return this->num_vehicles > 1; };
437 void FreeChain(
bool keep_orderlist =
false);
439 void DebugCheckSanity()
const;
Functions related to bit mathematics.
debug_inline constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
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.
debug_inline static constexpr uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
Types related to cargoes...
uint8_t CargoType
Cargo slots to indicate a cargo type within a game.
static const CargoType CARGO_AUTO_REFIT
Automatically choose cargo type when doing auto refitting.
static const CargoType NUM_CARGO
Maximum number of cargo types in a game.
static const CargoType CARGO_NO_REFIT
Do not refit cargo of a vehicle (used in vehicle orders and auto-replace/auto-renew).
Endian-aware buffer adapter that always reads values in little endian order.
Endian-aware buffer adapter that always writes values in little endian order.
Minimal stack that uses a pool to avoid pointers.
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)
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.
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.
OrderConditionVariable
Variables (of a vehicle) to 'cause' skipping on.
OrderStopLocation
Where to stop the trains.
OrderUnloadFlags
Flags related to the unloading order.
OrderDepotTypeFlags
Reasons that could cause us to go to the depot.
uint8_t VehicleOrderID
The index of an order within its current vehicle (not pool related)
OrderDepotActionFlags
Actions that can be performed when the vehicle enters the depot.
@ ODATF_SERVICE_ONLY
Only service the vehicle.
OrderLoadFlags
Flags related to the loading order.
static const VehicleOrderID INVALID_VEH_ORDER_ID
Invalid vehicle order index (sentinel)
OrderConditionComparator
Comparator for the skip reasoning.
OrderNonStopFlags
Non-stop order flags.
@ ONSF_NO_STOP_AT_DESTINATION_STATION
The vehicle will stop at any station it passes except the destination.
@ ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS
The vehicle will not stop at any stations it passes except the destination.
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.
Types related to stations.
Compatibility struct to allow saveload of pool-based orders.
uint32_t index
This order's index (1-based).
Order order
The order data.
uint32_t next
The next order index (1-based).
Shared order list linking together the linked list of orders and the list of vehicles sharing this or...
StationIDStack GetNextStoppingStation(const Vehicle *v, VehicleOrderID first=INVALID_VEH_ORDER_ID, uint hops=0) const
Recursively determine the next deterministic station to stop at.
TimerGameTick::Ticks GetTimetableDurationIncomplete() const
Gets the known duration of the vehicles timetable even if the timetable is not complete.
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.
bool IsCompleteTimetable() const
Checks whether all orders of the list have a filled timetable.
friend SaveLoadTable GetOrderListDescription()
Saving and loading of order lists.
void UpdateTotalDuration(TimerGameTick::Ticks delta)
Must be called if an order's timetable is changed to update internal book keeping.
uint GetNumVehicles() const
Return the number of vehicles that share this orders list.
void InsertOrderAt(Order &&order, VehicleOrderID index)
Insert a new order into the order chain.
void RemoveVehicle(Vehicle *v)
Removes the vehicle from the shared order list.
uint num_vehicles
NOSAVE: Number of vehicles that share this order list.
void AddVehicle(Vehicle *v)
Adds the given vehicle to this shared order list.
Vehicle * GetFirstSharedVehicle() const
Get the first vehicle of this vehicle chain.
void Initialize(Vehicle *v)
Recomputes everything.
TimerGameTick::Ticks timetable_duration
NOSAVE: Total timetabled duration of the order list.
void UpdateTimetableDuration(TimerGameTick::Ticks delta)
Must be called if an order's timetable is changed to update internal book keeping.
Vehicle * first_shared
NOSAVE: pointer to the first vehicle in the shared order chain.
OrderList(Order &&order, Vehicle *v)
Create an order list with the given order chain for the given vehicle.
VehicleOrderID GetFirstOrder() const
Get the first order of the order chain.
TimerGameTick::Ticks GetTimetableTotalDuration() const
Gets the total duration of the vehicles timetable or Ticks::INVALID_TICKS is the timetable is not com...
VehicleOrderID num_manual_orders
NOSAVE: How many manually added orders are there in the list.
void MoveOrder(VehicleOrderID from, VehicleOrderID to)
Move an order to another position within the order list.
VehicleOrderID GetNext(VehicleOrderID cur) const
Get the order after the given one or the first one, if the given one is the last one.
VehicleOrderID GetNumOrders() const
Get number of orders in the order list.
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.
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.
bool IsShared() const
Is this a shared order list?
TimerGameTick::Ticks total_duration
NOSAVE: Total (timetabled or not) duration of the order list.
VehicleOrderID GetLastOrder() const
Get the last order of the order chain.
OrderList()
Default constructor producing an invalid order list.
const Order * GetOrderAt(VehicleOrderID index) const
Get a certain order of the order chain.
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?
OrderDepotTypeFlags GetDepotOrderType() const
What caused us going to the depot?
uint16_t GetTimetabledTravel() const
Get the time in ticks a vehicle should take to reach the destination or 0 if it's not timetabled.
OrderConditionVariable GetConditionVariable() const
What variable do we have to compare?
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.
void SetUnloadType(OrderUnloadFlags unload_type)
Set how the consist must be unloaded.
void SetLoadType(OrderLoadFlags load_type)
Set how the consist must be loaded.
uint16_t max_speed
How fast the vehicle may go on the way to the destination.
void ConvertFromOldSavegame()
Converts this order from an old savegame's version; it moves all bits to the new location.
void SetTravelTimetabled(bool timetabled)
Set if the travel time is explicitly timetabled (unless the order is conditional).
DestinationID GetDestination() const
Gets the destination of this order.
bool IsType(OrderType type) const
Check whether this order is of the given type.
void SetNonStopType(OrderNonStopFlags non_stop_type)
Set whether we must stop at stations or not.
VehicleOrderID GetConditionSkipToOrder() const
Get the order to skip to.
OrderStopLocation GetStopLocation() const
Where must we stop at the platform?
uint16_t GetWaitTime() const
Get the time in ticks a vehicle will probably wait at the destination (timetabled or not).
CargoType GetRefitCargo() const
Get the cargo to to refit to.
OrderType GetType() const
Get the type of order of this order.
void MakeGoToStation(StationID destination)
Makes this order a Go To Station order.
uint8_t type
The type of order + non-stop flags.
uint16_t wait_time
How long in ticks to wait at the destination.
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.
bool IsCompletelyTimetabled() const
Checks if travel_time and wait_time apply to this order and if they are timetabled.
OrderLoadFlags GetLoadType() const
How must the consist be loaded?
void SetWaitTime(uint16_t time)
Set the time in ticks to wait at the destination.
void SetStopLocation(OrderStopLocation stop_location)
Set where we must stop at the platform.
void MakeDummy()
Makes this order a Dummy order.
void MakeGoToWaypoint(StationID destination)
Makes this order a Go To Waypoint order.
void SetConditionVariable(OrderConditionVariable condition_variable)
Set variable we have to compare.
uint8_t flags
Load/unload types, depot order/action types.
bool IsWaitTimetabled() const
Does this order have an explicit wait time set?
void SetTravelTime(uint16_t time)
Set the time in ticks to take for travelling to the destination.
friend SaveLoadTable GetOrderDescription()
Saving and loading of orders.
DestinationID dest
The destination of the order.
void SetDestination(DestinationID destination)
Sets the destination of this order.
void SetWaitTimetabled(bool timetabled)
Set if the wait time is explicitly timetabled (unless the order is conditional).
bool IsTravelTimetabled() const
Does this order have an explicit travel time set?
void SetConditionComparator(OrderConditionComparator condition_comparator)
Set the comparator to use.
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.
void SetConditionSkipToOrder(VehicleOrderID order_id)
Get the order to skip to.
OrderDepotActionFlags GetDepotActionType() const
What are we going to do when in the depot.
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.
void Free()
'Free' the order
uint16_t GetTimetabledWait() const
Get the time in ticks a vehicle should wait at the destination or 0 if it's not timetabled.
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.
uint16_t GetTravelTime() const
Get the time in ticks a vehicle will probably take to reach the destination (timetabled or not).
void MakeImplicit(StationID destination)
Makes this order an implicit order.
bool IsAutoRefit() const
Is this order a auto-refit order.
OrderUnloadFlags GetUnloadType() const
How must the consist be unloaded?
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?
OrderNonStopFlags GetNonStopType() const
At which stations must we stop?
bool IsRefit() const
Is this order a refit order.
void MakeLoading(bool ordered)
Makes this order a Loading order.
uint16_t GetConditionValue() const
Get the value to base the skip on.
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.
void MakeGoToDepot(DestinationID destination, OrderDepotTypeFlags order, OrderNonStopFlags non_stop_type=ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS, OrderDepotActionFlags action=ODATF_SERVICE_ONLY, CargoType cargo=CARGO_NO_REFIT)
Makes this order a Go To Depot order.
uint16_t travel_time
How long in ticks the journey to this destination should take.
Base class for all PoolItems.
Tindex index
Index of this pool item.
Base class for all pools.
Definition of the tick-based game-timer.
Types related to vehicles.