mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-11 13:10:45 +00:00
Codechange: Use range-for to iterate base media files. (#12721)
This commit is contained in:
parent
3c42f701d7
commit
517dab35b1
@ -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;
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user