VarAction2: Cache refit capacity callback results which depend only on cargo

This commit is contained in:
Jonathan G Rennison
2022-06-06 18:34:30 +01:00
parent fcd9137a9f
commit 7a61b5d820
8 changed files with 109 additions and 7 deletions

View File

@@ -111,7 +111,10 @@ bool LinkRefresher::HandleRefit(CargoID refit_cargo)
CargoID temp_cid = v->cargo_type;
byte temp_subtype = v->cargo_subtype;
v->cargo_type = this->cargo;
v->cargo_subtype = GetBestFittingSubType(v, v, this->cargo);
if (e->refit_capacity_values == nullptr || !(e->callbacks_used & SGCU_REFIT_CB_ALL_CARGOES) || this->cargo == e->GetDefaultCargoType() || (e->type == VEH_AIRCRAFT && IsCargoInClass(this->cargo, CC_PASSENGERS))) {
/* This can be omitted when the refit capacity values are already determined, and the capacity is definitely from the refit callback */
v->cargo_subtype = GetBestFittingSubType(v, v, this->cargo);
}
uint16 mail_capacity = 0;
uint amount = e->DetermineCapacity(v, &mail_capacity);