mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-10 22:31:40 +02:00
Analyze filesystem of mods to detect potential mod conflicts
This commit is contained in:
@@ -331,10 +331,32 @@ void CModHandler::loadModFilesystems()
|
|||||||
|
|
||||||
coreMod->updateChecksum(calculateModChecksum(ModScope::scopeBuiltin(), CResourceHandler::get(ModScope::scopeBuiltin())));
|
coreMod->updateChecksum(calculateModChecksum(ModScope::scopeBuiltin(), CResourceHandler::get(ModScope::scopeBuiltin())));
|
||||||
|
|
||||||
|
std::map<std::string, ISimpleResourceLoader *> modFilesystems;
|
||||||
|
|
||||||
for(std::string & modName : activeMods)
|
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];
|
for(std::string & rightModName : activeMods)
|
||||||
CResourceHandler::addFilesystem("data", modName, genModFilesystem(modName, mod.config));
|
{
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user