Codechange: Use std::array for company infrastructure arrays.

This commit is contained in:
Peter Nelson 2024-04-16 15:47:41 +01:00 committed by Peter Nelson
parent fe7bd3a266
commit db56499c01
2 changed files with 4 additions and 4 deletions

View File

@ -30,9 +30,9 @@ struct CompanyEconomyEntry {
};
struct CompanyInfrastructure {
uint32_t road[ROADTYPE_END]; ///< Count of company owned track bits for each road type.
std::array<uint32_t, RAILTYPE_END> rail{}; ///< Count of company owned track bits for each rail type.
std::array<uint32_t, ROADTYPE_END> road{}; ///< 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.

View File

@ -2338,7 +2338,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 (uint i = 0; i < std::size(c->infrastructure.rail); i++) rail_pieces += c->infrastructure.rail[i];
if (rail_pieces != 0) {
SetDParam(0, rail_pieces);
DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_RAIL);
@ -2346,7 +2346,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 (uint i = 0; i < std::size(c->infrastructure.road); i++) road_pieces += c->infrastructure.road[i];
if (road_pieces != 0) {
SetDParam(0, road_pieces);
DrawString(r.left, r.right, y, STR_COMPANY_VIEW_INFRASTRUCTURE_ROAD);