Codechange: Base CargoArray off std::array.

This avoids needing to define array accessors and allows use of
default value initialization.
This commit is contained in:
Peter Nelson
2023-05-23 12:23:50 +01:00
committed by PeterN
parent 74e42e39a8
commit f177ce7c9a
14 changed files with 26 additions and 68 deletions

View File

@@ -322,8 +322,8 @@ int GetTrainDetailsWndVScroll(VehicleID veh_id, TrainDetailsWindowTabs det_tab)
int num = 0;
if (det_tab == TDW_TAB_TOTALS) { // Total cargo tab
CargoArray act_cargo;
CargoArray max_cargo;
CargoArray act_cargo{};
CargoArray max_cargo{};
for (const Vehicle *v = Vehicle::Get(veh_id); v != nullptr; v = v->Next()) {
act_cargo[v->cargo_type] += v->cargo.StoredCount();
max_cargo[v->cargo_type] += v->cargo_cap;
@@ -435,8 +435,8 @@ void DrawTrainDetails(const Train *v, const Rect &r, int vscroll_pos, uint16 vsc
}
} else {
int y = r.top;
CargoArray act_cargo;
CargoArray max_cargo;
CargoArray act_cargo{};
CargoArray max_cargo{};
Money feeder_share = 0;
for (const Vehicle *u = v; u != nullptr; u = u->Next()) {