mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-27 22:49:25 +02:00
Implement detection of mod compatibility patches
This commit is contained in:
@@ -275,11 +275,8 @@ JsonNode JsonUtils::assembleFromFiles(const std::string & filename)
|
||||
return result;
|
||||
}
|
||||
|
||||
void JsonUtils::detectConflicts(const JsonNode & left, const JsonNode & right, const std::string & entityName, const std::string & keyName)
|
||||
void JsonUtils::detectConflicts(JsonNode & result, const JsonNode & left, const JsonNode & right, const std::string & keyName)
|
||||
{
|
||||
if (left == right)
|
||||
return;
|
||||
|
||||
switch (left.getType())
|
||||
{
|
||||
case JsonNode::JsonType::DATA_NULL:
|
||||
@@ -289,16 +286,15 @@ void JsonUtils::detectConflicts(const JsonNode & left, const JsonNode & right, c
|
||||
case JsonNode::JsonType::DATA_STRING:
|
||||
case JsonNode::JsonType::DATA_VECTOR: // NOTE: comparing vectors as whole - since merge will overwrite it in its entirety
|
||||
{
|
||||
logMod->warn("Potential confict detected between '%s' and '%s' in object '%s'", left.getModScope(), right.getModScope(), entityName);
|
||||
logMod->warn("Mod '%s' - value %s set to '%s'", left.getModScope(), keyName, left.toCompactString());
|
||||
logMod->warn("Mod '%s' - value %s set to '%s'", right.getModScope(), keyName, right.toCompactString());
|
||||
result[keyName][left.getModScope()] = left;
|
||||
result[keyName][right.getModScope()] = right;
|
||||
return;
|
||||
}
|
||||
case JsonNode::JsonType::DATA_STRUCT:
|
||||
{
|
||||
for(auto & node : left.Struct())
|
||||
for(const auto & node : left.Struct())
|
||||
if (!right[node.first].isNull())
|
||||
detectConflicts(node.second, right[node.first], entityName, keyName + "/" + node.first);
|
||||
detectConflicts(result, node.second, right[node.first], keyName + "/" + node.first);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user