mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-27 22:49:25 +02:00
Improvements for json validation for mods
- Implemented validation for `targetCondition` in spells - Implemented validation for `mapObject` in towns/heroes - Fixed validation of zone connections in RMG - Added workarounds to prevent assertions triggering on invalid mods - Erase 'base' entries from json before validation (but after applying them to derived keys) Should have no effect on mod behavior/support, but may cause new detections for mods that were broken in either 1.6 or 1.7
This commit is contained in:
@@ -207,9 +207,9 @@ void CHeroHandler::beforeValidate(JsonNode & object)
|
||||
JsonNode & specialtyNode = object["specialty"];
|
||||
if(specialtyNode.getType() == JsonNode::JsonType::DATA_STRUCT)
|
||||
{
|
||||
const JsonNode & base = specialtyNode["base"];
|
||||
if(!base.isNull())
|
||||
if(specialtyNode.Struct().count("base") != 0)
|
||||
{
|
||||
const JsonNode & base = specialtyNode["base"];
|
||||
if(specialtyNode["bonuses"].isNull())
|
||||
{
|
||||
logMod->warn("specialty has base without bonuses");
|
||||
@@ -220,6 +220,7 @@ void CHeroHandler::beforeValidate(JsonNode & object)
|
||||
for(std::pair<std::string, JsonNode> keyValue : bonuses)
|
||||
JsonUtils::inherit(bonuses[keyValue.first], base);
|
||||
}
|
||||
specialtyNode.Struct().erase("base");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user