Skip to content

Commit fa8239a

Browse files
committed
fix mod filtering
1 parent 2e2abcb commit fa8239a

2 files changed

Lines changed: 16 additions & 13 deletions

File tree

game/gothic.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,11 @@ Gothic::Gothic() {
124124
plDef = modFile->getS("SETTINGS","PLAYER");
125125

126126
std::u16string vdf = TextCodec::toUtf16(std::string(modFile->getS("FILES","VDF")));
127-
for (size_t start = 0, split = 0; split != std::string::npos; start = split+1) {
127+
for(size_t start = 0, split = 0; split != std::string::npos; start = split+1) {
128128
split = vdf.find(' ', start);
129129
std::u16string mod = vdf.substr(start, split-start);
130-
if (!mod.empty())
131-
modvdfs.push_back(mod);
130+
if(!mod.empty())
131+
modvdfs.emplace_back(std::move(mod));
132132
}
133133
}
134134
Resources::loadVdfs(modvdfs);

game/resources.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,19 @@ void Resources::loadVdfs(const std::vector<std::u16string>& modvdfs) {
9797
inst->detectVdf(archives,Gothic::inst().nestedPath({u"Data"},Dir::FT_Dir));
9898

9999
// Remove all mod files, that are not listed in modvdfs
100-
archives.erase(std::remove_if(archives.begin(), archives.end(),
101-
[&modvdfs](const Archive& a){
102-
return a.isMod && modvdfs.end() == std::find_if(modvdfs.begin(), modvdfs.end(),
103-
[&a](const std::u16string& modname) {
104-
const std::u16string_view& full_path = a.name;
105-
const std::u16string_view& file_name = modname;
106-
return (0 == full_path.compare(full_path.length() - file_name.length(),
107-
file_name.length(), file_name));
108-
});
109-
}), archives.end());
100+
if(!modvdfs.empty()) {
101+
// NOTE: apparently in CoM there is no mods list declaration. In such case - assume all modes
102+
archives.erase(std::remove_if(archives.begin(), archives.end(),
103+
[&modvdfs](const Archive& a){
104+
return a.isMod && modvdfs.end() == std::find_if(modvdfs.begin(), modvdfs.end(),
105+
[&a](const std::u16string& modname) {
106+
const std::u16string_view& full_path = a.name;
107+
const std::u16string_view& file_name = modname;
108+
return (0 == full_path.compare(full_path.length() - file_name.length(),
109+
file_name.length(), file_name));
110+
});
111+
}), archives.end());
112+
}
110113

111114
// addon archives first!
112115
std::stable_sort(archives.begin(),archives.end(),[](const Archive& a,const Archive& b){

0 commit comments

Comments
 (0)