diff --git a/src/base_media_base.h b/src/base_media_base.h index 0bd288a9a2..0164a1176a 100644 --- a/src/base_media_base.h +++ b/src/base_media_base.h @@ -158,8 +158,8 @@ struct BaseSet { */ std::optional GetTextfile(TextfileType type) const { - for (uint i = 0; i < NUM_FILES; i++) { - auto textfile = ::GetTextfile(type, BASESET_DIR, this->files[i].filename); + for (const auto &file : this->files) { + auto textfile = ::GetTextfile(type, BASESET_DIR, file.filename); if (textfile.has_value()) { return textfile; } diff --git a/src/base_media_func.h b/src/base_media_func.h index d04485579c..2d68caaa6b 100644 --- a/src/base_media_func.h +++ b/src/base_media_func.h @@ -325,8 +325,8 @@ template const char *TryGetBaseSetFile(const ContentInfo *ci, if (!md5sum) return s->files[0].filename.c_str(); MD5Hash md5; - for (uint i = 0; i < Tbase_set::NUM_FILES; i++) { - md5 ^= s->files[i].hash; + for (const auto &file : s->files) { + md5 ^= file.hash; } if (md5 == ci->md5sum) return s->files[0].filename.c_str(); } diff --git a/src/gfxinit.cpp b/src/gfxinit.cpp index 62b69f2646..f2fccc890c 100644 --- a/src/gfxinit.cpp +++ b/src/gfxinit.cpp @@ -127,9 +127,9 @@ void CheckExternalFiles() if (used_set->GetNumInvalid() != 0) { /* Not all files were loaded successfully, see which ones */ fmt::format_to(output_iterator, "Trying to load graphics set '{}', but it is incomplete. The game will probably not run correctly until you properly install this set or select another one. See section 4.1 of README.md.\n\nThe following files are corrupted or missing:\n", used_set->name); - for (uint i = 0; i < GraphicsSet::NUM_FILES; i++) { - MD5File::ChecksumResult res = GraphicsSet::CheckMD5(&used_set->files[i], BASESET_DIR); - if (res != MD5File::CR_MATCH) fmt::format_to(output_iterator, "\t{} is {} ({})\n", used_set->files[i].filename, res == MD5File::CR_MISMATCH ? "corrupt" : "missing", used_set->files[i].missing_warning); + for (const auto &file : used_set->files) { + MD5File::ChecksumResult res = GraphicsSet::CheckMD5(&file, BASESET_DIR); + if (res != MD5File::CR_MATCH) fmt::format_to(output_iterator, "\t{} is {} ({})\n", file.filename, res == MD5File::CR_MISMATCH ? "corrupt" : "missing", file.missing_warning); } fmt::format_to(output_iterator, "\n"); }