From 295508fc533a8ce6b8ad9d7ae323ee204011af8e Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Sat, 15 Jul 2023 20:44:07 +0100 Subject: [PATCH] Codechange: Avoid lengthof() on std::array. --- src/saveload/afterload.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index cfa3ddfbc5..f8b9202e6e 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -1708,14 +1708,15 @@ bool AfterLoadGame() } } + /* At version 78, industry cargo types can be changed, and are stored with the industry. For older save versions + * copy the IndustrySpec's cargo types over to the Industry. */ if (IsSavegameVersionBefore(SLV_78)) { - uint j; - for (Industry * i : Industry::Iterate()) { + for (Industry *i : Industry::Iterate()) { const IndustrySpec *indsp = GetIndustrySpec(i->type); - for (j = 0; j < lengthof(i->produced); j++) { + for (uint j = 0; j < std::size(i->produced); j++) { i->produced[j].cargo = indsp->produced_cargo[j]; } - for (j = 0; j < lengthof(i->accepted); j++) { + for (uint j = 0; j < std::size(i->accepted); j++) { i->accepted[j].cargo = indsp->accepts_cargo[j]; } }