void AObjectTypeHandler::init(const JsonNode & input, boost::optional<std::string> name) { base = input["base"]; if (!input["rmg"].isNull()) { rmgInfo.value = input["rmg"]["value"].Float(); rmgInfo.mapLimit = loadJsonOrMax(input["rmg"]["mapLimit"]); rmgInfo.zoneLimit = loadJsonOrMax(input["rmg"]["zoneLimit"]); rmgInfo.rarity = input["rmg"]["rarity"].Float(); } // else block is not needed - set in constructor for (auto entry : input["templates"].Struct()) { 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(entry.second); templates.push_back(tmpl); } if (input["name"].isNull()) objectName = name; else objectName.reset(input["name"].String()); initTypeData(input); }
void AObjectTypeHandler::addTemplate(JsonNode config) { config.setType(JsonNode::JsonType::DATA_STRUCT); // ensure that input is not null JsonUtils::inherit(config, base); ObjectTemplate tmpl; tmpl.id = Obj(type); tmpl.subid = subtype; tmpl.stringID = ""; // TODO? tmpl.readJson(config); templates.push_back(tmpl); }