1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

fix for insert@/modify@ in JsonUtils::merge; minor typo fixes

This commit is contained in:
Michał Zaremba
2025-08-22 15:51:11 +02:00
parent 6206633e4c
commit be736eb1b2
3 changed files with 5 additions and 5 deletions

View File

@@ -34,7 +34,7 @@ static std::optional<int> getIndexSafe(const JsonNode & node, const std::string
}
catch(const std::out_of_range & )
{
logMod->warn("Failed to replace index when replacing individual items in array. Value '%s' does not exists in targeted array of %d items", keyName, node.Vector().size());
logMod->warn("Failed to replace index when replacing individual items in array. Value '%s' does not exist in targeted array of %d items", keyName, node.Vector().size());
return std::nullopt;
}
};
@@ -253,14 +253,14 @@ void JsonUtils::merge(JsonNode & dest, JsonNode & source, bool ignoreOverride, b
else if (boost::algorithm::starts_with(node.first, "insert@"))
{
constexpr int numberPosition = std::char_traits<char>::length("insert@");
auto index = getIndexSafe(node.second, node.first.substr(numberPosition));
auto index = getIndexSafe(dest, node.first.substr(numberPosition));
if (index)
dest.Vector().insert(dest.Vector().begin() + index.value(), std::move(node.second));
}
else if (boost::algorithm::starts_with(node.first, "modify@"))
{
constexpr int numberPosition = std::char_traits<char>::length("modify@");
auto index = getIndexSafe(node.second, node.first.substr(numberPosition));
auto index = getIndexSafe(dest, node.first.substr(numberPosition));
if (index)
merge(dest.Vector().at(index.value()), node.second, ignoreOverride);
}