OpenTTD Source
20241121-master-g67a0fccfad
|
Utility to refresh links a consist will visit. More...
#include <refresh.h>
Data Structures | |
struct | Hop |
A hop the refresh algorithm might evaluate. More... | |
struct | RefitDesc |
Simulated cargo type and capacity for prediction of future links. More... | |
Static Public Member Functions | |
static void | Run (Vehicle *v, bool allow_merge=true, bool is_full_loading=false) |
Refresh all links the given vehicle will visit. More... | |
Protected Types | |
enum | RefreshFlags { USE_NEXT , HAS_CARGO , WAS_REFIT , RESET_REFIT , IN_AUTOREFIT } |
Various flags about properties of the last examined link that might have an influence on the next one. More... | |
typedef std::vector< RefitDesc > | RefitList |
typedef std::set< Hop > | HopSet |
Protected Member Functions | |
LinkRefresher (Vehicle *v, HopSet *seen_hops, bool allow_merge, bool is_full_loading) | |
Constructor for link refreshing algorithm. More... | |
bool | HandleRefit (CargoID refit_cargo) |
Handle refit orders by updating capacities and refit_capacities. More... | |
void | ResetRefit () |
Restore capacities and refit_capacities as vehicle might have been able to load now. | |
void | RefreshStats (const Order *cur, const Order *next) |
Refresh link stats for the given pair of orders. More... | |
const Order * | PredictNextOrder (const Order *cur, const Order *next, uint8_t flags, uint num_hops=0) |
Predict the next order the vehicle will execute and resolve conditionals by recursion and return next non-conditional order in list. More... | |
void | RefreshLinks (const Order *cur, const Order *next, uint8_t flags, uint num_hops=0) |
Iterate over orders starting at cur and next and refresh links associated with them. More... | |
Protected Attributes | |
Vehicle * | vehicle |
Vehicle for which the links should be refreshed. | |
uint | capacities [NUM_CARGO] |
Current added capacities per cargo ID in the consist. | |
RefitList | refit_capacities |
Current state of capacity remaining from previous refits versus overall capacity per vehicle in the consist. | |
HopSet * | seen_hops |
Hops already seen. If the same hop is seen twice we stop the algorithm. This is shared between all Refreshers of the same run. | |
CargoID | cargo |
Cargo given in last refit order. | |
bool | allow_merge |
If the refresher is allowed to merge or extend link graphs. | |
bool | is_full_loading |
If the vehicle is full loading. | |
|
protected |
Various flags about properties of the last examined link that might have an influence on the next one.
|
protected |
Constructor for link refreshing algorithm.
vehicle | Vehicle to refresh links for. |
seen_hops | Set of hops already seen. This is shared between this refresher and all its children. |
allow_merge | If the refresher is allowed to merge or extend link graphs. |
is_full_loading | If the vehicle is full loading. |
Definition at line 69 of file refresh.cpp.
|
protected |
Handle refit orders by updating capacities and refit_capacities.
refit_cargo | Cargo to refit to. |
Definition at line 90 of file refresh.cpp.
References cargo, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), GetBestFittingSubType(), HasBit(), Vehicle::Next(), refit_capacities, and vehicle.
|
protected |
Predict the next order the vehicle will execute and resolve conditionals by recursion and return next non-conditional order in list.
cur | Current order being evaluated. |
next | Next order to be evaluated. |
flags | RefreshFlags to give hints about the previous link and state carried over from that. |
num_hops | Number of hops already taken by recursive calls to this method. |
Definition at line 163 of file refresh.cpp.
References HasBit(), Order::IsType(), and USE_NEXT.
|
protected |
Iterate over orders starting at cur and next and refresh links associated with them.
cur and next can be equal. If they're not they must be "neighbours" in their order list, which means next must be directly reachable from cur without passing any further OT_GOTO_STATION or OT_IMPLICIT orders in between.
cur | Current order being evaluated. |
next | Next order to be checked. |
flags | RefreshFlags to give hints about the previous link and state carried over from that. |
num_hops | Number of hops already taken by recursive calls to this method. |
Definition at line 265 of file refresh.cpp.
References Order::IsType().
Referenced by Run().
Refresh link stats for the given pair of orders.
cur | Last stop where the consist could interact with cargo. |
next | Next order to be processed. |
Definition at line 201 of file refresh.cpp.
References Order::GetDestination(), and SpecializedStation< Station, false >::GetIfValid().
|
static |
Refresh all links the given vehicle will visit.
v | Vehicle to refresh links for. |
allow_merge | If the refresher is allowed to merge or extend link graphs. |
is_full_loading | If the vehicle is full loading. |
Definition at line 26 of file refresh.cpp.
References allow_merge, BaseConsist::cur_implicit_order_index, OrderList::GetNextDecisionNode(), Vehicle::GetOrder(), is_full_loading, Vehicle::last_loading_station, Vehicle::orders, RefreshLinks(), and seen_hops.