void CharDB::load() { if (mLoaded) unload(); XML::Document *doc = new XML::Document( paths.getStringValue("charCreationFile"), true, false); const XmlNodePtrConst root = doc->rootNode(); if (!root || !xmlNameEqual(root, "chars")) { logger->log("CharDB: Failed to parse %s.", paths.getStringValue("charCreationFile").c_str()); delete doc; return; } for_each_xml_child_node(node, root) { if (xmlNameEqual(node, "haircolor")) { loadMinMax(node, &mMinHairColor, &mMaxHairColor); } else if (xmlNameEqual(node, "hairstyle")) { loadMinMax(node, &mMinHairStyle, &mMaxHairStyle); } else if (xmlNameEqual(node, "look")) { loadMinMax(node, &mMinLook, &mMaxLook); } else if (xmlNameEqual(node, "stat")) { loadMinMax(node, &mMinStat, &mMaxStat); mSumStat = XML::getProperty(node, "sum", 0); } else if (xmlNameEqual(node, "item")) { const int id = XML::getProperty(node, "id", 0); if (id > 0) mDefaultItems.push_back(id); } else if (xmlNameEqual(node, "race")) { loadMinMax(node, &mMinRace, &mMaxRace); } } delete doc; mLoaded = true; }
void CharDB::load() { if (mLoaded) unload(); XML::Document *doc = new XML::Document( paths.getStringValue("charCreationFile"), UseResman_true, SkipError_false); const XmlNodePtrConst root = doc->rootNode(); if (!root || !xmlNameEqual(root, "chars")) { logger->log("CharDB: Failed to parse %s.", paths.getStringValue("charCreationFile").c_str()); delete doc; return; } for_each_xml_child_node(node, root) { if (xmlNameEqual(node, "haircolor")) { loadMinMax(node, &mMinHairColor, &mMaxHairColor); } else if (xmlNameEqual(node, "hairstyle")) { loadMinMax(node, &mMinHairStyle, &mMaxHairStyle); } else if (xmlNameEqual(node, "look")) { loadMinMax(node, &mMinLook, &mMaxLook); } else if (xmlNameEqual(node, "stat")) { loadMinMax(node, &mMinStat, &mMaxStat); mSumStat = XML::getProperty(node, "sum", 0); } else if (xmlNameEqual(node, "item")) { const int id = XML::getProperty(node, "id", 0); if (id > 0) { BeingSlot slot; slot.spriteId = id; for (int f = 0; f < maxCards; f ++) { const std::string cardName = strprintf("card%d", f + 1); slot.cardsId.cards[f] = XML::getProperty(node, cardName.c_str(), 0); } mDefaultItems.push_back(slot); } } else if (xmlNameEqual(node, "race")) { loadMinMax(node, &mMinRace, &mMaxRace); } } delete doc; mLoaded = true; }