mirror of
https://github.com/vcmi/vcmi.git
synced 2025-12-01 23:12:49 +02:00
Implemented join room dialog
This commit is contained in:
@@ -32,85 +32,26 @@ const ModVerificationInfo & ActiveModsInSaveList::getVerificationInfo(TModID mod
|
||||
return VLC->modh->getModInfo(mod).getVerificationInfo();
|
||||
}
|
||||
|
||||
void ActiveModsInSaveList::verifyActiveMods(const std::vector<std::pair<TModID, ModVerificationInfo>> & modList)
|
||||
void ActiveModsInSaveList::verifyActiveMods(const std::map<TModID, ModVerificationInfo> & modList)
|
||||
{
|
||||
auto searchVerificationInfo = [&modList](const TModID & m) -> const ModVerificationInfo*
|
||||
auto comparison = ModVerificationInfo::verifyListAgainstLocalMods(modList);
|
||||
std::vector<TModID> missingMods;
|
||||
std::vector<TModID> excessiveMods;
|
||||
|
||||
for (auto const & compared : comparison)
|
||||
{
|
||||
for(auto & i : modList)
|
||||
if(i.first == m)
|
||||
return &i.second;
|
||||
return nullptr;
|
||||
};
|
||||
if (compared.second == ModVerificationStatus::NOT_INSTALLED)
|
||||
missingMods.push_back(modList.at(compared.first).name);
|
||||
|
||||
std::vector<TModID> missingMods, excessiveMods;
|
||||
ModIncompatibility::ModListWithVersion missingModsResult;
|
||||
ModIncompatibility::ModList excessiveModsResult;
|
||||
if (compared.second == ModVerificationStatus::DISABLED)
|
||||
missingMods.push_back(VLC->modh->getModInfo(compared.first).getVerificationInfo().name);
|
||||
|
||||
for(const auto & m : VLC->modh->getActiveMods())
|
||||
{
|
||||
if(searchVerificationInfo(m))
|
||||
continue;
|
||||
|
||||
//TODO: support actual disabling of these mods
|
||||
if(VLC->modh->getModInfo(m).checkModGameplayAffecting())
|
||||
excessiveMods.push_back(m);
|
||||
if (compared.second == ModVerificationStatus::EXCESSIVE)
|
||||
excessiveMods.push_back(modList.at(compared.first).name);
|
||||
}
|
||||
|
||||
for(const auto & infoPair : modList)
|
||||
{
|
||||
auto & remoteModId = infoPair.first;
|
||||
auto & remoteModInfo = infoPair.second;
|
||||
|
||||
bool modAffectsGameplay = remoteModInfo.impactsGameplay;
|
||||
//parent mod affects gameplay if child affects too
|
||||
for(const auto & subInfoPair : modList)
|
||||
modAffectsGameplay |= (subInfoPair.second.impactsGameplay && subInfoPair.second.parent == remoteModId);
|
||||
|
||||
if(!vstd::contains(VLC->modh->getAllMods(), remoteModId))
|
||||
{
|
||||
if(modAffectsGameplay)
|
||||
missingMods.push_back(remoteModId); //mod is not installed
|
||||
continue;
|
||||
}
|
||||
|
||||
auto & localModInfo = VLC->modh->getModInfo(remoteModId).getVerificationInfo();
|
||||
modAffectsGameplay |= VLC->modh->getModInfo(remoteModId).checkModGameplayAffecting();
|
||||
bool modVersionCompatible = localModInfo.version.isNull()
|
||||
|| remoteModInfo.version.isNull()
|
||||
|| localModInfo.version.compatible(remoteModInfo.version);
|
||||
bool modLocalyEnabled = vstd::contains(VLC->modh->getActiveMods(), remoteModId);
|
||||
|
||||
if(modVersionCompatible && modAffectsGameplay && modLocalyEnabled)
|
||||
continue;
|
||||
|
||||
if(modAffectsGameplay)
|
||||
missingMods.push_back(remoteModId); //incompatible mod impacts gameplay
|
||||
}
|
||||
|
||||
//filter mods
|
||||
for(auto & m : missingMods)
|
||||
{
|
||||
if(auto * vInfo = searchVerificationInfo(m))
|
||||
{
|
||||
assert(vInfo->parent != m);
|
||||
if(!vInfo->parent.empty() && vstd::contains(missingMods, vInfo->parent))
|
||||
continue;
|
||||
missingModsResult.push_back({vInfo->name, vInfo->version.toString()});
|
||||
}
|
||||
}
|
||||
for(auto & m : excessiveMods)
|
||||
{
|
||||
auto & vInfo = VLC->modh->getModInfo(m).getVerificationInfo();
|
||||
assert(vInfo.parent != m);
|
||||
if(!vInfo.parent.empty() && vstd::contains(excessiveMods, vInfo.parent))
|
||||
continue;
|
||||
excessiveModsResult.push_back(vInfo.name);
|
||||
}
|
||||
|
||||
if(!missingModsResult.empty() || !excessiveModsResult.empty())
|
||||
throw ModIncompatibility(missingModsResult, excessiveModsResult);
|
||||
|
||||
//TODO: support actual enabling of required mods
|
||||
if(!missingMods.empty() || !excessiveMods.empty())
|
||||
throw ModIncompatibility(missingMods, excessiveMods);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user