diff --git a/src/company_base.h b/src/company_base.h index 7e7ca8ad4e..85905276fd 100644 --- a/src/company_base.h +++ b/src/company_base.h @@ -31,12 +31,12 @@ struct CompanyEconomyEntry { }; struct CompanyInfrastructure { - uint32_t road[ROADTYPE_END]; ///< Count of company owned track bits for each road type. - uint32_t signal; ///< Count of company owned signals. - uint32_t rail[RAILTYPE_END]; ///< Count of company owned track bits for each rail type. - uint32_t water; ///< Count of company owned track bits for canals. - uint32_t station; ///< Count of company owned station tiles. - uint32_t airport; ///< Count of company owned airports. + std::array road{}; ///< Count of company owned track bits for each road type. + uint32_t signal{}; ///< Count of company owned signals. + std::array rail{}; ///< Count of company owned track bits for each rail type. + uint32_t water{}; ///< Count of company owned track bits for canals. + uint32_t station{}; ///< Count of company owned station tiles. + uint32_t airport{}; ///< Count of company owned airports. /** Get total sum of all owned track bits. */ uint32_t GetRailTotal() const diff --git a/src/company_gui.cpp b/src/company_gui.cpp index 51a079a518..d9a4f17d2b 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -2456,7 +2456,7 @@ struct CompanyWindow : Window int y = r.top; uint rail_pieces = c->infrastructure.signal; - for (uint i = 0; i < lengthof(c->infrastructure.rail); i++) rail_pieces += c->infrastructure.rail[i]; + for (uint32_t pieces : c->infrastructure.rail) rail_pieces += pieces; if (rail_pieces != 0) { SetDParam(0, rail_pieces); DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_RAIL); @@ -2464,7 +2464,7 @@ struct CompanyWindow : Window } uint road_pieces = 0; - for (uint i = 0; i < lengthof(c->infrastructure.road); i++) road_pieces += c->infrastructure.road[i]; + for (uint32_t pieces : c->infrastructure.road) road_pieces += pieces; if (road_pieces != 0) { SetDParam(0, road_pieces); DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_ROAD); diff --git a/src/sl/company_sl.cpp b/src/sl/company_sl.cpp index 2de43fd73a..8360a94508 100644 --- a/src/sl/company_sl.cpp +++ b/src/sl/company_sl.cpp @@ -101,7 +101,7 @@ CompanyManagerFace ConvertFromOldCompanyManagerFace(uint32_t face) void AfterLoadCompanyStats() { /* Reset infrastructure statistics to zero. */ - for (Company *c : Company::Iterate()) MemSetT(&c->infrastructure, 0); + for (Company *c : Company::Iterate()) c->infrastructure = {}; /* Collect airport count. */ for (const Station *st : Station::Iterate()) {