* Constructor for link refreshing algorithm. * @param vehicle Vehicle to refresh links for. * @param seen_hops Set of hops already seen. This is shared between this * refresher and all its children. * @param allow_merge If the refresher is allowed to merge or extend link graphs. * @param is_full_loading If the vehicle is full loading. */
| 47 | * @param is_full_loading If the vehicle is full loading. |
| 48 | */ |
| 49 | LinkRefresher::LinkRefresher(Vehicle *vehicle, HopSet *seen_hops, bool allow_merge, bool is_full_loading) : |
| 50 | vehicle(vehicle), seen_hops(seen_hops), cargo(INVALID_CARGO), allow_merge(allow_merge), |
| 51 | is_full_loading(is_full_loading) |
| 52 | { |
| 53 | /* Assemble list of capacities and set last loading stations to 0. */ |
| 54 | for (Vehicle *v = this->vehicle; v != nullptr; v = v->Next()) { |
| 55 | this->refit_capacities.push_back(RefitDesc(v->cargo_type, v->cargo_cap, v->refit_cap)); |
| 56 | if (v->refit_cap > 0) { |
| 57 | assert(v->cargo_type < NUM_CARGO); |
| 58 | this->capacities[v->cargo_type] += v->refit_cap; |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Handle refit orders by updating capacities and refit_capacities. |