1
0
Fork 0

Codechange: Use range-for to iterate base media files. (#12721)

pull/12722/head
Peter Nelson 2024-05-26 16:46:18 +01:00 committed by GitHub
parent 3c42f701d7
commit 517dab35b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 7 deletions

View File

@ -158,8 +158,8 @@ struct BaseSet {
*/ */
std::optional<std::string> GetTextfile(TextfileType type) const std::optional<std::string> GetTextfile(TextfileType type) const
{ {
for (uint i = 0; i < NUM_FILES; i++) { for (const auto &file : this->files) {
auto textfile = ::GetTextfile(type, BASESET_DIR, this->files[i].filename); auto textfile = ::GetTextfile(type, BASESET_DIR, file.filename);
if (textfile.has_value()) { if (textfile.has_value()) {
return textfile; return textfile;
} }

View File

@ -325,8 +325,8 @@ template <class Tbase_set> const char *TryGetBaseSetFile(const ContentInfo *ci,
if (!md5sum) return s->files[0].filename.c_str(); if (!md5sum) return s->files[0].filename.c_str();
MD5Hash md5; MD5Hash md5;
for (uint i = 0; i < Tbase_set::NUM_FILES; i++) { for (const auto &file : s->files) {
md5 ^= s->files[i].hash; md5 ^= file.hash;
} }
if (md5 == ci->md5sum) return s->files[0].filename.c_str(); if (md5 == ci->md5sum) return s->files[0].filename.c_str();
} }

View File

@ -127,9 +127,9 @@ void CheckExternalFiles()
if (used_set->GetNumInvalid() != 0) { if (used_set->GetNumInvalid() != 0) {
/* Not all files were loaded successfully, see which ones */ /* 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); 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++) { for (const auto &file : used_set->files) {
MD5File::ChecksumResult res = GraphicsSet::CheckMD5(&used_set->files[i], BASESET_DIR); MD5File::ChecksumResult res = GraphicsSet::CheckMD5(&file, 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); 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"); fmt::format_to(output_iterator, "\n");
} }