1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-26 16:09:10 +00:00

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

This commit is contained in:
2024-05-26 16:46:18 +01:00
committed by GitHub
parent 3c42f701d7
commit 517dab35b1
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
{
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;
}

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();
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();
}

View File

@@ -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");
}