OpenTTD Source
20240917-master-g9ab0a47812
|
Go to the documentation of this file.
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;
Vehicle * first_shared
NOSAVE: pointer to the first vehicle in the shared order chain.
bool IsRefit() const
Is this order a refit order.
void MakeDummy()
Makes this order a Dummy order.
Minimal stack that uses a pool to avoid pointers.
bool IsType(OrderType type) const
Check whether this order is of the given type.
void SetLoadType(OrderLoadFlags load_type)
Set how the consist must be loaded.
uint8_t VehicleOrderID
The index of an order within its current vehicle (not pool related)
static const CargoID CARGO_NO_REFIT
Do not refit cargo of a vehicle (used in vehicle orders and auto-replace/auto-renew).
std::span< const struct SaveLoad > SaveLoadTable
A table of SaveLoad entries.
OrderLoadFlags
Flags related to the loading order.
void MakeLoading(bool ordered)
Makes this order a Loading order.
void MakeLeaveStation()
Makes this order a Leave Station order.
DestinationID GetDestination() const
Gets the destination of this order.
uint16_t GetConditionValue() const
Get the value to base the skip on.
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.
void MoveOrder(int from, int to)
Move an order to another position within the order list.
void UpdateTimetableDuration(TimerGameTick::Ticks delta)
Must be called if an order's timetable is changed to update internal book keeping.
Tindex index
Index of this pool item.
void Free()
'Free' the order
void SetTravelTimetabled(bool timetabled)
Set if the travel time is explicitly timetabled (unless the order is conditional).
OrderUnloadFlags GetUnloadType() const
How must the consist be unloaded?
std::span< const uint8_t > buffer
Reference to storage buffer.
OrderDepotTypeFlags
Reasons that could cause us to go to the depot.
friend SaveLoadTable GetOrderDescription()
Saving and loading of orders.
void AssignOrder(const Order &other)
Assign data to an order (from another order) This function makes sure that the index is maintained co...
bool IsCompleteTimetable() const
Checks whether all orders of the list have a filled timetable.
uint8_t type
The type of order + non-stop flags.
bool IsShared() const
Is this a shared order list?
void RemoveVehicle(Vehicle *v)
Removes the vehicle from the shared order list.
OrderStopLocation
Where to stop the trains.
TimerGameTick::Ticks GetTimetableDurationIncomplete() const
Gets the known duration of the vehicles timetable even if the timetable is not complete.
friend SaveLoadTable GetOrderListDescription()
Saving and loading of order lists.
OrderList(VehicleOrderID num_orders=INVALID_VEH_ORDER_ID)
Default constructor producing an invalid order 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...
OrderType GetType() const
Get the type of order of this order.
void InsertOrder(Vehicle *v, Order *new_o, VehicleOrderID sel_ord)
Insert a new order but skip the validation.
OrderStopLocation GetStopLocation() const
Where must we stop at the platform?
uint16_t wait_time
How long in ticks to wait at the destination.
void UpdateTotalDuration(TimerGameTick::Ticks delta)
Must be called if an order's timetable is changed to update internal book keeping.
@ ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS
The vehicle will not stop at any stations it passes except the destination.
OrderNonStopFlags GetNonStopType() const
At which stations must we stop?
CargoID GetRefitCargo() const
Get the cargo to to refit to.
VehicleOrderID GetNumManualOrders() const
Get number of manually added orders in the order list.
static const VehicleOrderID INVALID_VEH_ORDER_ID
Invalid vehicle order index (sentinel)
uint16_t GetTravelTime() const
Get the time in ticks a vehicle will probably take to reach the destination (timetabled or not).
void MakeGoToWaypoint(StationID destination)
Makes this order a Go To Waypoint order.
Endian-aware buffer adapter that always reads values in little endian order.
Vehicle * GetFirstSharedVehicle() const
Get the first vehicle of this vehicle chain.
void SetDestination(DestinationID destination)
Sets the destination of this order.
static constexpr TimerGameTick::Ticks INVALID_TICKS
Representation of an invalid number of ticks.
void DeleteOrder(Vehicle *v, VehicleOrderID sel_ord)
Delete an order but skip the parameter validation.
void DeleteOrderAt(int index)
Remove an order from the order list and delete it.
void Initialize(Order *chain, Vehicle *v)
Recomputes everything.
VehicleOrderID num_manual_orders
NOSAVE: How many manually added orders are there in the list.
bool IsGotoOrder() const
Is this a 'goto' order with a real destination?
OrderConditionComparator GetConditionComparator() const
What is the comparator to use?
void FreeChain(bool keep_orderlist=false)
Free a complete order chain.
void SetWaitTime(uint16_t time)
Set the time in ticks to wait at the destination.
void ConvertFromOldSavegame()
Converts this order from an old savegame's version; it moves all bits to the new location.
bool IsCompletelyTimetabled() const
Checks if travel_time and wait_time apply to this order and if they are timetabled.
void SetTravelTime(uint16_t time)
Set the time in ticks to take for travelling to the destination.
void MakeGoToStation(StationID destination)
Makes this order a Go To Station order.
StationIDStack GetNextStoppingStation(const Vehicle *v, const Order *first=nullptr, uint hops=0) const
Recursively determine the next deterministic station to stop at.
VehicleOrderID GetConditionSkipToOrder() const
Get the order to skip to.
void SetStopLocation(OrderStopLocation stop_location)
Set where we must stop at the platform.
Order * GetOrderAt(int index) const
Get a certain order of the order chain.
uint8_t flags
Load/unload types, depot order/action types.
OrderList(Order *chain, Vehicle *v)
Create an order list with the given order chain for the given vehicle.
bool IsTravelTimetabled() const
Does this order have an explicit travel time set?
constexpr T AssignBit(T &x, const uint8_t y, bool value)
Assigns a bit in a variable.
@ ONSF_NO_STOP_AT_DESTINATION_STATION
The vehicle will stop at any station it passes except the destination.
static const CargoID CARGO_AUTO_REFIT
Automatically choose cargo type when doing auto refitting.
uint16_t GetWaitTime() const
Get the time in ticks a vehicle will probably wait at the destination (timetabled or not).
uint16_t DepotID
Type for the unique identifier of depots.
void SetRefit(CargoID cargo)
Make this depot/station order also a refit order.
int32_t Ticks
The type to store ticks in.
OrderUnloadFlags
Flags related to the unloading order.
OrderNonStopFlags
Non-stop order flags.
Base class for all pools.
void SetConditionVariable(OrderConditionVariable condition_variable)
Set variable we have to compare.
TimerGameTick::Ticks GetTotalDuration() const
Gets the known duration of the vehicles orders, timetabled or not.
CargoID refit_cargo
Refit CargoID.
TimerGameTick::Ticks timetable_duration
NOSAVE: Total timetabled duration of the order list.
~Order()
Clean everything up.
void RecalculateTimetableDuration()
Recomputes Timetable duration.
uint16_t GetTimetabledTravel() const
Get the time in ticks a vehicle should take to reach the destination or 0 if it's not timetabled.
uint16_t GetTimetabledWait() const
Get the time in ticks a vehicle should wait at the destination or 0 if it's not timetabled.
Shared order list linking together the linked list of orders and the list of vehicles sharing this or...
uint16_t MapOldOrder() const
Pack this order into a 16 bits integer as close to the TTD representation as possible.
void SetConditionSkipToOrder(VehicleOrderID order_id)
Get the order to skip to.
Order * GetLastOrder() const
Get the last order of the order chain.
uint16_t max_speed
How fast the vehicle may go on the way to the destination.
uint8_t CargoID
Cargo slots to indicate a cargo type within a game.
void SetDepotOrderType(OrderDepotTypeFlags depot_order_type)
Set the cause to go to the depot.
bool IsAutoRefit() const
Is this order a auto-refit order.
uint32_t Pack() const
Pack this order into a 32 bits integer, or actually only the type, flags and destination.
Order * first
First order of the order list.
void SetDepotActionType(OrderDepotActionFlags depot_service_type)
Set what we are going to do in the depot.
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 MakeConditional(VehicleOrderID order)
Makes this order an conditional order.
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...
OrderDepotTypeFlags GetDepotOrderType() const
What caused us going to the depot?
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.
Order * GetFirstOrder() const
Get the first order of the order chain.
OrderConditionVariable GetConditionVariable() const
What variable do we have to compare?
friend void AfterLoadVehicles(bool part_of_load)
For instantiating the shared vehicle chain.
void AddVehicle([[maybe_unused]] Vehicle *v)
Adds the given vehicle to this shared order list.
uint num_vehicles
NOSAVE: Number of vehicles that share this order list.
void SetConditionComparator(OrderConditionComparator condition_comparator)
Set the comparator to use.
OrderConditionVariable
Variables (of a vehicle) to 'cause' skipping on.
uint GetNumVehicles() const
Return the number of vehicles that share this orders list.
@ ODATF_SERVICE_ONLY
Only service the vehicle.
TileIndex GetLocation(const Vehicle *v, bool airport=false) const
Returns a tile somewhat representing the order destination (not suitable for pathfinding).
Endian-aware buffer adapter that always writes values in little endian order.
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.
void SetUnloadType(OrderUnloadFlags unload_type)
Set how the consist must be unloaded.
void SetConditionValue(uint16_t value)
Set the value to base the skip on.
TimerGameTick::Ticks GetTimetableTotalDuration() const
Gets the total duration of the vehicles timetable or Ticks::INVALID_TICKS is the timetable is not com...
uint16_t travel_time
How long in ticks the journey to this destination should take.
static const CargoID NUM_CARGO
Maximum number of cargo types in a game.
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.
bool CanLeaveWithCargo(bool has_cargo) const
A vehicle can leave the current station with cargo if:
OrderDepotActionFlags
Actions that can be performed when the vehicle enters the depot.
OrderDepotActionFlags GetDepotActionType() const
What are we going to do when in the depot.
Base class for all PoolItems.
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.
Order * next
Pointer to next order. If nullptr, end of list.
TimerGameTick::Ticks total_duration
NOSAVE: Total (timetabled or not) duration of the order list.
VehicleOrderID GetNumOrders() const
Get number of orders in the order list.
bool Equals(const Order &other) const
Does this order have the same type, flags and destination?
void InsertOrderAt(Order *new_order, int index)
Insert a new order into the order chain.
bool IsWaitTimetabled() const
Does this order have an explicit wait time set?
void SetNonStopType(OrderNonStopFlags non_stop_type)
Set whether we must stop at stations or not.
DestinationID dest
The destination of the order.
void MakeImplicit(StationID destination)
Makes this order an implicit order.
OrderConditionComparator
Comparator for the skip reasoning.
VehicleOrderID num_orders
NOSAVE: How many orders there are in the list.
OrderLoadFlags GetLoadType() const
How must the consist be loaded?
void SetWaitTimetabled(bool timetabled)
Set if the wait time is explicitly timetabled (unless the order is conditional).
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.