|
|
@ -72,10 +72,17 @@ LinkRefresher::LinkRefresher(Vehicle *vehicle, HopSet *seen_hops, bool allow_mer
|
|
|
|
vehicle(vehicle), seen_hops(seen_hops), cargo(CT_INVALID), allow_merge(allow_merge),
|
|
|
|
vehicle(vehicle), seen_hops(seen_hops), cargo(CT_INVALID), allow_merge(allow_merge),
|
|
|
|
is_full_loading(is_full_loading)
|
|
|
|
is_full_loading(is_full_loading)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
for (CargoID cargo_type = 0; cargo_type < NUM_CARGO; cargo_type++) {
|
|
|
|
|
|
|
|
this->capacities[cargo_type] = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Assemble list of capacities and set last loading stations to 0. */
|
|
|
|
/* Assemble list of capacities and set last loading stations to 0. */
|
|
|
|
for (Vehicle *v = this->vehicle; v != NULL; v = v->Next()) {
|
|
|
|
for (Vehicle *v = this->vehicle; v != NULL; v = v->Next()) {
|
|
|
|
this->refit_capacities.push_back(RefitDesc(v->cargo_type, v->cargo_cap, v->refit_cap));
|
|
|
|
this->refit_capacities.push_back(RefitDesc(v->cargo_type, v->cargo_cap, v->refit_cap));
|
|
|
|
if (v->refit_cap > 0) this->capacities[v->cargo_type] += v->refit_cap;
|
|
|
|
if (v->refit_cap > 0) {
|
|
|
|
|
|
|
|
assert(v->cargo_type < NUM_CARGO);
|
|
|
|
|
|
|
|
this->capacities[v->cargo_type] += v->refit_cap;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -200,11 +207,12 @@ void LinkRefresher::RefreshStats(const Order *cur, const Order *next)
|
|
|
|
StationID next_station = next->GetDestination();
|
|
|
|
StationID next_station = next->GetDestination();
|
|
|
|
Station *st = Station::GetIfValid(cur->GetDestination());
|
|
|
|
Station *st = Station::GetIfValid(cur->GetDestination());
|
|
|
|
if (st != NULL && next_station != INVALID_STATION && next_station != st->index) {
|
|
|
|
if (st != NULL && next_station != INVALID_STATION && next_station != st->index) {
|
|
|
|
for (CapacitiesMap::const_iterator i = this->capacities.begin(); i != this->capacities.end(); ++i) {
|
|
|
|
for (CargoID c = 0; c < NUM_CARGO; c++) {
|
|
|
|
/* Refresh the link and give it a minimum capacity. */
|
|
|
|
/* Refresh the link and give it a minimum capacity. */
|
|
|
|
|
|
|
|
|
|
|
|
if (i->second == 0) continue;
|
|
|
|
uint cargo_quantity = this->capacities[c];
|
|
|
|
CargoID c = i->first;
|
|
|
|
|
|
|
|
|
|
|
|
if (cargo_quantity == 0) continue;
|
|
|
|
|
|
|
|
|
|
|
|
/* If not allowed to merge link graphs, make sure the stations are
|
|
|
|
/* If not allowed to merge link graphs, make sure the stations are
|
|
|
|
* already in the same link graph. */
|
|
|
|
* already in the same link graph. */
|
|
|
@ -225,7 +233,7 @@ void LinkRefresher::RefreshStats(const Order *cur, const Order *next)
|
|
|
|
st->index == vehicle->last_station_visited &&
|
|
|
|
st->index == vehicle->last_station_visited &&
|
|
|
|
this->vehicle->orders.list->GetTotalDuration() >
|
|
|
|
this->vehicle->orders.list->GetTotalDuration() >
|
|
|
|
(Ticks)this->vehicle->current_order_time) {
|
|
|
|
(Ticks)this->vehicle->current_order_time) {
|
|
|
|
uint effective_capacity = i->second * this->vehicle->load_unload_ticks;
|
|
|
|
uint effective_capacity = cargo_quantity * this->vehicle->load_unload_ticks;
|
|
|
|
if (effective_capacity > (uint)this->vehicle->orders.list->GetTotalDuration()) {
|
|
|
|
if (effective_capacity > (uint)this->vehicle->orders.list->GetTotalDuration()) {
|
|
|
|
IncreaseStats(st, c, next_station, effective_capacity /
|
|
|
|
IncreaseStats(st, c, next_station, effective_capacity /
|
|
|
|
this->vehicle->orders.list->GetTotalDuration(), 0,
|
|
|
|
this->vehicle->orders.list->GetTotalDuration(), 0,
|
|
|
@ -233,10 +241,10 @@ void LinkRefresher::RefreshStats(const Order *cur, const Order *next)
|
|
|
|
} else if (RandomRange(this->vehicle->orders.list->GetTotalDuration()) < effective_capacity) {
|
|
|
|
} else if (RandomRange(this->vehicle->orders.list->GetTotalDuration()) < effective_capacity) {
|
|
|
|
IncreaseStats(st, c, next_station, 1, 0, EUM_INCREASE | restricted_mode);
|
|
|
|
IncreaseStats(st, c, next_station, 1, 0, EUM_INCREASE | restricted_mode);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
IncreaseStats(st, c, next_station, i->second, 0, EUM_REFRESH | restricted_mode);
|
|
|
|
IncreaseStats(st, c, next_station, cargo_quantity, 0, EUM_REFRESH | restricted_mode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
IncreaseStats(st, c, next_station, i->second, 0, EUM_REFRESH | restricted_mode);
|
|
|
|
IncreaseStats(st, c, next_station, cargo_quantity, 0, EUM_REFRESH | restricted_mode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|