mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Use CargoArray::GetCount()
parent
a6c5b4ce4b
commit
74e42e39a8
|
@ -334,10 +334,7 @@ bool FindSubsidyTownCargoRoute()
|
||||||
/* Passenger subsidies are not handled here. */
|
/* Passenger subsidies are not handled here. */
|
||||||
town_cargo_produced[CT_PASSENGERS] = 0;
|
town_cargo_produced[CT_PASSENGERS] = 0;
|
||||||
|
|
||||||
uint8 cargo_count = 0;
|
uint8 cargo_count = town_cargo_produced.GetCount();
|
||||||
for (CargoID i = 0; i < NUM_CARGO; i++) {
|
|
||||||
if (town_cargo_produced[i] > 0) cargo_count++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* No cargo produced at all? */
|
/* No cargo produced at all? */
|
||||||
if (cargo_count == 0) return false;
|
if (cargo_count == 0) return false;
|
||||||
|
|
|
@ -329,12 +329,7 @@ int GetTrainDetailsWndVScroll(VehicleID veh_id, TrainDetailsWindowTabs det_tab)
|
||||||
max_cargo[v->cargo_type] += v->cargo_cap;
|
max_cargo[v->cargo_type] += v->cargo_cap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set scroll-amount separately from counting, as to not compute num double
|
num = max_cargo.GetCount();
|
||||||
* for more carriages of the same type
|
|
||||||
*/
|
|
||||||
for (CargoID i = 0; i < NUM_CARGO; i++) {
|
|
||||||
if (max_cargo[i] > 0) num++; // only count carriages that the train has
|
|
||||||
}
|
|
||||||
num++; // needs one more because first line is description string
|
num++; // needs one more because first line is description string
|
||||||
} else {
|
} else {
|
||||||
for (const Train *v = Train::Get(veh_id); v != nullptr; v = v->GetNextVehicle()) {
|
for (const Train *v = Train::Get(veh_id); v != nullptr; v = v->GetNextVehicle()) {
|
||||||
|
|
Loading…
Reference in New Issue