103 inline void SetDestination(DestinationID destination) { this->dest = destination; }
218 inline void SetMaxSpeed(uint16 speed) { this->max_speed = speed; }
221 bool CanLoadOrUnload()
const;
255 friend const struct SaveLoad *GetOrderListDescription();
257 StationID GetBestLoadableNext(
const Vehicle *v,
const Order *o1,
const Order *o2)
const;
271 : first(NULL), num_orders(num_orders), num_manual_orders(0), num_vehicles(0), first_shared(NULL),
272 timetable_duration(0), total_duration(0) { }
321 const Order *GetNextDecisionNode(
const Order *
next, uint hops)
const;
323 void InsertOrderAt(
Order *new_order,
int index);
324 void DeleteOrderAt(
int index);
325 void MoveOrder(
int from,
int to);
331 inline bool IsShared()
const {
return this->num_vehicles > 1; };
345 bool IsVehicleInSharedOrdersList(
const Vehicle *v)
const;
346 int GetPositionInSharedOrderList(
const Vehicle *v)
const;
356 void RemoveVehicle(
Vehicle *v);
358 bool IsCompleteTimetable()
const;
390 void FreeChain(
bool keep_orderlist =
false);
392 void DebugCheckSanity()
const;
395 #define FOR_ALL_ORDERS_FROM(var, start) FOR_ALL_ITEMS_FROM(Order, order_index, var, start) 396 #define FOR_ALL_ORDERS(var) FOR_ALL_ORDERS_FROM(var, 0) 399 #define FOR_VEHICLE_ORDERS(v, order) for (order = (v->orders.list == NULL) ? NULL : v->orders.list->GetFirstOrder(); order != NULL; order = order->next) 402 #define FOR_ALL_ORDER_LISTS_FROM(var, start) FOR_ALL_ITEMS_FROM(OrderList, orderlist_index, var, start) 403 #define FOR_ALL_ORDER_LISTS(var) FOR_ALL_ORDER_LISTS_FROM(var, 0) OrderConditionVariable
Variables (of a vehicle) to 'cause' skipping on.
VehicleOrderID num_orders
NOSAVE: How many orders there are in the list.
uint16 DepotID
Type for the unique identifier of depots.
uint16 GetTravelTime() const
Get the time in ticks a vehicle will probably take to reach the destination (timetabled or not)...
Automatically choose cargo type when doing auto refitting.
Minimal stack that uses a pool to avoid pointers.
bool IsGotoOrder() const
Is this a 'goto' order with a real destination?
OrderConditionComparator GetConditionComparator() const
What is the comparator to use?
void SetConditionValue(uint16 value)
Set the value to base the skip on.
Ticks GetTimetableTotalDuration() const
Gets the total duration of the vehicles timetable or INVALID_TICKS is the timetable is not complete...
void UpdateTimetableDuration(Ticks delta)
Must be called if an order's timetable is changed to update internal book keeping.
VehicleOrderID GetConditionSkipToOrder() const
Get the order to skip to.
void SetWaitTime(uint16 time)
Set the time in ticks to wait at the destination.
static const VehicleOrderID INVALID_VEH_ORDER_ID
Invalid vehicle order index (sentinel)
OrderList(VehicleOrderID num_orders=INVALID_VEH_ORDER_ID)
Default constructor producing an invalid order list.
Ticks GetTotalDuration() const
Gets the known duration of the vehicles orders, timetabled or not.
void SetDepotOrderType(OrderDepotTypeFlags depot_order_type)
Set the cause to go to the depot.
static const Ticks INVALID_TICKS
Representation of an invalid number of ticks.
void SetDepotActionType(OrderDepotActionFlags depot_service_type)
Set what we are going to do in the depot.
bool IsTravelTimetabled() const
Does this order have an explicit travel time set?
void SetRefit(CargoID cargo)
Make this depot/station order also a refit order.
Only service the vehicle.
VehicleOrderID GetNumManualOrders() const
Get number of manually added orders in the order list.
Ticks total_duration
NOSAVE: Total (timetabled or not) duration of the order list.
Tindex index
Index of this pool item.
Functions related to bit mathematics.
CargoID refit_cargo
Refit CargoID.
OrderNonStopFlags
Non-stop order flags.
void SetUnloadType(OrderUnloadFlags unload_type)
Set how the consist must be unloaded.
void SetConditionComparator(OrderConditionComparator condition_comparator)
Set the comparator to use.
~Order()
Clean everything up.
uint16 MapOldOrder() const
Pack this order into a 16 bits integer as close to the TTD representation as possible.
void SetConditionVariable(OrderConditionVariable condition_variable)
Set variable we have to compare.
Vehicle * GetFirstSharedVehicle() const
Get the first vehicle of this vehicle chain.
Types related to cargoes...
Defintion of Pool, structure used to access PoolItems, and PoolItem, base structure for Vehicle...
TileIndex GetLocation(const Vehicle *v, bool airport=false) const
Returns a tile somewhat representing the order destination (not suitable for pathfinding).
bool CanLeaveWithCargo(bool has_cargo) const
A vehicle can leave the current station with cargo if:
void SetMaxSpeed(uint16 speed)
Set the maxmimum speed in km-ish/h a vehicle is allowed to reach on the way to the destination...
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.
OrderDepotActionFlags GetDepotActionType() const
What are we going to do when in the depot.
The vehicle will stop at any station it passes except the destination.
Order * next
Pointer to next order. If NULL, end of list.
bool IsAutoRefit() const
Is this order a auto-refit order.
void SetConditionSkipToOrder(VehicleOrderID order_id)
Get the order to skip to.
Ticks timetable_duration
NOSAVE: Total timetabled duration of the order list.
DestinationID dest
The destination of the order.
uint16 travel_time
How long in ticks the journey to this destination should take.
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...
Shared order list linking together the linked list of orders and the list of vehicles sharing this or...
OrderDepotTypeFlags GetDepotOrderType() const
What caused us going to the depot?
Header files for depots (not hangars)
OrderConditionVariable GetConditionVariable() const
What variable do we have to compare?
Types related to stations.
uint8 type
The type of order + non-stop flags.
void SetNonStopType(OrderNonStopFlags non_stop_type)
Set whether we must stop at stations or not.
void MakeImplicit(StationID destination)
Makes this order an implicit order.
bool IsRefit() const
Is this order a refit order.
Do not refit cargo of a vehicle (used in vehicle orders and auto-replace/auto-new).
void MakeDummy()
Makes this order a Dummy order.
VehicleType
Available vehicle types.
bool IsType(OrderType type) const
Check whether this order is of the given type.
friend const struct SaveLoad * GetOrderDescription()
Saving and loading of orders.
void DeleteOrder(Vehicle *v, VehicleOrderID sel_ord)
Delete an order but skip the parameter validation.
VehicleOrderID num_manual_orders
NOSAVE: How many manually added orders are there in the list.
void MakeLoading(bool ordered)
Makes this order a Loading order.
OrderDepotActionFlags
Actions that can be performed when the vehicle enters the depot.
uint8 flags
Load/unload types, depot order/action types.
bool IsWaitTimetabled() const
Does this order have an explicit wait time set?
uint16 GetTimetabledTravel() const
Get the time in ticks a vehicle should take to reach the destination or 0 if it's not timetabled...
bool IsShared() const
Is this a shared order list?
Order * GetFirstOrder() const
Get the first order of the order chain.
OrderConditionComparator
Comparator for the skip reasoning.
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).
bool Equals(const Order &other) const
Does this order have the same type, flags and destination?
Order * GetLastOrder() const
Get the last order of the order chain.
Order * first
First order of the order list.
Base class for all PoolItems.
friend void Load_VEHS()
Loading of ancient vehicles.
Base class for all pools.
OrderUnloadFlags GetUnloadType() const
How must the consist be unloaded?
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.
void SetLoadType(OrderLoadFlags load_type)
Set how the consist must be loaded.
Maximal number of cargo types in a game.
OrderUnloadFlags
Flags related to the unloading order.
uint16 GetWaitTime() const
Get the time in ticks a vehicle will probably wait at the destination (timetabled or not)...
void AddVehicle(Vehicle *v)
Adds the given vehicle to this shared order list.
OrderStopLocation
Where to stop the trains.
uint16 GetTimetabledWait() const
Get the time in ticks a vehicle should wait at the destination or 0 if it's not timetabled.
Ticks GetTimetableDurationIncomplete() const
Gets the known duration of the vehicles timetable even if the timetable is not complete.
DestinationID GetDestination() const
Gets the destination of this order.
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.
OrderStopLocation GetStopLocation() const
Where must we stop at the platform?
uint32 TileIndex
The index/ID of a Tile.
OrderLoadFlags
Flags related to the loading order.
void MakeLeaveStation()
Makes this order a Leave Station order.
void InsertOrder(Vehicle *v, Order *new_o, VehicleOrderID sel_ord)
Insert a new order but skip the validation.
uint num_vehicles
NOSAVE: Number of vehicles that share this order list.
uint16 wait_time
How long in ticks to wait at the destination.
int32 Ticks
The type to store ticks in.
void Free()
'Free' the order
uint16 GetConditionValue() const
Get the value to base the skip on.
Types related to vehicles.
OrderList(Order *chain, Vehicle *v)
Create an order list with the given order chain for the given vehicle.
void SetTravelTimetabled(bool timetabled)
Set if the travel time is explicitly timetabled (unless the order is conditional).
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
void AfterLoadVehicles(bool part_of_load)
Called after load to update coordinates.
void AssignOrder(const Order &other)
Assign data to an order (from another order) This function makes sure that the index is maintained co...
The vehicle will not stop at any stations 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 SetDestination(DestinationID destination)
Sets the destination of this order.
Types related to the dates in OpenTTD.
void MakeGoToWaypoint(StationID destination)
Makes this order a Go To Waypoint order.
uint GetNumVehicles() const
Return the number of vehicles that share this orders list.
byte VehicleOrderID
The index of an order within its current vehicle (not pool related)
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
uint32 Pack() const
Pack this order into a 32 bits integer, or actually only the type, flags and destination.
OrderType GetType() const
Get the type of order of this order.
byte CargoID
Cargo slots to indicate a cargo type within a game.
uint16 GetMaxSpeed() const
Get the maxmimum speed in km-ish/h a vehicle is allowed to reach 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.
friend const struct SaveLoad * GetVehicleDescription(VehicleType vt)
Saving and loading the current order of vehicles.
void SetTravelTime(uint16 time)
Set the time in ticks to take for travelling to the destination.
Vehicle * first_shared
NOSAVE: pointer to the first vehicle in the shared order chain.
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.
OrderNonStopFlags GetNonStopType() const
At which stations must we stop?
bool IsCompletelyTimetabled() const
Checks if travel_time and wait_time apply to this order and if they are timetabled.
VehicleOrderID GetNumOrders() const
Get number of orders in the order list.
void MakeGoToStation(StationID destination)
Makes this order a Go To Station order.
OrderDepotTypeFlags
Reasons that could cause us to go to the depot.
CargoID GetRefitCargo() const
Get the cargo to to refit to.