|
OpenTTD Source 20260206-master-g4d4e37dbf1
|
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 (OrderListID index) | |
| Default constructor producing an invalid order list. | |
| OrderList (OrderListID index, Order &&order, Vehicle *v) | |
| Create an order list with the order for the given vehicle. | |
| OrderList (OrderListID index, std::vector< Order > &&orders, Vehicle *v) | |
| OrderList (OrderListID index, Vehicle *v) | |
| ~OrderList () | |
| Destructor. | |
| void | Initialize (Vehicle *v) |
| Recomputes everything. | |
| void | RecalculateTimetableDuration () |
| Recomputes Timetable duration. | |
| VehicleOrderID | GetFirstOrder () const |
| Get the first order of the order chain. | |
| std::span< const Order > | GetOrders () const |
| std::span< Order > | GetOrders () |
| const Order * | GetOrderAt (VehicleOrderID index) const |
| Get a certain order of the order chain. | |
| Order * | GetOrderAt (VehicleOrderID index) |
| VehicleOrderID | GetLastOrder () const |
| Get the last order of the order chain. | |
| VehicleOrderID | GetNext (VehicleOrderID cur) 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. | |
| VehicleOrderID | GetNumManualOrders () const |
| Get number of manually added orders in the order list. | |
| void | GetNextStoppingStation (std::vector< StationID > &next_station, const Vehicle *v, VehicleOrderID first=INVALID_VEH_ORDER_ID, uint hops=0) const |
| Recursively determine the next deterministic station to stop at. | |
| VehicleOrderID | GetNextDecisionNode (VehicleOrderID 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. | |
| void | InsertOrderAt (Order &&order, VehicleOrderID index) |
| Insert a new order into the order chain. | |
| void | DeleteOrderAt (VehicleOrderID index) |
| Remove an order from the order list and delete it. | |
| void | MoveOrder (VehicleOrderID from, VehicleOrderID to) |
| Move an order to another position within the order list. | |
| bool | IsShared () const |
| Is this a shared order list? | |
| Vehicle * | GetFirstSharedVehicle () const |
| Get the first vehicle of this vehicle chain. | |
| uint | GetNumVehicles () const |
| Return the number of vehicles that share this orders list. | |
| void | AddVehicle (Vehicle *v) |
| Adds the given vehicle to this shared order list. | |
| void | RemoveVehicle (Vehicle *v) |
| Removes the vehicle from the shared order list. | |
| bool | IsCompleteTimetable () const |
| Checks whether all orders of the list have a filled timetable. | |
| TimerGameTick::Ticks | GetTimetableTotalDuration () const |
| Gets the total duration of the vehicles timetable or Ticks::INVALID_TICKS is the timetable is not complete. | |
| TimerGameTick::Ticks | GetTimetableDurationIncomplete () const |
| Gets the known duration of the vehicles timetable even if the timetable is not complete. | |
| TimerGameTick::Ticks | GetTotalDuration () const |
| Gets the known duration of the vehicles orders, timetabled or not. | |
| void | UpdateTimetableDuration (TimerGameTick::Ticks delta) |
| Must be called if an order's timetable is changed to update internal book keeping. | |
| void | UpdateTotalDuration (TimerGameTick::Ticks delta) |
| Must be called if an order's timetable is changed to update internal book keeping. | |
| void | FreeChain (bool keep_orderlist=false) |
| Free a complete order chain. | |
| void | DebugCheckSanity () const |
Private Attributes | |
| VehicleOrderID | num_manual_orders = 0 |
| NOSAVE: How many manually added orders are there in the list. | |
| uint | num_vehicles = 0 |
| NOSAVE: Number of vehicles that share this order list. | |
| Vehicle * | first_shared = nullptr |
| NOSAVE: pointer to the first vehicle in the shared order chain. | |
| std::vector< Order > | orders |
| Orders of the order list. | |
| uint32_t | old_order_index = 0 |
| TimerGameTick::Ticks | timetable_duration {} |
| NOSAVE: Total timetabled duration of the order list. | |
| TimerGameTick::Ticks | total_duration {} |
| NOSAVE: Total (timetabled or not) duration of the order list. | |
Friends | |
| struct | ORDLChunkHandler |
| template<typename T> | |
| class | SlOrders |
| void | AfterLoadVehiclesPhase1 (bool part_of_load) |
| For instantiating the shared vehicle chain. | |
| SaveLoadTable | GetOrderListDescription () |
| Saving and loading of order lists. | |
Shared order list linking together the linked list of orders and the list of vehicles sharing this order list.
Definition at line 274 of file order_base.h.
|
inline |
Default constructor producing an invalid order list.
Definition at line 293 of file order_base.h.
Referenced by GetOrderListDescription.
Create an order list with the order for the given vehicle.
| index | index of the list within the order list pool |
| order | Rvalue reference to the order. |
| v | any vehicle using this orderlist |
Definition at line 301 of file order_base.h.
References Initialize().
Definition at line 307 of file order_base.h.
|
inline |
Definition at line 313 of file order_base.h.
|
inline |
Destructor.
Invalidates OrderList for re-usage by the pool.
Definition at line 319 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 412 of file order_base.h.
Referenced by Vehicle::AddToShared().
| void OrderList::DeleteOrderAt | ( | VehicleOrderID | 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 439 of file order_cmd.cpp.
References num_manual_orders, orders, timetable_duration, and total_duration.
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 292 of file order_cmd.cpp.
References InvalidateWindowClassesData(), num_manual_orders, orders, BaseStation::owner, OWNER_NONE, timetable_duration, and WC_STATION_LIST.
Referenced by DeleteVehicleOrders().
|
inline |
Get the first order of the order chain.
Definition at line 329 of file order_base.h.
References INVALID_VEH_ORDER_ID.
Referenced by GetNextStoppingStation().
|
inline |
Get the first vehicle of this vehicle chain.
Definition at line 398 of file order_base.h.
Referenced by CmdSetTimetableStart().
|
inline |
Get the last order of the order chain.
Definition at line 355 of file order_base.h.
References GetNumOrders(), and INVALID_VEH_ORDER_ID.
|
inline |
Get the order after the given one or the first one, if the given one is the last one.
| cur | Order to find the next one for. |
Definition at line 363 of file order_base.h.
References GetNumOrders(), and INVALID_VEH_ORDER_ID.
Referenced by CheckAircraftOrderDistance(), DrawOrderString(), TimetableWindow::DrawTimetablePanel(), FillTimetableArrivalDepartureTable(), GetNextDecisionNode(), GetNextStoppingStation(), GetOrderDistance(), and LinkRefresher::PredictNextOrder().
| VehicleOrderID OrderList::GetNextDecisionNode | ( | VehicleOrderID | 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.
| next | The order to start looking at. |
| hops | The number of orders we have already looked at. |
Definition at line 326 of file order_cmd.cpp.
References Order::GetConditionSkipToOrder(), Order::GetConditionVariable(), Order::GetDepotActionType(), GetNext(), GetNextDecisionNode(), GetNumOrders(), Halt, INVALID_VEH_ORDER_ID, Order::IsRefit(), Order::IsType(), orders, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), and Unconditionally.
Referenced by GetNextDecisionNode(), GetNextStoppingStation(), LinkRefresher::PredictNextOrder(), and LinkRefresher::Run().
| void OrderList::GetNextStoppingStation | ( | std::vector< StationID > & | next_station, |
| const Vehicle * | v, | ||
| VehicleOrderID | first = INVALID_VEH_ORDER_ID, | ||
| uint | hops = 0 ) const |
Recursively determine the next deterministic station to stop at.
| next_station | The next stations that we have already seen, and might be adding to. |
| v | The vehicle we're looking at. |
| first | Order to start searching at or INVALID_VEH_ORDER_ID to start at cur_implicit_order_index + 1. |
| hops | Number of orders we have already looked at. |
Definition at line 363 of file order_cmd.cpp.
References BaseConsist::cur_implicit_order_index, GetFirstOrder(), GetNext(), GetNextDecisionNode(), GetNextStoppingStation(), GetNumOrders(), INVALID_VEH_ORDER_ID, Vehicle::last_station_visited, orders, Transfer, and Unload.
Referenced by GetNextStoppingStation().
|
inline |
Get number of manually added orders in the order list.
Definition at line 379 of file order_base.h.
|
inline |
Get number of orders in the order list.
Definition at line 373 of file order_base.h.
Referenced by CheckAircraftOrderDistance(), CmdCloneOrder(), GetIncompatibleRefitOrderIdForAutoreplace(), GetLastOrder(), GetNext(), GetNextDecisionNode(), GetNextStoppingStation(), GetOrderAt(), MoveOrder(), LinkRefresher::PredictNextOrder(), and LinkRefresher::RefreshLinks().
|
inline |
Return the number of vehicles that share this orders list.
Definition at line 404 of file order_base.h.
|
inline |
Definition at line 345 of file order_base.h.
|
inline |
Get a certain order of the order chain.
| index | zero-based index of the order within the chain. |
Definition at line 339 of file order_base.h.
References GetNumOrders().
Referenced by GetIncompatibleRefitOrderIdForAutoreplace(), and LinkRefresher::RefreshLinks().
|
inline |
Definition at line 332 of file order_base.h.
|
inline |
Definition at line 331 of file order_base.h.
|
inline |
Gets the known duration of the vehicles timetable even if the timetable is not complete.
Definition at line 428 of file order_base.h.
Referenced by TimetableWindow::DrawArrivalDeparturePanel(), and TimetableWindow::DrawSummaryPanel().
|
inline |
Gets the total duration of the vehicles timetable or Ticks::INVALID_TICKS is the timetable is not complete.
Definition at line 422 of file order_base.h.
References Ticks::INVALID_TICKS, and IsCompleteTimetable().
Referenced by CmdSetTimetableStart(), and UpdateVehicleTimetable().
|
inline |
Gets the known duration of the vehicles orders, timetabled or not.
Definition at line 434 of file order_base.h.
| void OrderList::Initialize | ( | Vehicle * | v | ) |
Recomputes everything.
| v | one of vehicle that is using this orderlist |
Definition at line 252 of file order_cmd.cpp.
References first_shared, Vehicle::NextShared(), num_manual_orders, num_vehicles, orders, RecalculateTimetableDuration(), timetable_duration, and total_duration.
Referenced by OrderList().
| void OrderList::InsertOrderAt | ( | Order && | order, |
| VehicleOrderID | index ) |
Insert a new order into the order chain.
| order | Rvalue reference of the order to insert into the chain. |
| index | is the position where the order is supposed to be inserted. |
Definition at line 417 of file order_cmd.cpp.
References InvalidateWindowClassesData(), num_manual_orders, orders, BaseStation::owner, OWNER_NONE, timetable_duration, total_duration, and WC_STATION_LIST.
Referenced by InsertOrder().
| bool OrderList::IsCompleteTimetable | ( | ) | const |
Checks whether all orders of the list have a filled timetable.
Definition at line 486 of file order_cmd.cpp.
References orders.
Referenced by CmdSetTimetableStart(), and GetTimetableTotalDuration().
|
inline |
Is this a shared order list?
Definition at line 392 of file order_base.h.
Referenced by CmdCloneOrder().
| void OrderList::MoveOrder | ( | VehicleOrderID | from, |
| VehicleOrderID | 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 457 of file order_cmd.cpp.
References GetNumOrders(), and orders.
Referenced by CmdMoveOrder().
| void OrderList::RecalculateTimetableDuration | ( | ) |
Recomputes Timetable duration.
Split out into a separate function so it can be used by afterload.
Definition at line 279 of file order_cmd.cpp.
References orders, and timetable_duration.
Referenced by Initialize().
| void OrderList::RemoveVehicle | ( | Vehicle * | v | ) |
Removes the vehicle from the shared order list.
| v | vehicle to remove from the list |
Definition at line 476 of file order_cmd.cpp.
References first_shared, Vehicle::NextShared(), and num_vehicles.
|
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 440 of file order_base.h.
Referenced by ChangeTimetable().
|
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 446 of file order_base.h.
Referenced by ChangeTimetable().
|
friend |
For instantiating the shared vehicle chain.
Definition at line 256 of file vehicle_sl.cpp.
References _age_cargo_skip_counter, CheckValidVehicles(), CompanyServiceInterval(), GetOldOrder(), GetStartTickFromDate(), IsSavegameVersionBefore(), Vehicle::Next(), Vehicle::next_shared, orders, VehicleDefaultSettings::servint_ispercent, CompanyProperties::settings, SlErrorCorrupt(), SLV_105, SLV_157, SLV_160, SLV_162, SLV_180, SLV_5, SLV_SHIP_ROTATION, SLV_TIMETABLE_START_TICKS, SLV_VEHICLE_ECONOMY_AGE, VEH_DISASTER, and CompanySettings::vehicle.
|
friend |
Saving and loading of order lists.
Definition at line 240 of file order_sl.cpp.
References GetOrderListDescription, OrderList(), SL_MAX_VERSION, SL_MIN_VERSION, SLE_CONDVARNAME, SLEG_CONDSTRUCTLIST, SLV_69, and SLV_ORDERS_OWNED_BY_ORDERLIST.
Referenced by GetOrderListDescription.
|
friend |
Definition at line 278 of file order_base.h.
|
friend |
Definition at line 280 of file order_base.h.
|
private |
NOSAVE: pointer to the first vehicle in the shared order chain.
Definition at line 284 of file order_base.h.
Referenced by Initialize(), and RemoveVehicle().
|
private |
NOSAVE: How many manually added orders are there in the list.
Definition at line 282 of file order_base.h.
Referenced by DeleteOrderAt(), FreeChain(), Initialize(), and InsertOrderAt().
|
private |
NOSAVE: Number of vehicles that share this order list.
Definition at line 283 of file order_base.h.
Referenced by Initialize(), and RemoveVehicle().
|
private |
Definition at line 286 of file order_base.h.
|
private |
Orders of the order list.
Definition at line 285 of file order_base.h.
Referenced by AfterLoadVehiclesPhase1, DeleteOrderAt(), FreeChain(), GetNextDecisionNode(), GetNextStoppingStation(), Initialize(), InsertOrderAt(), IsCompleteTimetable(), MoveOrder(), and RecalculateTimetableDuration().
|
private |
NOSAVE: Total timetabled duration of the order list.
Definition at line 288 of file order_base.h.
Referenced by DeleteOrderAt(), FreeChain(), Initialize(), InsertOrderAt(), and RecalculateTimetableDuration().
|
private |
NOSAVE: Total (timetabled or not) duration of the order list.
Definition at line 289 of file order_base.h.
Referenced by DeleteOrderAt(), Initialize(), and InsertOrderAt().