diff --git a/lib/CModHandler.cpp b/lib/CModHandler.cpp index 485a8304b..a652d03ef 100644 --- a/lib/CModHandler.cpp +++ b/lib/CModHandler.cpp @@ -655,8 +655,9 @@ void CModInfo::loadLocalData(const JsonNode & data) //check compatibility bool wasEnabled = enabled; - enabled &= vcmiCompatibleMin.isNull() || Version::GameVersion().compatible(vcmiCompatibleMin); - enabled &= vcmiCompatibleMax.isNull() || vcmiCompatibleMax.compatible(Version::GameVersion()); + enabled = enabled && (vcmiCompatibleMin.isNull() || Version::GameVersion().compatible(vcmiCompatibleMin)); + enabled = enabled && (vcmiCompatibleMax.isNull() || vcmiCompatibleMax.compatible(Version::GameVersion())); + if(wasEnabled && !enabled) logGlobal->warn("Mod %s is incompatible with current version of VCMI and cannot be enabled", name); diff --git a/lib/CModHandler.h b/lib/CModHandler.h index 03028dd5f..de0f4144d 100644 --- a/lib/CModHandler.h +++ b/lib/CModHandler.h @@ -212,7 +212,8 @@ public: /// version of the mod Version version; - ///The vcmi versions compatible with the mod + /// vcmi versions compatible with the mod + Version vcmiCompatibleMin, vcmiCompatibleMax; /// list of mods that should be loaded before this one @@ -364,7 +365,8 @@ public: if(h.saving) { h & activeMods; - for(auto & m : activeMods) + for(const auto & m : activeMods) + h & allMods[m].version; } else diff --git a/lib/rmg/ObstaclePlacer.cpp b/lib/rmg/ObstaclePlacer.cpp index 1e7874075..29fba34ab 100644 --- a/lib/rmg/ObstaclePlacer.cpp +++ b/lib/rmg/ObstaclePlacer.cpp @@ -171,10 +171,7 @@ void ObstacleProxy::finalInsertion(CMapEditManager * manager, std::set ObstacleProxy::verifyCoverage(const int3 & t) const { - std::pair result(false, false); - if(blockedArea.contains(t)) - result.first = true; - return result; + return {blockedArea.contains(t), false}; } void ObstacleProxy::placeObject(rmg::Object & object, std::set & instances) @@ -230,12 +227,7 @@ void ObstaclePlacer::init() std::pair ObstaclePlacer::verifyCoverage(const int3 & t) const { - std::pair result(false, false); - if(map.shouldBeBlocked(t)) - result.first = true; - if(zone.areaPossible().contains(t)) - result.second = true; - return result; + return {map.shouldBeBlocked(t), zone.areaPossible().contains(t)}; } void ObstaclePlacer::placeObject(rmg::Object & object, std::set &) @@ -248,9 +240,10 @@ void ObstaclePlacer::postProcess(const rmg::Object & object) //river processing if(riverManager) { - if(object.instances().front()->object().typeName == "mountain") + const auto objTypeName = object.instances().front()->object().typeName; + if(objTypeName == "mountain") riverManager->riverSource().unite(object.getArea()); - if(object.instances().front()->object().typeName == "lake") + else if(objTypeName == "lake") riverManager->riverSink().unite(object.getArea()); } }