OpenTTD Source
20240919-master-gdf0233f4c2
|
Go to the documentation of this file.
13 #include "../cargo_type.h"
14 #include "../vehicle_base.h"
65 Hop() {NOT_REACHED();}
77 typedef std::vector<RefitDesc> RefitList;
78 typedef std::set<Hop> HopSet;
OrderID from
Last order where vehicle could interact with cargo or absolute first order.
CargoID cargo
Cargo the consist is probably carrying or INVALID_CARGO if unknown.
OrderID to
Next order to be processed.
@ IN_AUTOREFIT
Currently doing an autorefit loop. Ignore the first autorefit order.
RefreshFlags
Various flags about properties of the last examined link that might have an influence on the next one...
@ USE_NEXT
There was a conditional jump. Try to use the given next order when looking for a new one.
uint16_t capacity
Capacity the vehicle will have.
CargoID cargo
Cargo given in last refit order.
LinkRefresher(Vehicle *v, HopSet *seen_hops, bool allow_merge, bool is_full_loading)
Constructor for link refreshing algorithm.
uint capacities[NUM_CARGO]
Current added capacities per cargo ID in the consist.
Hop()
Default constructor should not be called but has to be visible for usage in std::set.
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.
Vehicle * vehicle
Vehicle for which the links should be refreshed.
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...
Utility to refresh links a consist will visit.
Hop(OrderID from, OrderID to, CargoID cargo)
Real constructor, only use this one.
bool HandleRefit(CargoID refit_cargo)
Handle refit orders by updating capacities and refit_capacities.
HopSet * seen_hops
Hops already seen. If the same hop is seen twice we stop the algorithm. This is shared between all Re...
bool allow_merge
If the refresher is allowed to merge or extend link graphs.
uint16_t remaining
Capacity remaining from before the previous refit.
bool is_full_loading
If the vehicle is full loading.
@ RESET_REFIT
Consist had a chance to load since the last refit and the refit capacities can be reset.
void RefreshStats(const Order *cur, const Order *next)
Refresh link stats for the given pair of orders.
CargoID cargo
Cargo type the vehicle will be carrying.
RefitList refit_capacities
Current state of capacity remaining from previous refits versus overall capacity per vehicle in the c...
A hop the refresh algorithm might evaluate.
uint8_t CargoID
Cargo slots to indicate a cargo type within a game.
static void Run(Vehicle *v, bool allow_merge=true, bool is_full_loading=false)
Refresh all links the given vehicle will visit.
void ResetRefit()
Restore capacities and refit_capacities as vehicle might have been able to load now.
@ HAS_CARGO
Consist could leave the last stop where it could interact with cargo carrying cargo (i....
@ WAS_REFIT
Consist was refit since the last stop where it could interact with cargo.
static const CargoID NUM_CARGO
Maximum number of cargo types in a game.
Simulated cargo type and capacity for prediction of future links.
bool operator<(const Hop &other) const
Comparison operator to allow hops to be used in a std::set.