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:
@@ -331,7 +331,7 @@ void CTownHandler::loadBuilding(CTown * town, const std::string & stringID, cons
|
||||
//MODS COMPATIBILITY FOR pre-1.6
|
||||
if(ret->produce.empty() && ret->bid == BuildingID::RESOURCE_SILO)
|
||||
{
|
||||
logGlobal->warn("Resource silo in town '%s' does not produces any resources!", ret->town->faction->getJsonKey());
|
||||
logGlobal->warn("Resource silo in town '%s' does not produce any resources!", ret->town->faction->getJsonKey());
|
||||
switch (ret->town->primaryRes.toEnum())
|
||||
{
|
||||
case EGameResID::GOLD:
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ bool ContentTypeHandler::loadMod(const std::string & modName, bool validate)
|
||||
{
|
||||
// normal new object
|
||||
logMod->trace("no index in loadMod(%s)", name);
|
||||
performValidate(data,name);
|
||||
performValidate(data, name);
|
||||
handler->loadObject(modName, name, data);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user