// Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the // License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . //----------------------------------------------------------------------------- // includes //----------------------------------------------------------------------------- //nel #include "nel/misc/command.h" #include "nel/misc/variable.h" // game share #include "game_share/utils.h" #include "game_share/file_description_container.h" #include "game_share/singleton_registry.h" #include "game_share/persistent_data.h" //----------------------------------------------------------------------------- // Namespaces //----------------------------------------------------------------------------- using namespace std; //----------------------------------------------------------------------------- // Variables //----------------------------------------------------------------------------- //NLMISC::CVariable Bla("ShardMerge", "Bla", "Directory containing event tools", string("./events/tools/"), 0, true); //----------------------------------------------------------------------------- // CContestCtrlScript Commands //----------------------------------------------------------------------------- NLMISC_CATEGORISED_COMMAND(ShardMerge,mergeGuildIdFix,"set the guild ids in the pdr records from the values in their file names","") { if (args.size()!=1) return false; CFileDescriptionContainer fdc; fdc.addFileSpec(args[0]); for (uint32 i=0;i"; resultString+= inputString.splitFrom(""); // convert back to a pdr pdr.clear(); pdr.fromXML(resultString); // write the file pdr.writeToFile((fdc[i].FileName+".new.xml").c_str()); pdr.writeToFile((fdc[i].FileName+".new.bin").c_str()); } return true; } NLMISC_CATEGORISED_COMMAND(ShardMerge,mergeChangeCharacterNames,"change names of characters to thos listed in charcter_names.txt file","") { DROP_IF(args.size()!=1,"Syntax error: Requires an argument",return false); DROP_IF(!NLMISC::CFile::fileExists(args[0]+"/character_names.txt"),"File not found: "+args[0]+"/character_names.txt",return false); NLMISC::CSString fileContent; fileContent.readFromFile(args[0]+"/character_names.txt"); NLMISC::CVectorSString fileLines; fileContent.splitLines(fileLines); for (uint32 i=0;i"; resultString+= inputString.splitFrom("<_Name type=\"STRING\" value=\"").splitFrom("\"/>"); // convert back to a pdr pdr.clear(); pdr.fromXML(resultString); // write the file pdr.writeToFile((fileName+".new.xml").c_str()); pdr.writeToFile((fileName+".new.bin").c_str()); } return true; } NLMISC_CATEGORISED_COMMAND(ShardMerge,mergeBuildCharacterNamesFromCSV,"build a character names file from a CSV file containing columns: account, accountSlot, name","") { if (args.size()!=2) return false; // read the CSV file NLMISC::CSString input; input.readFromFile(args[0].c_str()); // convert CSV input into lines NLMISC::CVectorSString lines; input.splitLines(lines); DROP_IF(lines.empty(),"Failed to extract meaningful data from input file: "+args[0],return false); // split the first line into column titles NLMISC::CVectorSString columns; lines[0].splitByOneOfSeparators(",;",columns); // run through the column titles and identify the columns that interest us uint32 accountIdx=~0u; uint32 accountSlotIdx=~0u; uint32 nameIdx=~0u; for (uint32 i=0;i[[...]]") { if (args.size()<1) return false; // setup maps of all account ids and character names accross all input files std::map accounts; // std::map names; // // for each input file: ... for (uint32 i=0;i::iterator it= accounts.begin();it!=accounts.end();++it) { if ((*it).second.contains(',')) { output+="Account "+(*it).first+":"+(*it).second+"\n"; nlinfo("Duplicate account: %s @ %s",(*it).first.c_str(),(*it).second.c_str()); } } // run through the names map looking for duplicate entries for (std::map::iterator it= names.begin();it!=names.end();++it) { if ((*it).second.contains(',')) { output+="Name "+(*it).first+":"+(*it).second+"\n"; nlinfo("Duplicate character name: %s @ %s",(*it).first.c_str(),(*it).second.c_str()); } } // if no duplicates were found then drop out DROP_IF(output.empty(),"No duplicates found!",return true); // dump the output to disk NLMISC::CSString outputFileName= args[0]+".err"; nlinfo("Writintg duplicate list to output file: %s",outputFileName.c_str()); output.writeToFile(outputFileName); return true; } //-----------------------------------------------------------------------------