CObjectClassesHandler::ObjectContainter * CObjectClassesHandler::loadFromJson(const JsonNode & json) { auto obj = new ObjectContainter(); obj->name = json["name"].String(); obj->handlerName = json["handler"].String(); obj->base = json["base"]; obj->id = selectNextID(json["index"], objects, 256); for (auto entry : json["types"].Struct()) { loadObjectEntry(entry.second, obj); } return obj; }
void CObjectClassesHandler::loadSubObject(const std::string & identifier, JsonNode config, si32 ID, boost::optional<si32> subID) { config.setType(JsonNode::JsonType::DATA_STRUCT); // ensure that input is not NULL assert(objects.count(ID)); if (subID) { assert(objects.at(ID)->subObjects.count(subID.get()) == 0); assert(config["index"].isNull()); config["index"].Float() = subID.get(); } inheritNodeWithMeta(config, objects.at(ID)->base); loadObjectEntry(identifier, config, objects[ID]); }
void CObjectClassesHandler::loadSubObject(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) { assert(objects.at(ID)->objects.count(subID.get()) == 0); assert(config["index"].isNull()); config["index"].Float() = subID.get(); } std::string oldMeta = config.meta; // FIXME: move into inheritNode? JsonUtils::inherit(config, objects.at(ID)->base); config.setMeta(oldMeta); loadObjectEntry(config, objects[ID]); }
CObjectClassesHandler::ObjectContainter * CObjectClassesHandler::loadFromJson(const JsonNode & json, const std::string & name) { auto obj = new ObjectContainter(); obj->identifier = name; obj->name = json["name"].String(); obj->handlerName = json["handler"].String(); obj->base = json["base"]; obj->id = selectNextID(json["index"], objects, 256); if(json["defaultAiValue"].isNull()) obj->groupDefaultAiValue = boost::none; else obj->groupDefaultAiValue = json["defaultAiValue"].Integer(); for (auto entry : json["types"].Struct()) { loadObjectEntry(entry.first, entry.second, obj); } return obj; }