QString IQSanComponentSkin::_readImageConfig(const QString &key, QRect &rect, bool &clipping, QSize &newScale, bool &scaled, const QString &defaultValue) const { clipping = false; scaled = false; if (_m_imageConfig.isEmpty()) return defaultValue; const QVariant &val = _m_imageConfig[key]; QString result; if (JsonUtils::isString(val)) { result = val.toString(); } else if (val.canConvert<JsonArray>()) { JsonArray arr = val.value<JsonArray>(); if (arr.size() >= 2 && JsonUtils::isString(arr[0]) && tryParse(arr[1], rect)) { clipping = true; result = arr[0].toString(); if (arr.size() > 3 && tryParse(arr[3], newScale)) scaled = true; } } else { qWarning("Unable to read configuration: %s", key.toLatin1().constData()); return defaultValue; } return result; }
bool IQSanComponentSkin::AnchoredRect::tryParse(const QVariant &var) { // must be in one of the following format: // [offsetX, offestY, sizeX, sizeY] // [childAnchor, parentAnchor, [offsetX, offsetY]] // [childAnchor, parentAnchor, [offsetX, offsetY], [sizeX, sizeY]] if (!var.canConvert<JsonArray>()) return false; m_useFixedSize = false; m_anchorChild = m_anchorParent = Qt::AlignLeft | Qt::AlignTop; JsonArray value = var.value<JsonArray>(); if (JsonUtils::isNumberArray(value, 0, 3)) { QRect rect; bool success = JsonUtils::tryParse(value, rect); if (!success) return false; m_useFixedSize = true; m_fixedSize = rect.size(); m_offset = rect.topLeft(); } else if (JsonUtils::isStringArray(value, 0, 0) && value.size() >= 3 && JsonUtils::isNumberArray(value[2], 0, 1)) { if (JsonUtils::tryParse(value[0], m_anchorChild) && JsonUtils::tryParse(value[1], m_anchorParent) && JsonUtils::tryParse(value[2], m_offset)) { if (value.size() >= 4 && JsonUtils::isNumberArray(value[3].value<JsonArray>(), 0, 1) && JsonUtils::tryParse(value[3], m_fixedSize)) m_useFixedSize = true; return true; } } return false; }
bool QSanProtocol::Countdown::tryParse(const QVariant &var) { if (!var.canConvert<JsonArray>()) return false; JsonArray val = var.value<JsonArray>(); //compatible with old JSON representation of Countdown if (JsonUtils::isString(val[0])) { if (val[0].toString() == QStringLiteral("MG_COUNTDOWN")) val.removeFirst(); else return false; } if (val.size() == 2) { if (!JsonUtils::isNumberArray(val, 0, 1)) return false; current = (time_t)val[0].toInt(); max = (time_t)val[1].toInt(); type = S_COUNTDOWN_USE_SPECIFIED; return true; } else if (val.size() == 1 && val[0].canConvert<int>()) { CountdownType type = (CountdownType)val[0].toInt(); if (type != S_COUNTDOWN_NO_LIMIT && type != S_COUNTDOWN_USE_DEFAULT) return false; else this->type = type; return true; } else return false; }
void History::fromJson(JsonArray& json) { int i,j; for (i = json.size() > N ? json.size() - N : 0, j = 0; i < json.size(); i++, j++) { _records[j] = json.get(i); } _last = j; }
bool JsonUtils::tryParse(const QVariant &arg, QColor &color) { JsonArray args = arg.value<JsonArray>(); if (args.size() < 3) return false; color.setRed(args[0].toInt()); color.setGreen(args[1].toInt()); color.setBlue(args[2].toInt()); color.setAlpha(args.size() > 3 ? args[3].toInt() : 255); return true; }
static void write_object( JsonIn &jsin, JsonOut &jsout, int depth, bool force_wrap ) { jsout.start_object( force_wrap ); jsin.start_object(); while( !jsin.end_object() ) { std::string name = jsin.get_member_name(); jsout.member( name ); bool override_wrap = false; if( name == "rows" || name == "blueprint" ) { // Introspect into the row, if it has more than one element, force it to wrap. int in_start_pos = jsin.tell(); bool ate_seperator = jsin.get_ate_separator(); { JsonArray arr = jsin.get_array(); if( arr.size() > 1 ) { override_wrap = true; } } jsin.seek( in_start_pos ); jsin.set_ate_separator( ate_seperator ); } format( jsin, jsout, depth, override_wrap ); } jsout.end_object(); }
////////////////// mission.h //// void mission::deserialize(JsonIn &jsin) { JsonObject jo = jsin.get_object(); if (jo.has_member("type_id")) { type = &(g->mission_types[jo.get_int("type_id")]); } jo.read("description", description); jo.read("failed", failed); jo.read("value", value); jo.read("reward", reward); jo.read("uid", uid ); JsonArray ja = jo.get_array("target"); if (ja.size() == 2) { target.x = ja.get_int(0); target.y = ja.get_int(1); } follow_up = mission_id(jo.get_int("follow_up", follow_up)); item_id = itype_id(jo.get_string("item_id", item_id)); jo.read("deadline", deadline ); jo.read("step", step ); jo.read("count", count ); jo.read("npc_id", npc_id ); jo.read("good_fac_id", good_fac_id ); jo.read("bad_fac_id", bad_fac_id ); }
QAbstractAnimation *QSanRoomSkin::createHuaShenAnimation(QPixmap &huashenAvatar, QPoint topLeft, QGraphicsItem *parent, QGraphicsItem *&huashenAvatarCreated) const { QLabel *avatar = new QLabel; avatar->setStyleSheet("QLabel { background-color: transparent; }"); avatar->setPixmap(huashenAvatar); QGraphicsProxyWidget *widget = new QGraphicsProxyWidget(parent); widget->setWidget(avatar); widget->setPos(topLeft); QPropertyAnimation *animation = new QPropertyAnimation(widget, "opacity"); animation->setLoopCount(2000); JsonArray huashenConfig = _m_animationConfig["huashen"].value<JsonArray>(); int duration; if (tryParse(huashenConfig[0], duration) && huashenConfig[1].canConvert<JsonArray>()) { animation->setDuration(duration); JsonArray keyValues = huashenConfig[1].value<JsonArray>(); for (int i = 0; i < keyValues.size(); i++) { QVariant keyValue = keyValues[i]; if (!keyValue.canConvert<JsonArray>() || keyValue.value<JsonArray>().length() != 2) continue; double step; double val; JsonArray keyArr = keyValue.value<JsonArray>(); if (!tryParse(keyArr[0], step) || !tryParse(keyArr[1], val)) continue; animation->setKeyValueAt(step, val); } } huashenAvatarCreated = widget; return animation; }
bool IQSanComponentSkin::QSanSimpleTextFont::tryParse(const QVariant &args) { JsonArray arg = args.value<JsonArray>(); if (arg.size() < 4) return false; m_vertical = false; QString fontPath = arg[0].toString(); if (fontPath.startsWith("@")) { m_vertical = true; fontPath.remove(0, 1); } if (_m_fontBank.contains(fontPath)) m_fontFace = _m_fontBank[fontPath]; else { m_fontFace = QSanUiUtils::QSanFreeTypeFont::loadFont(fontPath); _m_fontBank[fontPath] = m_fontFace; } if (JsonUtils::isNumber(arg[1])) { int size = arg[1].toInt(); m_fontSize.setWidth(size); m_fontSize.setHeight(size); m_spacing = 0; } else { JsonArray arg1 = arg[1].value<JsonArray>(); m_fontSize.setWidth(arg1[0].toInt()); m_fontSize.setHeight(arg1[1].toInt()); m_spacing = arg1[2].toInt(); } m_weight = arg[2].toInt(); JsonUtils::tryParse(arg[3], m_color); return true; }
void ToyControl::init(char* json) { JsonParser<32> parser; JsonArray root = parser.parse(json); if (!root.success()) { HTTP_DEBUG_PRINTLN("JsonParser.parse() failed"); return; } else { if (root.size() == 0) { return; } id = String((char*)root[0]["id"]); battleId = String((char*)root[0]["battle_id"]); toyDeviceId = String((char*)root[0]["toy_device_id"]); type = String((char*)root[0]["type"]); HTTP_DEBUG_PRINT("id: "); HTTP_DEBUG_PRINTLN(id); HTTP_DEBUG_PRINT("battleId: "); HTTP_DEBUG_PRINTLN(battleId); HTTP_DEBUG_PRINT("toyDeviceId: "); HTTP_DEBUG_PRINTLN(toyDeviceId); HTTP_DEBUG_PRINT("type: "); HTTP_DEBUG_PRINTLN(type); } }
bool map_bash_info::load(JsonObject &jsobj, std::string member, bool isfurniture) { if( jsobj.has_object(member) ) { JsonObject j = jsobj.get_object(member); if ( jsonint(j, "num_tests", num_tests ) == false ) { if ( jsonint(j, "str_min", str_min ) && jsonint(j, "str_max", str_max ) ) { num_tests = 1; } } else if ( num_tests > 0 ) { str_min = j.get_int("str_min"); str_max = j.get_int("str_max"); } jsonint(j, "str_min_blocked", str_min_blocked ); jsonint(j, "str_max_blocked", str_max_blocked ); jsonint(j, "str_min_roll", str_min_roll ); jsonint(j, "chance", chance ); jsonstring(j, "sound", sound ); jsonstring(j, "sound_fail", sound_fail ); if ( jsonstring(j, "ter_set", ter_set ) == false && isfurniture == false ) { ter_set = "t_rubble"; debugmsg("terrain[\"%s\"].bash.ter_set is not set!",jsobj.get_string("id").c_str() ); } if ( j.has_array("items") ) { JsonArray ja = j.get_array("items"); if (ja.size() > 0) { int c=0; while ( ja.has_more() ) { if ( ja.has_object(c) ) { JsonObject jio = ja.next_object(); if ( jio.has_string("item") && jio.has_int("amount") ) { if ( jio.has_int("minamount") ) { map_bash_item_drop drop( jio.get_string("item"), jio.get_int("amount"), jio.get_int("minamount") ); jsonint(jio, "chance", drop.chance); items.push_back(drop); } else { map_bash_item_drop drop( jio.get_string("item"), jio.get_int("amount") ); jsonint(jio, "chance", drop.chance); items.push_back(drop); } } else { debugmsg("terrain[\"%s\"].bash.items[%d]: invalid entry",jsobj.get_string("id").c_str(),c); } } else { debugmsg("terrain[\"%s\"].bash.items[%d]: invalid entry",jsobj.get_string("id").c_str(),c); } c++; } } } //debugmsg("%d/%d %s %s/%s %d",str_min,str_max, ter_set.c_str(), sound.c_str(), sound_fail.c_str(), items.size() ); return true; } else { return false; } }
bool JsonUtils::tryParse(const QVariant &arg, QPoint &result) { JsonArray args = arg.value<JsonArray>(); if (args.size() != 2) return false; result.setX(args[0].toInt()); result.setY(args[1].toInt()); return true; }
bool IQSanComponentSkin::QSanShadowTextFont::tryParse(const QVariant &arg) { if (!arg.isValid() || !arg.canConvert<JsonArray>()) return false; JsonArray args = arg.value<JsonArray>(); if (args.size() < 4) return false; if (!QSanSimpleTextFont::tryParse(arg)) return false; if (args.size() >= 8) { m_shadowRadius = args[4].toInt(); m_shadowDecadeFactor = args[5].toDouble(); JsonUtils::tryParse(args[6], m_shadowOffset); JsonArray color = args[7].value<JsonArray>(); m_shadowColor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt(), color[3].toInt()); } else { m_shadowRadius = -1; } return true; }
bool QSanProtocol::Packet::parse(const QByteArray &raw) { if (raw.length() > S_MAX_PACKET_SIZE) { return false; } JsonDocument doc = JsonDocument::fromJson(raw); JsonArray result = doc.array(); if (!JsonUtils::isNumberArray(result, 0, 3) || result.size() > 5) return false; globalSerial = result[0].toUInt(); localSerial = result[1].toUInt(); m_packetDescription = static_cast<PacketDescription>(result[2].toInt()); m_command = (CommandType)result[3].toInt(); if (result.size() == 5) m_messageBody = result[4]; return true; }
bool JsonUtils::tryParse(const QVariant &arg, QRect &result) { JsonArray args = arg.value<JsonArray>(); if (args.size() != 4) return false; result.setLeft(args[0].toInt()); result.setTop(args[1].toInt()); result.setWidth(args[2].toInt()); result.setHeight(args[3].toInt()); return true; }
void it_artifact_armor::deserialize(JsonObject &jo) { id = jo.get_string("id"); name = jo.get_string("name"); description = jo.get_string("description"); sym = jo.get_int("sym"); color = int_to_color(jo.get_int("color")); price = jo.get_int("price"); // LEGACY: Since it seems artifacts get serialized out to disk, and they're // dynamic, we need to allow for them to be read from disk for, oh, I guess // quite some time. Loading and saving once will write things out as a JSON // array. if (jo.has_string("m1")) { materials.push_back(jo.get_string("m1")); } if (jo.has_string("m2")) { materials.push_back(jo.get_string("m2")); } // Assumption, perhaps dangerous, that we won't wind up with m1 and m2 and // a materials array in our serialized objects at the same time. if (jo.has_array("materials")) { JsonArray jarr = jo.get_array("materials"); for (int i = 0; i < jarr.size(); ++i) { materials.push_back(jarr.get_string(i)); } } if (materials.size() == 0) { // I don't think we need this, but a lot of code seems to want at least // one material and I'm not sure I found every single corner case. materials.push_back("null"); } volume = jo.get_int("volume"); weight = jo.get_int("weight"); melee_dam = jo.get_int("melee_dam"); melee_cut = jo.get_int("melee_cut"); m_to_hit = jo.get_int("m_to_hit"); item_tags = jo.get_tags("item_flags"); jo.read( "covers", covers); encumber = jo.get_int("encumber"); coverage = jo.get_int("coverage"); thickness = jo.get_int("material_thickness"); env_resist = jo.get_int("env_resist"); warmth = jo.get_int("warmth"); storage = jo.get_int("storage"); power_armor = jo.get_bool("power_armor"); JsonArray ja = jo.get_array("effects_worn"); while (ja.has_more()) { effects_worn.push_back((art_effect_passive)ja.next_int()); } }
Status loginServerOtpPending(std::list<DataChunk> users, std::list<bool> &isPending) { const auto url = ABC_SERVER_ROOT "/v1/otp/pending/check"; std::string param; std::map<std::string, bool> userMap; std::list<std::string> usersEncoded; for (const auto &u : users) { std::string username = base64Encode(u); param += (username + ","); userMap[username] = false; usersEncoded.push_back(username); } JsonObject json; ABC_CHECK(json.set("l1s", param)); HttpReply reply; ABC_CHECK(AirbitzRequest().post(reply, url, json.encode())); ServerReplyJson replyJson; ABC_CHECK(replyJson.decode(reply)); JsonArray arrayJson = replyJson.results(); size_t size = arrayJson.size(); for (size_t i = 0; i < size; i++) { json_t *pJSON_Row = arrayJson[i].get(); if (!pJSON_Row || !json_is_object(pJSON_Row)) return ABC_ERROR(ABC_CC_JSONError, "Error parsing JSON array element object"); json_t *pJSON_Value = json_object_get(pJSON_Row, "login"); if (!pJSON_Value || !json_is_string(pJSON_Value)) return ABC_ERROR(ABC_CC_JSONError, "Error otp/pending/login JSON"); std::string username(json_string_value(pJSON_Value)); pJSON_Value = json_object_get(pJSON_Row, ABC_SERVER_JSON_OTP_PENDING); if (!pJSON_Value || !json_is_boolean(pJSON_Value)) return ABC_ERROR(ABC_CC_JSONError, "Error otp/pending/pending JSON"); if (json_is_true(pJSON_Value)) { userMap[username] = json_is_true(pJSON_Value); } } isPending.clear(); for (auto &username: usersEncoded) { isPending.push_back(userMap[username]); } return Status(); }
void item_comp::load( JsonArray &ja ) { JsonArray comp = ja.next_array(); type = comp.get_string( 0 ); count = comp.get_int( 1 ); // Recoverable is true by default. if( comp.size() > 2 ) { recoverable = comp.get_string( 2 ) == "NO_RECOVER" ? false : true; } if( count <= 0 ) { ja.throw_error( "item count must be a positive number" ); } }
void load_colors(JsonObject &jsobj) { std::string colors[16]={"BLACK","RED","GREEN","BROWN","BLUE","MAGENTA","CYAN","GRAY", "DGRAY","LRED","LGREEN","YELLOW","LBLUE","LMAGENTA","LCYAN","WHITE"}; JsonArray jsarr; for(int c=0;c<16;c++) { jsarr = jsobj.get_array(colors[c]); if(jsarr.size()<3)continue; consolecolors[colors[c]].clear(); consolecolors[colors[c]].push_back(jsarr.get_int(2)); consolecolors[colors[c]].push_back(jsarr.get_int(1)); consolecolors[colors[c]].push_back(jsarr.get_int(0)); } }
void tool_comp::load( JsonArray &ja ) { if( ja.test_string() ) { // constructions uses this format: [ "tool", ... ] type = ja.next_string(); count = -1; } else { JsonArray comp = ja.next_array(); type = comp.get_string( 0 ); count = comp.get_int( 1 ); requirement = comp.size() > 2 && comp.get_string( 2 ) == "LIST"; } if( count == 0 ) { ja.throw_error( "tool count must not be 0" ); } // Note: negative count means charges (of the tool) should be consumed }
void Item_factory::set_material_from_json(JsonObject& jo, std::string member, itype* new_item_template) { //If the value isn't found, just return a group of null materials std::string material_list[2] = {"null", "null"}; if( jo.has_array(member) ) { JsonArray jarr = jo.get_array(member); if (jarr.size() > 2) { debugmsg("Too many materials provided for item %s", new_item_template->id.c_str()); } material_list[0] = jarr.get_string(0); material_list[1] = jarr.get_string(1); } else if ( jo.has_string(member) ) { material_list[0] = jo.get_string(member); } new_item_template->m1 = material_list[0]; new_item_template->m2 = material_list[1]; }
QPixmap QSanRoomSkin::getProgressBarPixmap(int percentile) const { QVariant allMaps_var = _m_imageConfig[S_SKIN_KEY_PROGRESS_BAR_IMAGE]; if (!allMaps_var.canConvert<JsonArray>()) return QPixmap(1, 1); JsonArray allMaps = allMaps_var.value<JsonArray>(); for (int i = 0; i < allMaps.size(); i++) { if (!isNumber(allMaps[i].value<JsonArray>()[0])) continue; int thred = allMaps[i].value<JsonArray>()[0].toInt(); if (thred >= percentile) { if (!isString(allMaps[i].value<JsonArray>()[1])) continue; return getPixmapFromFileName(allMaps[i].value<JsonArray>()[1].toString(), true); } } return QPixmap(1, 1); }
void item_comp::load( JsonArray &ja ) { JsonArray comp = ja.next_array(); type = comp.get_string( 0 ); count = comp.get_int( 1 ); size_t handled = 2; while( comp.size() > handled ) { const std::string &flag = comp.get_string( handled++ ); if( flag == "NO_RECOVER" ) { recoverable = false; } else if( flag == "LIST" ) { requirement = true; } } if( count <= 0 ) { ja.throw_error( "item count must be a positive number" ); } }
bool JsonHelper::writeJson(JsonArray json, string path) { if(!validatePathExtension(path)) { return false; } string arrayString = "["; size_t jsonSize = json.size(); for(size_t i = 0; i < jsonSize; ++i) { arrayString += "\n" + dump(json.at(i).object_items(), 1); if(i != jsonSize - 1) { arrayString += ","; } } arrayString += "\n]"; ofstream JsonSaveFile(path); JsonSaveFile << arrayString; JsonSaveFile.close(); return true; }
bool QSanRoomSkin::_loadLayoutConfig(const QVariant &layout) { JsonObject layoutConfig = layout.value<JsonObject>(); JsonObject config = layoutConfig[S_SKIN_KEY_COMMON].value<JsonObject>(); tryParse(config["cardNormalHeight"], _m_commonLayout.m_cardNormalHeight); tryParse(config["cardNormalWidth"], _m_commonLayout.m_cardNormalWidth); tryParse(config["hpExtraSpaceHolder"], _m_commonLayout.m_hpExtraSpaceHolder); tryParse(config["cardMainArea"], _m_commonLayout.m_cardMainArea); tryParse(config["cardSuitArea"], _m_commonLayout.m_cardSuitArea); tryParse(config["cardNumberArea"], _m_commonLayout.m_cardNumberArea); tryParse(config["cardFrameArea"], _m_commonLayout.m_cardFrameArea); tryParse(config["cardFootnoteArea"], _m_commonLayout.m_cardFootnoteArea); tryParse(config["cardAvatarArea"], _m_commonLayout.m_cardAvatarArea); tryParse(config["chooseGeneralBoxSwitchIconSizeThreshold"], _m_commonLayout.m_chooseGeneralBoxSwitchIconSizeThreshold); tryParse(config["chooseGeneralBoxSwitchIconEachRow"], _m_commonLayout.m_chooseGeneralBoxSwitchIconEachRow); tryParse(config["chooseGeneralBoxSwitchIconEachRowForTooManyGenerals"], _m_commonLayout.m_chooseGeneralBoxSwitchIconEachRowForTooManyGenerals); tryParse(config["chooseGeneralBoxNoIconThreshold"], _m_commonLayout.m_chooseGeneralBoxNoIconThreshold); tryParse(config["chooseGeneralBoxDenseIconSize"], _m_commonLayout.m_chooseGeneralBoxDenseIconSize); tryParse(config["chooseGeneralBoxSparseIconSize"], _m_commonLayout.m_chooseGeneralBoxSparseIconSize); tryParse(config["tinyAvatarSize"], _m_commonLayout.m_tinyAvatarSize); tryParse(config["bubbleChatBoxShowAreaSize"], _m_commonLayout.m_bubbleChatBoxShowAreaSize); _m_commonLayout.m_cardFootnoteFont.tryParse(config["cardFootnoteFont"]); JsonArray magatamaFont = config["magatamaFont"].value<JsonArray>(); for (int i = 0; i < 6 && i < magatamaFont.size(); i++) { _m_commonLayout.m_hpFont[i].tryParse(magatamaFont[i]); } config = layoutConfig[S_SKIN_KEY_ROOM].value<JsonObject>(); tryParse(config["chatBoxHeightPercentage"], _m_roomLayout.m_chatBoxHeightPercentage); tryParse(config["chatTextBoxHeight"], _m_roomLayout.m_chatTextBoxHeight); tryParse(config["discardPileMinWidth"], _m_roomLayout.m_discardPileMinWidth); tryParse(config["discardPilePadding"], _m_roomLayout.m_discardPilePadding); tryParse(config["infoPlaneWidthPercentage"], _m_roomLayout.m_infoPlaneWidthPercentage); tryParse(config["logBoxHeightPercentage"], _m_roomLayout.m_logBoxHeightPercentage); tryParse(config["minimumSceneSize"], _m_roomLayout.m_minimumSceneSize); tryParse(config["maximumSceneSize"], _m_roomLayout.m_maximumSceneSize); tryParse(config["minimumSceneSize-10player"], _m_roomLayout.m_minimumSceneSize10Player); tryParse(config["maximumSceneSize-10player"], _m_roomLayout.m_maximumSceneSize10Player); tryParse(config["photoHDistance"], _m_roomLayout.m_photoHDistance); tryParse(config["photoVDistance"], _m_roomLayout.m_photoVDistance); tryParse(config["photoDashboardPadding"], _m_roomLayout.m_photoDashboardPadding); tryParse(config["photoRoomPadding"], _m_roomLayout.m_photoRoomPadding); tryParse(config["roleBoxHeight"], _m_roomLayout.m_roleBoxHeight); tryParse(config["scenePadding"], _m_roomLayout.m_scenePadding); for (int i = 0; i < 2; i++) { JsonObject playerConfig; PlayerCardContainerLayout *layout; if (i == 0) { layout = &_m_photoLayout; playerConfig = layoutConfig[S_SKIN_KEY_PHOTO].value<JsonObject>(); } else { layout = &_m_dashboardLayout; playerConfig = layoutConfig[S_SKIN_KEY_DASHBOARD].value<JsonObject>(); } tryParse(playerConfig["normalHeight"], layout->m_normalHeight); tryParse(playerConfig["handCardNumIconArea"], layout->m_handCardArea); JsonArray equipAreas = playerConfig["equipAreas"].value<JsonArray>(); for (int j = 0; j < S_EQUIP_AREA_LENGTH && j < equipAreas.size(); j++) tryParse(equipAreas[j], layout->m_equipAreas[j]); tryParse(playerConfig["equipImageArea"], layout->m_equipImageArea); tryParse(playerConfig["equipSuitArea"], layout->m_equipSuitArea); tryParse(playerConfig["equipPointArea"], layout->m_equipPointArea); tryParse(playerConfig["horseImageArea"], layout->m_horseImageArea); tryParse(playerConfig["horseSuitArea"], layout->m_horseSuitArea); tryParse(playerConfig["horsePointArea"], layout->m_horsePointArea); if (!layout->m_equipPointFontBlack.tryParse(playerConfig["equipPointFontBlack"])) layout->m_equipPointFontBlack.tryParse(playerConfig["equipPointFont"]); if (!layout->m_equipPointFontRed.tryParse(playerConfig["equipPointFontRed"])) layout->m_equipPointFontRed.tryParse(playerConfig["equipPointFont"]); tryParse(playerConfig["delayedTrickFirstRegion"], layout->m_delayedTrickFirstRegion); tryParse(playerConfig["delayedTrickStep"], layout->m_delayedTrickStep); layout->m_markTextArea.tryParse(playerConfig["markTextArea"]); tryParse(playerConfig["roleComboBoxPos"], layout->m_roleComboBoxPos); tryParse(playerConfig["avatarArea"], layout->m_avatarArea); tryParse(playerConfig["secondaryAvatarArea"], layout->m_smallAvatarArea); tryParse(playerConfig["circleArea"], layout->m_circleArea); tryParse(playerConfig["avatarImageType"], layout->m_avatarSize); tryParse(playerConfig["secondaryAvatarImageType"], layout->m_smallAvatarSize); tryParse(playerConfig["primaryAvatarImageType"], layout->m_primaryAvatarSize); tryParse(playerConfig["circleImageType"], layout->m_circleImageSize); tryParse(playerConfig["avatarNameArea"], layout->m_avatarNameArea); layout->m_avatarNameFont.tryParse(playerConfig["avatarNameFont"]); tryParse(playerConfig["smallAvatarNameArea"], layout->m_smallAvatarNameArea); layout->m_smallAvatarNameFont.tryParse(playerConfig["smallAvatarNameFont"]); tryParse(playerConfig["kingdomMaskArea"], layout->m_kingdomMaskArea); tryParse(playerConfig["kingdomIconArea"], layout->m_kingdomIconArea); layout->m_handCardFont.tryParse(playerConfig["handCardFont"]); tryParse(playerConfig["screenNameArea"], layout->m_screenNameArea); layout->m_screenNameFont.tryParse(playerConfig["screenNameFont"]); layout->m_progressBarArea.tryParse(playerConfig["progressBarArea"]); tryParse(playerConfig["progressBarHorizontal"], layout->m_isProgressBarHorizontal); tryParse(playerConfig["magatamaSize"], layout->m_magatamaSize); tryParse(playerConfig["magatamaImageArea"], layout->m_magatamaImageArea); tryParse(playerConfig["magatamasHorizontal"], layout->m_magatamasHorizontal); tryParse(playerConfig["magatamasBgVisible"], layout->m_magatamasBgVisible); JsonArray magatamasAnchor = playerConfig["magatamasAnchor"].value<JsonArray>(); if (!magatamasAnchor.isEmpty()) { if (magatamasAnchor.size() > 1) tryParse(magatamasAnchor[1], layout->m_magatamasAnchor); if (JsonUtils::isString(magatamasAnchor[0])) tryParse(magatamasAnchor[0], layout->m_magatamasAlign); } layout->m_phaseArea.tryParse(playerConfig["phaseArea"]); tryParse(playerConfig["privatePileStartPos"], layout->m_privatePileStartPos); tryParse(playerConfig["privatePileStep"], layout->m_privatePileStep); tryParse(playerConfig["privatePileButtonSize"], layout->m_privatePileButtonSize); tryParse(playerConfig["actionedIconRegion"], layout->m_actionedIconRegion); tryParse(playerConfig["saveMeIconRegion"], layout->m_saveMeIconRegion); tryParse(playerConfig["chainedIconRegion"], layout->m_chainedIconRegion); layout->m_deathIconRegion.tryParse(playerConfig["deathIconRegion"]); tryParse(playerConfig["votesIconRegion"], layout->m_votesIconRegion); tryParse(playerConfig["drankMaskColor"], layout->m_drankMaskColor); tryParse(playerConfig["duanchangMaskColor"], layout->m_duanchangMaskColor); tryParse(playerConfig["deathEffectColor"], layout->m_deathEffectColor); tryParse(playerConfig["extraSkillArea"], layout->m_extraSkillArea); layout->m_extraSkillFont.tryParse(playerConfig["extraSkillFont"]); tryParse(playerConfig["extraSkillTextArea"], layout->m_extraSkillTextArea); } config = layoutConfig[S_SKIN_KEY_PHOTO].value<JsonObject>(); tryParse(config["normalWidth"], _m_photoLayout.m_normalWidth); if (!tryParse(config["focusFrameArea"], _m_photoLayout.m_focusFrameArea) && isNumber(config["borderWidth"])) { int borderWidth = 0; tryParse(config["borderWidth"], borderWidth); _m_photoLayout.m_focusFrameArea = QRect(-borderWidth, -borderWidth, _m_photoLayout.m_normalWidth + 2 * borderWidth, _m_photoLayout.m_normalHeight + 2 * borderWidth); } tryParse(config["mainFrameArea"], _m_photoLayout.m_mainFrameArea); tryParse(config["onlineStatusArea"], _m_photoLayout.m_onlineStatusArea); tryParse(config["onlineStatusBgColor"], _m_photoLayout.m_onlineStatusBgColor); _m_photoLayout.m_onlineStatusFont.tryParse(config["onlineStatusFont"]); tryParse(config["cardMoveArea"], _m_photoLayout.m_cardMoveRegion); tryParse(config["skillNameArea"], _m_photoLayout.m_skillNameArea); _m_photoLayout.m_skillNameFont.tryParse(config["skillNameFont"]); tryParse(config["canvasArea"], _m_photoLayout.m_boundingRect); config = layoutConfig[S_SKIN_KEY_DASHBOARD].value<JsonObject>(); tryParse(config["leftWidth"], _m_dashboardLayout.m_leftWidth); tryParse(config["rightWidth"], _m_dashboardLayout.m_rightWidth); tryParse(config["floatingAreaHeight"], _m_dashboardLayout.m_floatingAreaHeight); tryParse(config["focusFrameArea"], _m_dashboardLayout.m_focusFrameArea); tryParse(config["buttonSetSize"], _m_dashboardLayout.m_buttonSetSize); tryParse(config["confirmButtonArea"], _m_dashboardLayout.m_confirmButtonArea); tryParse(config["cancelButtonArea"], _m_dashboardLayout.m_cancelButtonArea); tryParse(config["discardButtonArea"], _m_dashboardLayout.m_discardButtonArea); tryParse(config["trustButtonArea"], _m_dashboardLayout.m_trustButtonArea); tryParse(config["equipBorderPos"], _m_dashboardLayout.m_equipBorderPos); tryParse(config["equipSelectedOffset"], _m_dashboardLayout.m_equipSelectedOffset); tryParse(config["disperseWidth"], _m_dashboardLayout.m_disperseWidth); tryParse(config["trustEffectColor"], _m_dashboardLayout.m_trustEffectColor); tryParse(config["skillDockLeftMargin"], _m_dashboardLayout.m_skillDockLeftMargin); tryParse(config["skillDockRightMargin"], _m_dashboardLayout.m_skillDockRightMargin); tryParse(config["skillDockBottomMargin"], _m_dashboardLayout.m_skillDockBottomMargin); config = layoutConfig["skillButton"].value<JsonObject>(); JsonArray configWidth = config["width"].value<JsonArray>(); JsonArray configTextArea = config["textArea"].value<JsonArray>(); JsonArray configTextAreaDown = config["textAreaDown"].value<JsonArray>(); JsonArray configTextFont = config["textFont"].value<JsonArray>(); for (int i = 0; i < 3; i++) { int height = 0; if (tryParse(config["height"], height)) _m_dashboardLayout.m_skillButtonsSize[i].setHeight(height); int width = 0; if (i < configWidth.size() && tryParse(configWidth[i], width)) _m_dashboardLayout.m_skillButtonsSize[i].setWidth(width); if (i < configTextArea.size()) tryParse(configTextArea[i], _m_dashboardLayout.m_skillTextArea[i]); if (i < configTextAreaDown.size()) tryParse(configTextAreaDown[i], _m_dashboardLayout.m_skillTextAreaDown[i]); if (i < configTextFont.size()) _m_dashboardLayout.m_skillTextFonts[i].tryParse(configTextFont[i]); } for (int i = 0; i < QSanInvokeSkillButton::S_NUM_SKILL_TYPES; i++) { QString key; switch ((QSanInvokeSkillButton::SkillType)i) { case QSanInvokeSkillButton::S_SKILL_AWAKEN: key = "awakenFontColor"; break; case QSanInvokeSkillButton::S_SKILL_COMPULSORY: key = "compulsoryFontColor"; break; case QSanInvokeSkillButton::S_SKILL_FREQUENT: key = "frequentFontColor"; break; case QSanInvokeSkillButton::S_SKILL_ONEOFF_SPELL: key = "oneoffFontColor"; break; case QSanInvokeSkillButton::S_SKILL_PROACTIVE: key = "proactiveFontColor"; break; case QSanInvokeSkillButton::S_SKILL_ATTACHEDLORD: key = "attachedlordFontColor"; break; default: Q_ASSERT(false); break; } JsonArray subconfig = config[key].value<JsonArray>(); for (int j = 0; j < 4 && j < subconfig.size(); j++) { int index = i * 4 + j; JsonArray config = subconfig[j].value<JsonArray>(); if (config.size() < 2) continue; tryParse(config[0], _m_dashboardLayout.m_skillTextColors[index]); tryParse(config[1], _m_dashboardLayout.m_skillTextShadowColors[index]); } } return true; }
/* * load player from ginormous json blob */ void player::deserialize(JsonIn &jsin) { JsonObject data = jsin.get_object(); JsonArray parray; json_load_common_variables( data ); std::string prof_ident="(null)"; if ( data.read("profession",prof_ident) && profession::exists(prof_ident) ) { prof = profession::prof(prof_ident); } else { debugmsg("Tried to use non-existent profession '%s'", prof_ident.c_str()); } data.read("activity",activity); data.read("backlog",backlog); data.read("driving_recoil",driving_recoil); data.read("in_vehicle",in_vehicle); data.read("controlling_vehicle",controlling_vehicle); data.read("grab_point", grab_point); std::string grab_typestr="OBJECT_NONE"; if( grab_point.x != 0 || grab_point.y != 0 ) { grab_typestr = "OBJECT_VEHICLE"; data.read( "grab_type", grab_typestr); } if ( obj_type_id.find(grab_typestr) != obj_type_id.end() ) { grab_type = (object_type)obj_type_id[grab_typestr]; } data.read( "blocks_left", num_blocks); data.read( "focus_pool", focus_pool); data.read( "style_selected", style_selected ); data.read( "health", health ); data.read( "mutations", my_mutations ); set_highest_cat_level(); drench_mut_calc(); parray = data.get_array("temp_cur"); if ( parray.size() == num_bp ) { for(int i=0; i < num_bp; i++) { temp_cur[i]=parray.get_int(i); } } else { debugmsg("Error, incompatible temp_cur in save file %s",parray.str().c_str()); } parray = data.get_array("temp_conv"); if ( parray.size() == num_bp ) { for(int i=0; i < num_bp; i++) { temp_conv[i]=parray.get_int(i); } } else { debugmsg("Error, incompatible temp_conv in save file %s",parray.str().c_str()); } parray = data.get_array("frostbite_timer"); if ( parray.size() == num_bp ) { for(int i=0; i < num_bp; i++) { frostbite_timer[i]=parray.get_int(i); } } else { debugmsg("Error, incompatible frostbite_timer in save file %s",parray.str().c_str()); } parray = data.get_array("learned_recipes"); if ( !parray.empty() ) { learned_recipes.clear(); std::string pstr=""; while ( parray.has_more() ) { if ( parray.read_next(pstr) ) { learned_recipes[ pstr ] = recipe_by_name( pstr ); } } } data.read("morale", morale); data.read( "active_mission", active_mission ); data.read( "active_missions", active_missions ); data.read( "failed_missions", failed_missions ); data.read( "completed_missions", completed_missions ); stats & pstats = *lifetime_stats(); data.read("player_stats",pstats); inv.clear(); if ( data.has_member("inv") ) { JsonIn* jip = data.get_raw("inv"); inv.json_load_items( *jip ); } if ( data.has_member("invcache") ) { JsonIn* jip = data.get_raw("invcache"); inv.json_load_invcache( *jip ); } worn.clear(); data.read("worn", worn); weapon.contents.clear(); data.read("weapon", weapon); }
void RecAnalysis::initialize(QString dir) { QList<QByteArray> records_line; if (dir.isEmpty()) { records_line = ClientInstance->getRecords(); } else if (dir.endsWith(".qsgs")) { QFile file(dir); if (file.open(QIODevice::ReadOnly)) { char header; file.getChar(&header); if (header == 0) { QByteArray lines = file.readAll(); lines = qUncompress(lines); records_line = lines.split('\n'); } else { file.ungetChar(header); while (!file.atEnd()) records_line << file.readLine(); } } } else { QMessageBox::warning(NULL, tr("Warning"), tr("The file is unreadable")); return; } records_line.removeAll(QByteArray()); QStringList role_list; foreach (const QByteArray &_line, records_line) { QByteArray line = _line; line.remove(0, line.indexOf(' ')); Packet packet; if (!packet.parse(line)) continue; if (packet.getCommandType() == S_COMMAND_SETUP) { const QVariant &body = packet.getMessageBody(); if (JsonUtils::isString(body)) { QString l = body.toString(); QRegExp rx("(.*):(@?\\w+):(\\d+):(\\d+):([+\\w-]*):([RCFSTBHAMN123a-r]*)(\\s+)?"); if (!rx.exactMatch(l)) continue; QStringList texts = rx.capturedTexts(); m_recordGameMode = texts.at(2); m_recordPlayers = texts.at(2).split("_").first().remove(QRegExp("[^0-9]")).toInt(); QStringList ban_packages = texts.at(5).split("+"); foreach (const Package *package, Sanguosha->getPackages()) { if (!ban_packages.contains(package->objectName()) && Sanguosha->getScenario(package->objectName()) == NULL) m_recordPackages << Sanguosha->translate(package->objectName()); } QString flags = texts.at(6); if (flags.contains("R")) m_recordServerOptions << tr("RandomSeats"); if (flags.contains("C")) m_recordServerOptions << tr("EnableCheat"); if (flags.contains("F")) m_recordServerOptions << tr("FreeChoose"); if (flags.contains("S")) m_recordServerOptions << tr("Enable2ndGeneral"); if (flags.contains("A")) m_recordServerOptions << tr("EnableAI"); continue; } } if (packet.getCommandType() == S_COMMAND_ARRANGE_SEATS) { role_list.clear(); JsonUtils::tryParse(packet.getMessageBody(), role_list); continue; } if (packet.getCommandType() == S_COMMAND_ADD_PLAYER) { JsonArray body = packet.getMessageBody().value<JsonArray>(); if (body.size() >= 2) { getPlayer(body[0].toString())->m_screenName = body[1].toString(); } continue; } if (packet.getCommandType() == S_COMMAND_REMOVE_PLAYER) { QString name = packet.getMessageBody().toString(); m_recordMap.remove(name); continue; } if (packet.getCommandType() == S_COMMAND_SET_PROPERTY) { QStringList self_info; if (!JsonUtils::tryParse(packet.getMessageBody(), self_info) || self_info.size() < 3) continue; const QString &who = self_info.at(0); const QString &property = self_info.at(1); const QString &value = self_info.at(2); if (who == S_PLAYER_SELF_REFERENCE_ID) { if (property == "objectName") { getPlayer(value, S_PLAYER_SELF_REFERENCE_ID)->m_screenName = Config.UserName; } else if (property == "role") { getPlayer(S_PLAYER_SELF_REFERENCE_ID)->m_role = value; } else if (property == "general") { getPlayer(S_PLAYER_SELF_REFERENCE_ID)->m_generalName = value; } else if (property == "general2") { getPlayer(S_PLAYER_SELF_REFERENCE_ID)->m_general2Name = value; } } else { PlayerRecordStruct *record = getPlayer(who); if (record == NULL) continue; if (self_info.at(1) == "general") { record->m_generalName = value; } else if (self_info.at(1) == "general2") { record->m_general2Name = value; } else if (self_info.at(1) == "state" && value == "robot") { record->m_statue = "robot"; } } continue; } if (packet.getCommandType() == S_COMMAND_SET_MARK) { JsonArray args = packet.getMessageBody().value<JsonArray>(); if (args.size() != 3) continue; QString who = args.at(0).toString(); QString mark = args.at(1).toString(); int num = args.at(2).toInt(); if (mark == "Global_TurnCount") { PlayerRecordStruct *rec = getPlayer(who); if (rec) { rec->m_turnCount = num; m_currentPlayer = rec; } } continue; } if (packet.getCommandType() == S_COMMAND_SPEAK) { JsonArray body = packet.getMessageBody().value<JsonArray>(); if (body.size() < 2) { continue; } QString speaker = body[0].toString(); QString words = body[1].toString(); m_recordChat += getPlayer(speaker)->m_screenName + ": " + words; m_recordChat.append("<br/>"); continue; } if (packet.getCommandType() == S_COMMAND_CHANGE_HP) { JsonArray change = packet.getMessageBody().value<JsonArray>(); if (change.size() != 3 || !JsonUtils::isString(change[0]) || !JsonUtils::isNumber(change[1]) || !JsonUtils::isNumber(change[2])) continue; QString name = change[0].toString(); int hp_change = change[1].toInt(); /*int nature_index = change[2].toInt(); DamageStruct::Nature nature = DamageStruct::Normal; if (nature_index > 0) nature = (DamageStruct::Nature)nature_index;*/ if (hp_change > 0) getPlayer(name)->m_recover += hp_change; continue; } if (packet.getCommandType() == S_COMMAND_LOG_SKILL) { QStringList log; if (!JsonUtils::tryParse(packet.getMessageBody(), log) || log.size() != 6) continue; const QString &type = log.at(0); const QString &from = log.at(1); QStringList tos = log.at(2).split('+'); //const QString &card_str = log.at(3); const QString arg = log.at(4); //const QString arg2 = log.at(5); if (type.startsWith("#Damage")) { int damage = arg.toInt(); if (!from.isEmpty()) getPlayer(from)->m_damage += damage; getPlayer(tos.first())->m_damaged += damage; continue; } if (type == "#Murder" || type == "#Suicide") { getPlayer(from)->m_kill++; getPlayer(tos.first())->m_isAlive = false; continue; } if (type == "#Contingency") { getPlayer(tos.first())->m_isAlive = false; continue; } } }
void it_artifact_tool::deserialize(JsonObject &jo) { id = jo.get_string("id"); name = jo.get_string("name"); description = jo.get_string("description"); sym = jo.get_int("sym"); color = int_to_color(jo.get_int("color")); price = jo.get_int("price"); // LEGACY: Since it seems artifacts get serialized out to disk, and they're // dynamic, we need to allow for them to be read from disk for, oh, I guess // quite some time. Loading and saving once will write things out as a JSON // array. if (jo.has_string("m1")) { materials.push_back(jo.get_string("m1")); } if (jo.has_string("m2")) { materials.push_back(jo.get_string("m2")); } // Assumption, perhaps dangerous, that we won't wind up with m1 and m2 and // a materials array in our serialized objects at the same time. if (jo.has_array("materials")) { JsonArray jarr = jo.get_array("materials"); for (int i = 0; i < jarr.size(); ++i) { materials.push_back(jarr.get_string(i)); } } volume = jo.get_int("volume"); weight = jo.get_int("weight"); melee_dam = jo.get_int("melee_dam"); melee_cut = jo.get_int("melee_cut"); m_to_hit = jo.get_int("m_to_hit"); item_tags = jo.get_tags("item_flags"); max_charges = jo.get_long("max_charges"); def_charges = jo.get_long("def_charges"); std::vector<int> rand_charges; JsonArray jarr = jo.get_array("rand_charges"); while (jarr.has_more()) { rand_charges.push_back(jarr.next_long()); } charges_per_use = jo.get_int("charges_per_use"); turns_per_charge = jo.get_int("turns_per_charge"); ammo = jo.get_string("ammo"); revert_to = jo.get_string("revert_to"); charge_type = (art_charge)jo.get_int("charge_type"); JsonArray ja = jo.get_array("effects_wielded"); while (ja.has_more()) { effects_wielded.push_back((art_effect_passive)ja.next_int()); } ja = jo.get_array("effects_activated"); while (ja.has_more()) { effects_activated.push_back((art_effect_active)ja.next_int()); } ja = jo.get_array("effects_carried"); while (ja.has_more()) { effects_carried.push_back((art_effect_passive)ja.next_int()); } if( item_tags.count( "CHOP" ) > 0 ) { item_tags.insert( "SHEATH_SWORD" ); } if( item_tags.count( "STAB" ) > 0 ) { item_tags.insert( "SHEATH_KNIFE" ); } }
tABC_CC ABC_LoginServerOtpPending(std::list<DataChunk> users, std::list<bool> &isPending, tABC_Error *pError) { tABC_CC cc = ABC_CC_Ok; HttpReply reply; std::string url = ABC_SERVER_ROOT "/otp/pending/check"; ServerReplyJson replyJson; JsonArray arrayJson; json_t *pJSON_Root = NULL; char *szPost = NULL; std::map<std::string, bool> userMap; std::list<std::string> usersEncoded; std::string param; for (const auto &u : users) { std::string username = base64Encode(u); param += (username + ","); userMap[username] = false; usersEncoded.push_back(username); } // create the post data pJSON_Root = json_pack("{ss}", "l1s", param.c_str()); szPost = ABC_UtilStringFromJSONObject(pJSON_Root, JSON_COMPACT); // send the command ABC_CHECK_NEW(AirbitzRequest().post(reply, url, szPost)); ABC_CHECK_NEW(replyJson.decode(reply.body)); ABC_CHECK_NEW(replyJson.ok()); arrayJson = replyJson.results(); if (arrayJson) { size_t rows = arrayJson.size(); for (size_t i = 0; i < rows; i++) { json_t *pJSON_Row = arrayJson[i].get(); ABC_CHECK_ASSERT((pJSON_Row && json_is_object(pJSON_Row)), ABC_CC_JSONError, "Error parsing JSON array element object"); json_t *pJSON_Value = json_object_get(pJSON_Row, "login"); ABC_CHECK_ASSERT((pJSON_Value && json_is_string(pJSON_Value)), ABC_CC_JSONError, "Error otp/pending/login JSON"); std::string username(json_string_value(pJSON_Value)); pJSON_Value = json_object_get(pJSON_Row, ABC_SERVER_JSON_OTP_PENDING); ABC_CHECK_ASSERT((pJSON_Value && json_is_boolean(pJSON_Value)), ABC_CC_JSONError, "Error otp/pending/pending JSON"); if (json_is_true(pJSON_Value)) { userMap[username] = json_is_true(pJSON_Value);; } } } isPending.clear(); for (auto &username: usersEncoded) { isPending.push_back(userMap[username]); } exit: ABC_FREE_STR(szPost); if (pJSON_Root) json_decref(pJSON_Root); return cc; }
void player::json_load_common_variables(JsonObject & data) { JsonArray parray; // todo/maybe: // std::map<std::string, int*> strmap_common_variables; // void player::init_strmap_common_variables() { // strmap_common_variables["posx"]=&posx; // + all this below and in save_common_variables // } // load: // for(std::map<std::string, int*>::iterator it... // data.read(it->first,it->second); // save: // for(... // json.member( it->first, it->second ); if(!data.read("posx",posx) ) { // uh-oh. debugmsg("BAD PLAYER/NPC JSON: no 'posx'?"); } data.read("posy",posy); data.read("str_cur",str_cur); data.read("str_max",str_max); data.read("dex_cur",dex_cur); data.read("dex_max",dex_max); data.read("int_cur",int_cur); data.read("int_max",int_max); data.read("per_cur",per_cur); data.read("per_max",per_max); data.read("hunger",hunger); data.read("thirst",thirst); data.read("fatigue",fatigue); data.read("stim",stim); data.read("pain",pain); data.read("pkill",pkill); data.read("radiation",radiation); data.read("scent",scent); data.read("moves",moves); data.read("dodges_left",num_dodges); data.read("underwater",underwater); data.read("oxygen",oxygen); data.read("male",male); data.read("cash",cash); data.read("recoil",recoil); parray = data.get_array("hp_cur"); if ( parray.size() == num_hp_parts ) { for(int i=0; i < num_hp_parts; i++) { hp_cur[i] = parray.get_int(i); } } else { debugmsg("Error, incompatible hp_cur in save file '%s'",parray.str().c_str()); } parray = data.get_array("hp_max"); if ( parray.size() == num_hp_parts ) { for(int i=0; i < num_hp_parts; i++) { hp_max[i] = parray.get_int(i); } } else { debugmsg("Error, incompatible hp_max in save file '%s'",parray.str().c_str()); } data.read("power_level",power_level); data.read("max_power_level",max_power_level); data.read("traits",my_traits); if (data.has_object("skills")) { JsonObject pmap = data.get_object("skills"); for (std::vector<Skill*>::iterator aSkill = Skill::skills.begin(); aSkill != Skill::skills.end(); ++aSkill) { if ( pmap.has_object( (*aSkill)->ident() ) ) { pmap.read( (*aSkill)->ident(), skillLevel(*aSkill) ); } else { debugmsg("Load (%s) Missing skill %s","",(*aSkill)->ident().c_str() ); } } } else { debugmsg("Skills[] no bueno"); } data.read("ma_styles",ma_styles); data.read("illness",illness); data.read("effects",effects); data.read("addictions",addictions); data.read("my_bionics",my_bionics); }