28 template <
typename,
typename>
44 template <
typename Tcont,
typename Titer>
110 inline void SetDestination(DestinationID destination) { this->dest = destination; }
212 inline void SetWaitTime(uint16_t time) { this->wait_time = time; }
225 inline void SetMaxSpeed(uint16_t speed) { this->max_speed = speed; }
228 bool CanLoadOrUnload()
const;
247 uint32_t
Pack()
const;
338 inline bool IsShared()
const {
return this->num_vehicles > 1; };
394 void FreeChain(
bool keep_orderlist =
false);
396 void DebugCheckSanity()
const;
Functions related to bit mathematics.
constexpr debug_inline 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.
constexpr static debug_inline 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...
static const CargoID CARGO_NO_REFIT
Do not refit cargo of a vehicle (used in vehicle orders and auto-replace/auto-renew).
uint8_t CargoID
Cargo slots to indicate a cargo type within a game.
static const CargoID NUM_CARGO
Maximum number of cargo types in a game.
static const CargoID CARGO_AUTO_REFIT
Automatically choose cargo type when doing auto refitting.
Endian-aware buffer adapter that always reads values in little endian order.
std::span< const uint8_t > buffer
Reference to storage buffer.
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)
uint16_t DepotID
Type for the unique identifier of depots.
void InsertOrder(Vehicle *v, Order *new_o, VehicleOrderID sel_ord)
Insert a new order but skip the validation.
void DeleteOrder(Vehicle *v, VehicleOrderID sel_ord)
Delete an order but skip the parameter validation.
OrderDepotActionFlags
Actions that can be performed when the vehicle enters the depot.
@ ODATF_SERVICE_ONLY
Only service the vehicle.
OrderConditionComparator
Comparator for the skip reasoning.
OrderLoadFlags
Flags related to the loading order.
OrderStopLocation
Where to stop the trains.
OrderConditionVariable
Variables (of a vehicle) to 'cause' skipping on.
uint8_t VehicleOrderID
The index of an order within its current vehicle (not pool related)
OrderUnloadFlags
Flags related to the unloading order.
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.
OrderDepotTypeFlags
Reasons that could cause us to go to the depot.
static const VehicleOrderID INVALID_VEH_ORDER_ID
Invalid vehicle order index (sentinel)
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.
Shared order list linking together the linked list of orders and the list of vehicles sharing this or...
TimerGameTick::Ticks GetTimetableDurationIncomplete() const
Gets the known duration of the vehicles timetable even if the timetable is not complete.
void DeleteOrderAt(int index)
Remove an order from the order list and delete it.
friend void AfterLoadVehiclesPhase1(bool part_of_load)
For instantiating the shared vehicle chain.
OrderList(Order *chain, Vehicle *v)
Create an order list with the given order chain for the given vehicle.
StationIDStack GetNextStoppingStation(const Vehicle *v, const Order *first=nullptr, uint hops=0) const
Recursively determine the next deterministic station to stop at.
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.
const Order * GetNextDecisionNode(const Order *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...
void Initialize(Order *chain, Vehicle *v)
Recomputes everything.
Order * GetLastOrder() const
Get the last order of 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.
VehicleOrderID num_orders
NOSAVE: How many orders there are in the list.
void InsertOrderAt(Order *new_order, int index)
Insert a new order into the order chain.
Order * GetOrderAt(int index) const
Get a certain order of the order chain.
OrderList(VehicleOrderID num_orders=INVALID_VEH_ORDER_ID)
Default constructor producing an invalid order list.
void MoveOrder(int from, int to)
Move an order to another position within the order list.
TimerGameTick::Ticks timetable_duration
NOSAVE: Total timetabled duration of the order list.
Order * first
First order 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.
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.
const Order * GetNext(const Order *curr) 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.
void AddVehicle([[maybe_unused]] Vehicle *v)
Adds the given vehicle to this shared order list.
VehicleOrderID GetNumManualOrders() const
Get number of manually added orders in the order list.
Order * GetFirstOrder() const
Get the first order of the order chain.
Vehicle * GetFirstSharedVehicle() const
Get the first vehicle of this vehicle chain.
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.
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?
CargoID GetRefitCargo() const
Get the cargo to to refit to.
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).
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 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.
void MakeGoToDepot(DepotID destination, OrderDepotTypeFlags order, OrderNonStopFlags non_stop_type=ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS, OrderDepotActionFlags action=ODATF_SERVICE_ONLY, CargoID cargo=CARGO_NO_REFIT)
Makes this order a Go To Depot order.
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.
Order * next
Pointer to next order. If nullptr, end of list.
friend SaveLoadTable GetOrderDescription()
Saving and loading of orders.
DestinationID dest
The destination of the order.
~Order()
Clean everything up.
void SetDestination(DestinationID destination)
Sets the destination of this order.
void SetRefit(CargoID cargo)
Make this depot/station order also a refit order.
void SetWaitTimetabled(bool timetabled)
Set if the wait time is explicitly timetabled (unless the order is conditional).
uint32_t Pack() const
Pack this order into a 32 bits integer, or actually only the type, flags and destination.
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
CargoID refit_cargo
Refit CargoID.
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...
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.
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.