1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +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:
Ivan Savenko
2025-08-05 19:40:18 +03:00
parent d83afd5b05
commit 78b39688c5
12 changed files with 35 additions and 20 deletions

View File

@@ -356,6 +356,12 @@ void CObjectClassesHandler::loadSubObject(const std::string & identifier, JsonNo
}
JsonUtils::inherit(config, mapObjectTypes.at(ID.getNum())->base);
for (auto & templ : config["templates"].Struct())
JsonUtils::inherit(templ.second, config["base"]);
if (settings["mods"]["validation"].String() != "off")
JsonUtils::validate(config, "vcmi:objectType", identifier);
loadSubObject(config.getModScope(), identifier, config, mapObjectTypes.at(ID.getNum()).get(), subID.getNum());
}