mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Fixed broken in some cases behavior of "base" entries.
Maps with new objects seems to be working correctly now, objects are correctly initialized with base values even with null input
This commit is contained in:
parent
971a93b4f1
commit
1d5d4e3248
@ -59,9 +59,9 @@
|
||||
"base" : {
|
||||
"visitableFrom" : [ "---", "+++", "+++" ],
|
||||
"mask" : [
|
||||
"VVVVV", // a LOT of just visible rows due to towns like Tower
|
||||
"VVVVV",
|
||||
"VVVVV",
|
||||
"VVVVVV", // a LOT of just visible rows due to towns like Tower
|
||||
"VVVVVV",
|
||||
"VVVVVV",
|
||||
"VVBBBV",
|
||||
"VBBBBB",
|
||||
"VBBABB"
|
||||
|
@ -495,6 +495,7 @@ void CObjectClassesHandler::loadObject(std::string scope, std::string name, cons
|
||||
|
||||
void CObjectClassesHandler::createObject(std::string name, JsonNode config, si32 ID, boost::optional<si32> subID)
|
||||
{
|
||||
config.setType(JsonNode::DATA_STRUCT); // ensure that input is not NULL
|
||||
assert(objects.count(ID));
|
||||
if (subID)
|
||||
{
|
||||
@ -502,6 +503,9 @@ void CObjectClassesHandler::createObject(std::string name, JsonNode config, si32
|
||||
assert(config["index"].isNull());
|
||||
config["index"].Float() = subID.get();
|
||||
}
|
||||
|
||||
JsonUtils::inherit(config, objects.at(ID)->base);
|
||||
|
||||
loadObjectEntry(config, objects[ID]);
|
||||
}
|
||||
|
||||
@ -568,16 +572,17 @@ void AObjectTypeHandler::setType(si32 type, si32 subtype)
|
||||
|
||||
void AObjectTypeHandler::init(const JsonNode & input)
|
||||
{
|
||||
base = input["base"];
|
||||
for (auto entry : input["templates"].Struct())
|
||||
{
|
||||
JsonNode data = input["base"];
|
||||
JsonUtils::merge(data, entry.second);
|
||||
entry.second.setType(JsonNode::DATA_STRUCT);
|
||||
JsonUtils::inherit(entry.second, base);
|
||||
|
||||
ObjectTemplate tmpl;
|
||||
tmpl.id = Obj(type);
|
||||
tmpl.subid = subtype;
|
||||
tmpl.stringID = entry.first; // FIXME: create "fullID" - type.object.template?
|
||||
tmpl.readJson(data);
|
||||
tmpl.readJson(entry.second);
|
||||
templates.push_back(tmpl);
|
||||
}
|
||||
}
|
||||
@ -596,6 +601,7 @@ void AObjectTypeHandler::addTemplate(ObjectTemplate templ)
|
||||
|
||||
void AObjectTypeHandler::addTemplate(JsonNode config)
|
||||
{
|
||||
config.setType(JsonNode::DATA_STRUCT); // ensure that input is not null
|
||||
JsonUtils::inherit(config, base);
|
||||
ObjectTemplate tmpl;
|
||||
tmpl.id = Obj(type);
|
||||
|
Loading…
Reference in New Issue
Block a user