33#include < algorithm>
44#include < cstdint>
55#include < cstring>
6+ #include < functional>
67#include < vector>
78
89#include " appfat.h"
2425namespace devilution {
2526
2627std::vector<std::string> OverridePaths;
27- std::map<int , MpqArchiveT> MpqArchives;
28+ std::map<int , MpqArchiveT, std::greater<> > MpqArchives;
2829bool HasHellfireMpq;
2930
3031namespace {
3132
3233#ifdef UNPACKED_MPQS
3334char *FindUnpackedMpqFile (char *relativePath)
3435{
35- // Iterate over archives in reverse order to prefer files from high priority archives
3636 char *path = nullptr ;
37- for (auto rit = MpqArchives.rbegin (); rit != MpqArchives.rend (); ++rit) {
38- const std::string_view unpackedDir = rit->second ;
37+ for (const auto &[_, unpackedDir] : MpqArchives) {
3938 path = relativePath - unpackedDir.size ();
4039 std::memcpy (path, unpackedDir.data (), unpackedDir.size ());
4140 if (FileExists (path)) break ;
@@ -62,10 +61,9 @@ bool FindMpqFile(std::string_view filename, MpqArchive **archive, uint32_t *file
6261{
6362 const MpqFileHash fileHash = CalculateMpqFileHash (filename);
6463
65- // Iterate over archives in reverse order to prefer files from high priority archives
66- for (auto rit = MpqArchives.rbegin (); rit != MpqArchives.rend (); ++rit) {
67- if (rit->second .GetFileNumber (fileHash, *fileNumber)) {
68- *archive = &rit->second ;
64+ for (auto &[_, mpqArchive] : MpqArchives) {
65+ if (mpqArchive.GetFileNumber (fileHash, *fileNumber)) {
66+ *archive = &mpqArchive;
6967 return true ;
7068 }
7169 }
0 commit comments