mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-17 20:58:07 +02:00
Analyze filesystem of mods to detect potential mod conflicts
This commit is contained in:
parent
cd52625657
commit
2439d176a0
@ -331,10 +331,32 @@ void CModHandler::loadModFilesystems()
|
||||
|
||||
coreMod->updateChecksum(calculateModChecksum(ModScope::scopeBuiltin(), CResourceHandler::get(ModScope::scopeBuiltin())));
|
||||
|
||||
std::map<std::string, ISimpleResourceLoader *> modFilesystems;
|
||||
|
||||
for(std::string & modName : activeMods)
|
||||
modFilesystems[modName] = genModFilesystem(modName, allMods[modName].config);
|
||||
|
||||
for(std::string & modName : activeMods)
|
||||
CResourceHandler::addFilesystem("data", modName, modFilesystems[modName]);
|
||||
|
||||
for(std::string & leftModName : activeMods)
|
||||
{
|
||||
CModInfo & mod = allMods[modName];
|
||||
CResourceHandler::addFilesystem("data", modName, genModFilesystem(modName, mod.config));
|
||||
for(std::string & rightModName : activeMods)
|
||||
{
|
||||
if (leftModName == rightModName)
|
||||
continue;
|
||||
|
||||
const auto & filter = [](const ResourcePath &path){return path.getType() != EResType::DIRECTORY;};
|
||||
|
||||
std::unordered_set<ResourcePath> leftResources = modFilesystems[leftModName]->getFilteredFiles(filter);
|
||||
std::unordered_set<ResourcePath> rightResources = modFilesystems[rightModName]->getFilteredFiles(filter);
|
||||
|
||||
for (auto const & leftFile : leftResources)
|
||||
{
|
||||
if (rightResources.count(leftFile))
|
||||
logMod->warn("Potential confict detected between '%s' and '%s': both mods add file '%s'", leftModName, rightModName, leftFile.getOriginalName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user