OpenTTD Source
12.0-beta2
|
Go to the documentation of this file.
104 inline void SetDestination(DestinationID destination) { this->dest = destination; }
219 inline void SetMaxSpeed(uint16 speed) { this->max_speed = speed; }
222 bool CanLoadOrUnload()
const;
258 StationID GetBestLoadableNext(
const Vehicle *v,
const Order *o1,
const Order *o2)
const;
334 inline bool IsShared()
const {
return this->num_vehicles > 1; };
393 void FreeChain(
bool keep_orderlist =
false);
Vehicle * first_shared
NOSAVE: pointer to the first vehicle in the shared order chain.
byte VehicleOrderID
The index of an order within its current vehicle (not pool related)
bool IsRefit() const
Is this order a refit order.
uint32 TileIndex
The index/ID of a Tile.
uint16 GetWaitTime() const
Get the time in ticks a vehicle will probably wait at the destination (timetabled or not).
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.
uint16 GetTimetabledWait() const
Get the time in ticks a vehicle should wait at the destination or 0 if it's not timetabled.
void SetLoadType(OrderLoadFlags load_type)
Set how the consist must be loaded.
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
Ticks GetTotalDuration() const
Gets the known duration of the vehicles orders, timetabled or not.
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.
void UpdateTimetableDuration(Ticks delta)
Must be called if an order's timetable is changed to update internal book keeping.
DestinationID GetDestination() const
Gets the destination of this order.
Ticks total_duration
NOSAVE: Total (timetabled or not) duration of the order list.
uint16 GetTimetabledTravel() const
Get the time in ticks a vehicle should take to reach the destination or 0 if it's not timetabled.
uint16 GetConditionValue() const
Get the value to base the skip on.
void MoveOrder(int from, int to)
Move an order to another position within the order list.
uint16 DepotID
Type for the unique identifier of depots.
Tindex index
Index of this pool item.
uint16 wait_time
How long in ticks to wait at the destination.
void Free()
'Free' the order
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
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?
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.
bool IsShared() const
Is this a shared order list?
Ticks GetTimetableTotalDuration() const
Gets the total duration of the vehicles timetable or INVALID_TICKS is the timetable is not complete.
void RemoveVehicle(Vehicle *v)
Removes the vehicle from the shared order list.
OrderStopLocation
Where to stop the trains.
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...
uint32 Pack() const
Pack this order into a 32 bits integer, or actually only the type, flags and destination.
Ticks timetable_duration
NOSAVE: Total timetabled duration of the order list.
void MakeGoToDepot(DepotID destination, OrderDepotTypeFlags order, OrderNonStopFlags non_stop_type=ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS, OrderDepotActionFlags action=ODATF_SERVICE_ONLY, CargoID cargo=CT_NO_REFIT)
Makes this order a Go To Depot order.
OrderType GetType() const
Get the type of order of this order.
uint16 GetMaxSpeed() const
Get the maxmimum speed in km-ish/h a vehicle is allowed to reach on the way to the destination.
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?
@ 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)
A trimmed down version of what std::span will be in C++20.
void MakeGoToWaypoint(StationID destination)
Makes this order a Go To Waypoint order.
static T SB(T &x, const uint8 s, const uint8 n, const U d)
Set n bits in x starting at bit s to d.
Vehicle * GetFirstSharedVehicle() const
Get the first vehicle of this vehicle chain.
uint16 GetTravelTime() const
Get the time in ticks a vehicle will probably take to reach the destination (timetabled or not).
void SetDestination(DestinationID destination)
Sets the destination of this order.
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 SetTravelTime(uint16 time)
Set the time in ticks to take for travelling to the destination.
void Initialize(Order *chain, Vehicle *v)
Recomputes everything.
VehicleOrderID num_manual_orders
NOSAVE: How many manually added orders are there in the list.
int32 Ticks
The type to store ticks in.
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.
int GetPositionInSharedOrderList(const Vehicle *v) const
Gets the position of the given vehicle within the shared order vehicle list.
void SetConditionValue(uint16 value)
Set the value to base the skip on.
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 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.
uint16 max_speed
How fast the vehicle may go on the way to the destination.
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.
static const Ticks INVALID_TICKS
Representation of an invalid number of ticks.
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?
@ ONSF_NO_STOP_AT_DESTINATION_STATION
The vehicle will stop at any station it passes except the destination.
void UpdateTotalDuration(Ticks delta)
Must be called if an order's timetable is changed to update internal book keeping.
void SetRefit(CargoID cargo)
Make this depot/station order also a refit order.
OrderUnloadFlags
Flags related to the unloading order.
OrderNonStopFlags
Non-stop order flags.
void DebugCheckSanity() const
Checks for internal consistency of order list.
Base class for all pools.
void SetConditionVariable(OrderConditionVariable condition_variable)
Set variable we have to compare.
CargoID refit_cargo
Refit CargoID.
void AddVehicle(Vehicle *v)
Adds the given vehicle to this shared order list.
~Order()
Clean everything up.
void RecalculateTimetableDuration()
Recomputes Timetable duration.
uint16 MapOldOrder() const
Pack this order into a 16 bits integer as close to the TTD representation as possible.
Shared order list linking together the linked list of orders and the list of vehicles sharing this or...
Ticks GetTimetableDurationIncomplete() const
Gets the known duration of the vehicles timetable even if the timetable is not complete.
void SetConditionSkipToOrder(VehicleOrderID order_id)
Get the order to skip to.
@ CT_AUTO_REFIT
Automatically choose cargo type when doing auto refitting.
Order * GetLastOrder() const
Get the last order of the order chain.
@ NUM_CARGO
Maximal number of cargo types in a game.
void SetWaitTime(uint16 time)
Set the time in ticks to wait at the destination.
void SetDepotOrderType(OrderDepotTypeFlags depot_order_type)
Set the cause to go to the depot.
bool IsAutoRefit() const
Is this order a auto-refit order.
Order * first
First order of the order list.
void SetDepotActionType(OrderDepotActionFlags depot_service_type)
Set what we are going to do in the depot.
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.
uint num_vehicles
NOSAVE: Number of vehicles that share this order list.
void SetConditionComparator(OrderConditionComparator condition_comparator)
Set the comparator to use.
byte CargoID
Cargo slots to indicate a cargo type within a game.
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).
void SetMaxSpeed(uint16 speed)
Set 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.
bool IsVehicleInSharedOrdersList(const Vehicle *v) const
Checks whether a vehicle is part of the shared vehicle chain.
uint16 travel_time
How long in ticks the journey to this destination should take.
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.
@ CT_NO_REFIT
Do not refit cargo of a vehicle (used in vehicle orders and auto-replace/auto-new).
OrderDepotActionFlags GetDepotActionType() const
What are we going to do when in the depot.
Base class for all PoolItems.
Order * next
Pointer to next order. If nullptr, end of list.
uint8 flags
Load/unload types, depot order/action types.
uint8 type
The type of order + non-stop flags.
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).