1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Apply suggestions from code review

Co-authored-by: Andrey Filipenkov <decapitator@ukr.net>
This commit is contained in:
Nordsoft91 2022-09-19 01:18:17 +04:00 committed by GitHub
parent 1b6f4a5cf3
commit 60264aae29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 16 deletions

View File

@ -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);

View File

@ -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

View File

@ -171,10 +171,7 @@ void ObstacleProxy::finalInsertion(CMapEditManager * manager, std::set<CGObjectI
std::pair<bool, bool> ObstacleProxy::verifyCoverage(const int3 & t) const
{
std::pair<bool, bool> 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<CGObjectInstance*> & instances)
@ -230,12 +227,7 @@ void ObstaclePlacer::init()
std::pair<bool, bool> ObstaclePlacer::verifyCoverage(const int3 & t) const
{
std::pair<bool, bool> 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<CGObjectInstance*> &)
@ -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());
}
}