mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Use bitmask instead of array for cargo consistency check.
We only need to know if a cargo type is accepted, not how much.pull/11381/head
parent
a1c6923c63
commit
2a88e0fab3
|
@ -284,7 +284,7 @@ void CheckConsistencyOfArticulatedVehicle(const Vehicle *v)
|
|||
|
||||
CargoTypes real_refit_union = 0;
|
||||
CargoTypes real_refit_intersection = ALL_CARGOTYPES;
|
||||
CargoArray real_default_capacity{};
|
||||
CargoTypes real_default_cargoes = 0;
|
||||
|
||||
do {
|
||||
CargoTypes refit_mask = GetAvailableVehicleCargoTypes(v->engine_type, true);
|
||||
|
@ -292,15 +292,15 @@ void CheckConsistencyOfArticulatedVehicle(const Vehicle *v)
|
|||
if (refit_mask != 0) real_refit_intersection &= refit_mask;
|
||||
|
||||
assert(v->cargo_type < NUM_CARGO);
|
||||
real_default_capacity[v->cargo_type] += v->cargo_cap;
|
||||
if (v->cargo_cap > 0) SetBit(real_default_cargoes, v->cargo_type);
|
||||
|
||||
v = v->HasArticulatedPart() ? v->GetNextArticulatedPart() : nullptr;
|
||||
} while (v != nullptr);
|
||||
|
||||
/* Check whether the vehicle carries more cargoes than expected */
|
||||
bool carries_more = false;
|
||||
for (CargoID cid = 0; cid < NUM_CARGO; cid++) {
|
||||
if (real_default_capacity[cid] != 0 && purchase_default_capacity[cid] == 0) {
|
||||
for (CargoID cid : SetCargoBitIterator(real_default_cargoes)) {
|
||||
if (purchase_default_capacity[cid] == 0) {
|
||||
carries_more = true;
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue