COMMON: Fixed order of loading zip packs

It appears that the subsequent packages actually override previous ones
This commit is contained in:
Eugene Sandulenko 2023-11-10 23:43:58 +01:00
parent a6790f52bc
commit 57c87b4b50
No known key found for this signature in database
GPG Key ID: 014D387312D34F08

View File

@ -29,36 +29,14 @@ namespace Common {
struct ArchiveMemberListBackComparator {
bool operator()(const ArchiveMemberPtr &a, const ArchiveMemberPtr &b) {
return a->getName() > b->getName();
return a->getName() < b->getName();
}
};
bool generateZipSet(SearchSet &searchSet, const char *defaultFile, const char *packsMask, const char *packsPath) {
Archive *dat;
Archive *dat = nullptr;
bool changed = false;
if (!ConfMan.get(packsPath).empty()) {
FSDirectory *iconDir = new FSDirectory(ConfMan.get(packsPath));
ArchiveMemberList iconFiles;
iconDir->listMatchingMembers(iconFiles, packsMask);
sort(iconFiles.begin(), iconFiles.end(), ArchiveMemberListBackComparator());
for (ArchiveMemberList::iterator ic = iconFiles.begin(); ic != iconFiles.end(); ++ic) {
dat = makeZipArchive((*ic)->createReadStream());
if (dat) {
searchSet.add((*ic)->getName(), dat);
changed = true;
debug(2, "generateZipSet: Loaded pack file: %s", (*ic)->getName().c_str());
}
}
delete iconDir;
}
dat = nullptr;
if (ConfMan.hasKey("themepath")) {
FSNode *fs = new FSNode(normalizePath(ConfMan.get("themepath") + "/" + defaultFile, '/'));
if (fs->exists()) {
@ -95,6 +73,28 @@ bool generateZipSet(SearchSet &searchSet, const char *defaultFile, const char *p
debug(2, "generateZipSet: Loaded pack file: %s", defaultFile);
}
dat = nullptr;
if (!ConfMan.get(packsPath).empty()) {
FSDirectory *iconDir = new FSDirectory(ConfMan.get(packsPath));
ArchiveMemberList iconFiles;
iconDir->listMatchingMembers(iconFiles, packsMask);
sort(iconFiles.begin(), iconFiles.end(), ArchiveMemberListBackComparator());
for (ArchiveMemberList::iterator ic = iconFiles.begin(); ic != iconFiles.end(); ++ic) {
dat = makeZipArchive((*ic)->createReadStream());
if (dat) {
searchSet.add((*ic)->getName(), dat);
changed = true;
debug(2, "generateZipSet: Loaded pack file: %s", (*ic)->getName().c_str());
}
}
delete iconDir;
}
return changed;
}