/** Generate list of spell */ static void generateSpellList(CConfigFile &cf, const std::string &sheetName) { CConfigFile::CVar *spellList = cf.getVarPtr("spell_list"); if (!spellList) { nlwarning("Can't read spell list"); return; } COFile f; if (!f.open(sheetName, false, true)) { nlwarning("Can't write %s", sheetName.c_str()); return; } try { COXml xmlStreamOut; xmlStreamOut.init(&f); xmlStreamOut.xmlPush("FORM"); IStream &xmlStream = xmlStreamOut; xmlStream.xmlPush("STRUCT"); xmlStream.xmlPushBegin("ARRAY"); xmlStream.xmlSetAttrib("Name"); std::string name = "List"; xmlStream.serial(name); xmlStream.xmlPushEnd(); for(uint k = 0; k < (uint) spellList->size(); ++k) { std::vector<std::string> result; NLMISC::splitString(spellList->asString(k), "|", result); if (result.size() < 2) { nlwarning("Should provide at list spell name and id"); } xmlStream.xmlPush("STRUCT"); writeAtom(xmlStream, "ID", result[1]); writeAtom(xmlStream, "SheetBaseName", result[0]); xmlStream.xmlPop(); } xmlStream.xmlPop(); // STRUCT xmlStream.xmlPop(); // FORM } catch(const EStream &) { nlwarning("Cant write %s", sheetName.c_str()); } }
//----------------------------------------------- // dump : // Create a file with information to debug. //----------------------------------------------- void dump(const std::string &name) { // Write information to start as the version COFile fStart; if(fStart.open(name + "_start.rec", false, false)) { CVectorD currentPos = UserEntity->pos(); fStart.serialVersion(RecordVersion); fStart.serial(currentPos); // Close the File. fStart.close(); } else nlwarning("dump: cannot open/create the file '%s_start.rec'.", name.c_str()); // Write the DB IngameDbMngr.write(name + "_db.rec"); // Open the file. COFile f; if(f.open(name + ".rec", false, false)) { // Dump entities. EntitiesMngr.dump(f); // Dump Client CFG. ClientCfg.serial(f); // Close the File. f.close(); } else nlwarning("dump: cannot open/create the file '%s.rec'.", name.c_str()); // Open the file. if(f.open(name + ".xml", false, true)) { // Create the XML stream COXml output; // Init if(output.init (&f, "1.0")) { // Open the XML Dump. output.xmlPush("XML"); // Dump Client CFG. ClientCfg.serial(output); // Dump entities. EntitiesMngr.dumpXML(output); // Close the XML Dump. output.xmlPop(); // Flush the stream, write all the output file output.flush(); } else nlwarning("dump: cannot initialize '%s.xml'.", name.c_str()); // Close the File. f.close(); } else nlwarning("dump: cannot open/create the file '%s.xml'.", name.c_str()); }// dump //