OpenTTD
|
Shared order list linking together the linked list of orders and the list of vehicles sharing this order list. More...
#include <order_base.h>
Public Member Functions | |
OrderList (VehicleOrderID num_orders=INVALID_VEH_ORDER_ID) | |
Default constructor producing an invalid order list. More... | |
OrderList (Order *chain, Vehicle *v) | |
Create an order list with the given order chain for the given vehicle. More... | |
~OrderList () | |
Destructor. More... | |
void | Initialize (Order *chain, Vehicle *v) |
Recomputes everything. More... | |
Order * | GetFirstOrder () const |
Get the first order of the order chain. More... | |
Order * | GetOrderAt (int index) const |
Get a certain order of the order chain. More... | |
Order * | GetLastOrder () const |
Get the last order of the order chain. More... | |
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. More... | |
VehicleOrderID | GetNumOrders () const |
Get number of orders in the order list. More... | |
VehicleOrderID | GetNumManualOrders () const |
Get number of manually added orders in the order list. More... | |
StationIDStack | GetNextStoppingStation (const Vehicle *v, const Order *first=NULL, uint hops=0) const |
Recursively determine the next deterministic station to stop at. More... | |
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 evaluate a non-trivial condition. More... | |
void | InsertOrderAt (Order *new_order, int index) |
Insert a new order into the order chain. More... | |
void | DeleteOrderAt (int index) |
Remove an order from the order list and delete it. More... | |
void | MoveOrder (int from, int to) |
Move an order to another position within the order list. More... | |
bool | IsShared () const |
Is this a shared order list? More... | |
Vehicle * | GetFirstSharedVehicle () const |
Get the first vehicle of this vehicle chain. More... | |
uint | GetNumVehicles () const |
Return the number of vehicles that share this orders list. More... | |
bool | IsVehicleInSharedOrdersList (const Vehicle *v) const |
Checks whether a vehicle is part of the shared vehicle chain. More... | |
int | GetPositionInSharedOrderList (const Vehicle *v) const |
Gets the position of the given vehicle within the shared order vehicle list. More... | |
void | AddVehicle (Vehicle *v) |
Adds the given vehicle to this shared order list. More... | |
void | RemoveVehicle (Vehicle *v) |
Removes the vehicle from the shared order list. More... | |
bool | IsCompleteTimetable () const |
Checks whether all orders of the list have a filled timetable. More... | |
Ticks | GetTimetableTotalDuration () const |
Gets the total duration of the vehicles timetable or INVALID_TICKS is the timetable is not complete. More... | |
Ticks | GetTimetableDurationIncomplete () const |
Gets the known duration of the vehicles timetable even if the timetable is not complete. More... | |
Ticks | GetTotalDuration () const |
Gets the known duration of the vehicles orders, timetabled or not. More... | |
void | UpdateTimetableDuration (Ticks delta) |
Must be called if an order's timetable is changed to update internal book keeping. More... | |
void | UpdateTotalDuration (Ticks delta) |
Must be called if an order's timetable is changed to update internal book keeping. More... | |
void | FreeChain (bool keep_orderlist=false) |
Free a complete order chain. More... | |
void | DebugCheckSanity () const |
Checks for internal consistency of order list. More... | |
![]() | |
void * | operator new (size_t size) |
Allocates space for new Titem. More... | |
void * | operator new (size_t size, size_t index) |
Allocates space for new Titem with given index. More... | |
void * | operator new (size_t size, void *ptr) |
Allocates space for new Titem at given memory address. More... | |
void | operator delete (void *p) |
Marks Titem as free. More... | |
Private Member Functions | |
StationID | GetBestLoadableNext (const Vehicle *v, const Order *o1, const Order *o2) const |
Private Attributes | |
Order * | first |
First order of the order list. | |
VehicleOrderID | num_orders |
NOSAVE: How many orders there are in the list. | |
VehicleOrderID | num_manual_orders |
NOSAVE: How many manually added orders are there in the list. | |
uint | num_vehicles |
NOSAVE: Number of vehicles that share this order list. | |
Vehicle * | first_shared |
NOSAVE: pointer to the first vehicle in the shared order chain. | |
Ticks | timetable_duration |
NOSAVE: Total timetabled duration of the order list. | |
Ticks | total_duration |
NOSAVE: Total (timetabled or not) duration of the order list. | |
Friends | |
void | AfterLoadVehicles (bool part_of_load) |
For instantiating the shared vehicle chain. | |
const struct SaveLoad * | GetOrderListDescription () |
Saving and loading of order lists. | |
Additional Inherited Members | |
![]() | |
static bool | CanAllocateItem (size_t n=1) |
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function() More... | |
static bool | CleaningPool () |
Returns current state of pool cleaning - yes or no. More... | |
static bool | IsValidID (size_t index) |
Tests whether given index can be used to get valid (non-NULL) Titem. More... | |
static Titem * | Get (size_t index) |
Returns Titem with given index. More... | |
static Titem * | GetIfValid (size_t index) |
Returns Titem with given index. More... | |
static size_t | GetPoolSize () |
Returns first unused index. More... | |
static size_t | GetNumItems () |
Returns number of valid items in the pool. More... | |
static void | PostDestructor (size_t index) |
Dummy function called after destructor of each member. More... | |
![]() | |
Tindex | index |
Index of this pool item. | |
Shared order list linking together the linked list of orders and the list of vehicles sharing this order list.
Definition at line 252 of file order_base.h.
|
inline |
Default constructor producing an invalid order list.
Definition at line 270 of file order_base.h.
Create an order list with the given order chain for the given vehicle.
chain | pointer to the first order of the order chain |
v | any vehicle using this orderlist |
Definition at line 279 of file order_base.h.
|
inline |
Destructor.
Invalidates OrderList for re-usage by the pool.
Definition at line 282 of file order_base.h.
|
inline |
Adds the given vehicle to this shared order list.
v | vehicle to add to the list |
Definition at line 354 of file order_base.h.
void OrderList::DebugCheckSanity | ( | ) | const |
Checks for internal consistency of order list.
Triggers assertion if something is wrong.
Definition at line 605 of file order_cmd.cpp.
References DEBUG, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_order_pool >::index, and Order::next.
void OrderList::DeleteOrderAt | ( | int | index | ) |
Remove an order from the order list and delete it.
index | is the position of the order which is to be deleted. |
Definition at line 499 of file order_cmd.cpp.
References Order::IsType(), and Order::next.
Referenced by DeleteOrder().
void OrderList::FreeChain | ( | bool | keep_orderlist = false | ) |
Free a complete order chain.
keep_orderlist | If this is true only delete the orders, otherwise also delete the OrderList. |
Definition at line 323 of file order_cmd.cpp.
References Order::next.
Referenced by DeleteVehicleOrders().
|
inline |
Get the first order of the order chain.
Definition at line 290 of file order_base.h.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_order_pool >::index.
|
inline |
Get the first vehicle of this vehicle chain.
Definition at line 337 of file order_base.h.
Referenced by CmdSetTimetableStart().
|
inline |
Get the last order of the order chain.
Definition at line 298 of file order_base.h.
Get the order after the given one or the first one, if the given one is the last one.
curr | Order to find the next one for. |
Definition at line 306 of file order_base.h.
References Order::next.
Get the next order which will make the given vehicle stop at a station or refit at a depot or evaluate a non-trivial condition.
next | The order to start looking at. |
hops | The number of orders we have already looked at. |
Definition at line 369 of file order_cmd.cpp.
References Order::IsType().
Referenced by LinkRefresher::Run().
StationIDStack OrderList::GetNextStoppingStation | ( | const Vehicle * | v, |
const Order * | first = NULL , |
||
uint | hops = 0 |
||
) | const |
Recursively determine the next deterministic station to stop at.
v | The vehicle we're looking at. |
first | Order to start searching at or NULL to start at cur_implicit_order_index + 1. |
hops | Number of orders we have already looked at. |
Definition at line 404 of file order_cmd.cpp.
References BaseConsist::cur_implicit_order_index, and Order::next.
|
inline |
Get number of manually added orders in the order list.
Definition at line 318 of file order_base.h.
References Order::next.
|
inline |
Get number of orders in the order list.
Definition at line 312 of file order_base.h.
Referenced by CmdSellVehicle().
|
inline |
Return the number of vehicles that share this orders list.
Definition at line 343 of file order_base.h.
Order * OrderList::GetOrderAt | ( | int | index | ) | const |
Get a certain order of the order chain.
index | zero-based index of the order within the chain. |
Definition at line 346 of file order_cmd.cpp.
References Order::next.
int OrderList::GetPositionInSharedOrderList | ( | const Vehicle * | v | ) | const |
Gets the position of the given vehicle within the shared order vehicle list.
v | is the vehicle of which to get the position |
Definition at line 581 of file order_cmd.cpp.
References Vehicle::PreviousShared().
|
inline |
Gets the known duration of the vehicles timetable even if the timetable is not complete.
Definition at line 370 of file order_base.h.
|
inline |
Gets the total duration of the vehicles timetable or INVALID_TICKS is the timetable is not complete.
Definition at line 364 of file order_base.h.
References INVALID_TICKS.
Referenced by CmdSetTimetableStart().
|
inline |
Gets the known duration of the vehicles orders, timetabled or not.
Definition at line 376 of file order_base.h.
Recomputes everything.
chain | first order in the chain |
v | one of vehicle that is using this orderlist |
Definition at line 292 of file order_cmd.cpp.
References Order::next.
void OrderList::InsertOrderAt | ( | Order * | new_order, |
int | index | ||
) |
Insert a new order into the order chain.
new_order | is the order to insert into the chain. |
index | is the position where the order is supposed to be inserted. |
Definition at line 461 of file order_cmd.cpp.
References Order::IsType(), and Order::next.
Referenced by InsertOrder().
bool OrderList::IsCompleteTimetable | ( | ) | const |
Checks whether all orders of the list have a filled timetable.
Definition at line 592 of file order_cmd.cpp.
References Order::next.
Referenced by CmdSetTimetableStart().
|
inline |
Is this a shared order list?
Definition at line 331 of file order_base.h.
Referenced by CmdSellVehicle().
bool OrderList::IsVehicleInSharedOrdersList | ( | const Vehicle * | v | ) | const |
Checks whether a vehicle is part of the shared vehicle chain.
v | is the vehicle to search in the shared vehicle chain. |
Definition at line 567 of file order_cmd.cpp.
References Vehicle::NextShared().
void OrderList::MoveOrder | ( | int | from, |
int | to | ||
) |
Move an order to another position within the order list.
from | is the zero-based position of the order to move. |
to | is the zero-based position where the order is moved to. |
Definition at line 525 of file order_cmd.cpp.
References Order::next.
Referenced by CmdMoveOrder().
void OrderList::RemoveVehicle | ( | Vehicle * | v | ) |
Removes the vehicle from the shared order list.
v | vehicle to remove from the list |
Definition at line 557 of file order_cmd.cpp.
References Vehicle::NextShared().
|
inline |
Must be called if an order's timetable is changed to update internal book keeping.
delta | By how many ticks has the timetable duration changed |
Definition at line 382 of file order_base.h.
|
inline |
Must be called if an order's timetable is changed to update internal book keeping.
delta | By how many ticks has the total duration changed |
Definition at line 388 of file order_base.h.