mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
Show root mods only
This commit is contained in:
parent
a05f8339ae
commit
4691907f9c
@ -572,7 +572,8 @@ bool CServerHandler::validateGameStart(bool allowOnlyAI) const
|
|||||||
void CServerHandler::sendStartGame(bool allowOnlyAI) const
|
void CServerHandler::sendStartGame(bool allowOnlyAI) const
|
||||||
{
|
{
|
||||||
verifyStateBeforeStart(allowOnlyAI ? true : settings["session"]["onlyai"].Bool());
|
verifyStateBeforeStart(allowOnlyAI ? true : settings["session"]["onlyai"].Bool());
|
||||||
|
GH.windows().createAndPushWindow<CLoadingScreen>();
|
||||||
|
|
||||||
LobbyStartGame lsg;
|
LobbyStartGame lsg;
|
||||||
if(client)
|
if(client)
|
||||||
{
|
{
|
||||||
|
@ -149,8 +149,6 @@ void ApplyOnLobbyScreenNetPackVisitor::visitLobbyLoadProgress(LobbyLoadProgress
|
|||||||
w->tick(0);
|
w->tick(0);
|
||||||
w->redraw();
|
w->redraw();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
GH.windows().createAndPushWindow<CLoadingScreen>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplyOnLobbyHandlerNetPackVisitor::visitLobbyUpdateState(LobbyUpdateState & pack)
|
void ApplyOnLobbyHandlerNetPackVisitor::visitLobbyUpdateState(LobbyUpdateState & pack)
|
||||||
|
@ -958,6 +958,7 @@ void CMapLoaderJson::readHeader(const bool complete)
|
|||||||
info.version = CModVersion::fromString(mod["version"].String());
|
info.version = CModVersion::fromString(mod["version"].String());
|
||||||
info.checksum = mod["checksum"].Integer();
|
info.checksum = mod["checksum"].Integer();
|
||||||
info.name = mod["name"].String();
|
info.name = mod["name"].String();
|
||||||
|
info.parent = mod["parent"].String();
|
||||||
info.impactsGameplay = true;
|
info.impactsGameplay = true;
|
||||||
|
|
||||||
if(!mod["modId"].isNull())
|
if(!mod["modId"].isNull())
|
||||||
@ -1307,6 +1308,7 @@ void CMapSaverJson::writeHeader()
|
|||||||
JsonNode modWriter;
|
JsonNode modWriter;
|
||||||
modWriter["modId"].String() = mod.first;
|
modWriter["modId"].String() = mod.first;
|
||||||
modWriter["name"].String() = mod.second.name;
|
modWriter["name"].String() = mod.second.name;
|
||||||
|
modWriter["parent"].String() = mod.second.parent;
|
||||||
modWriter["version"].String() = mod.second.version.toString();
|
modWriter["version"].String() = mod.second.version.toString();
|
||||||
modWriter["checksum"].Integer() = mod.second.checksum;
|
modWriter["checksum"].Integer() = mod.second.checksum;
|
||||||
mods.Vector().push_back(modWriter);
|
mods.Vector().push_back(modWriter);
|
||||||
|
@ -473,41 +473,46 @@ void CModHandler::afterLoad(bool onlyEssential)
|
|||||||
|
|
||||||
void CModHandler::trySetActiveMods(const std::vector<std::pair<TModID, CModInfo::VerificationInfo>> & modList)
|
void CModHandler::trySetActiveMods(const std::vector<std::pair<TModID, CModInfo::VerificationInfo>> & modList)
|
||||||
{
|
{
|
||||||
auto hasMod = [&modList](const TModID & m) -> bool
|
auto searchVerificationInfo = [&modList](const TModID & m) -> const CModInfo::VerificationInfo*
|
||||||
{
|
{
|
||||||
for(auto & i : modList)
|
for(auto & i : modList)
|
||||||
if(i.first == m)
|
if(i.first == m)
|
||||||
return true;
|
return &i.second;
|
||||||
return false;
|
return nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
for(const auto & m : activeMods)
|
for(const auto & m : activeMods)
|
||||||
{
|
{
|
||||||
if(hasMod(m))
|
if(searchVerificationInfo(m))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
//TODO: support actual disabling of these mods
|
||||||
if(getModInfo(m).checkModGameplayAffecting())
|
if(getModInfo(m).checkModGameplayAffecting())
|
||||||
allMods[m].setEnabled(false);
|
allMods[m].setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<TModID> newActiveMods;
|
std::vector<TModID> newActiveMods, missingMods;
|
||||||
ModIncompatibility::ModList missingMods;
|
ModIncompatibility::ModList missingModsResult;
|
||||||
|
|
||||||
for(const auto & infoPair : modList)
|
for(const auto & infoPair : modList)
|
||||||
{
|
{
|
||||||
auto & remoteModId = infoPair.first;
|
auto & remoteModId = infoPair.first;
|
||||||
auto & remoteModInfo = infoPair.second;
|
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(!allMods.count(remoteModId))
|
if(!allMods.count(remoteModId))
|
||||||
{
|
{
|
||||||
if(remoteModInfo.impactsGameplay)
|
if(modAffectsGameplay)
|
||||||
missingMods.push_back({remoteModInfo.name, remoteModInfo.version.toString()}); //mod is not installed
|
missingMods.push_back(remoteModId); //mod is not installed
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto & localModInfo = getModInfo(remoteModId).getVerificationInfo();
|
auto & localModInfo = getModInfo(remoteModId).getVerificationInfo();
|
||||||
|
modAffectsGameplay |= getModInfo(remoteModId).checkModGameplayAffecting();
|
||||||
bool modAffectsGameplay = getModInfo(remoteModId).checkModGameplayAffecting();
|
|
||||||
bool modVersionCompatible = localModInfo.version.isNull()
|
bool modVersionCompatible = localModInfo.version.isNull()
|
||||||
|| remoteModInfo.version.isNull()
|
|| remoteModInfo.version.isNull()
|
||||||
|| localModInfo.version.compatible(remoteModInfo.version);
|
|| localModInfo.version.compatible(remoteModInfo.version);
|
||||||
@ -519,13 +524,26 @@ void CModHandler::trySetActiveMods(const std::vector<std::pair<TModID, CModInfo:
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(modAffectsGameplay || remoteModInfo.impactsGameplay)
|
if(modAffectsGameplay)
|
||||||
missingMods.push_back({remoteModInfo.name, remoteModInfo.version.toString()}); //incompatible mod impacts gameplay
|
missingMods.push_back(remoteModId); //incompatible mod impacts gameplay
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!missingMods.empty())
|
//filter mods
|
||||||
throw ModIncompatibility(std::move(missingMods));
|
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()});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!missingModsResult.empty())
|
||||||
|
throw ModIncompatibility(std::move(missingModsResult));
|
||||||
|
|
||||||
|
//TODO: support actual enabling of these mods
|
||||||
for(auto & m : newActiveMods)
|
for(auto & m : newActiveMods)
|
||||||
allMods[m].setEnabled(true);
|
allMods[m].setEnabled(true);
|
||||||
|
|
||||||
|
@ -42,6 +42,9 @@ CModInfo::CModInfo(const std::string & identifier, const JsonNode & local, const
|
|||||||
{
|
{
|
||||||
verificationInfo.name = config["name"].String();
|
verificationInfo.name = config["name"].String();
|
||||||
verificationInfo.version = CModVersion::fromString(config["version"].String());
|
verificationInfo.version = CModVersion::fromString(config["version"].String());
|
||||||
|
verificationInfo.parent = identifier.substr(0, identifier.find_last_of('.'));
|
||||||
|
if(verificationInfo.parent == identifier)
|
||||||
|
verificationInfo.parent.clear();
|
||||||
|
|
||||||
if(!config["compatibility"].isNull())
|
if(!config["compatibility"].isNull())
|
||||||
{
|
{
|
||||||
|
@ -41,6 +41,9 @@ public:
|
|||||||
/// CRC-32 checksum of the mod
|
/// CRC-32 checksum of the mod
|
||||||
ui32 checksum = 0;
|
ui32 checksum = 0;
|
||||||
|
|
||||||
|
/// parent mod ID, empty if root-level mod
|
||||||
|
TModID parent;
|
||||||
|
|
||||||
/// for serialization purposes
|
/// for serialization purposes
|
||||||
bool impactsGameplay = true;
|
bool impactsGameplay = true;
|
||||||
|
|
||||||
@ -50,6 +53,7 @@ public:
|
|||||||
h & name;
|
h & name;
|
||||||
h & version;
|
h & version;
|
||||||
h & checksum;
|
h & checksum;
|
||||||
|
h & parent;
|
||||||
h & impactsGameplay;
|
h & impactsGameplay;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user