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