diff options
Diffstat (limited to 'src/game/PlayerDump.cpp')
-rw-r--r-- | src/game/PlayerDump.cpp | 67 |
1 files changed, 43 insertions, 24 deletions
diff --git a/src/game/PlayerDump.cpp b/src/game/PlayerDump.cpp index 73939115211..06550269856 100644 --- a/src/game/PlayerDump.cpp +++ b/src/game/PlayerDump.cpp @@ -304,19 +304,19 @@ void PlayerDumpWriter::DumpTable(std::string& dump, uint32 guid, char const*tabl // collect guids switch ( type ) { - case DTT_INVENTORY: - StoreGUID(result,3,items); break; // item guid collection - case DTT_ITEM: - StoreGUID(result,0,ITEM_FIELD_ITEM_TEXT_ID,texts); break; - // item text id collection - case DTT_PET: - StoreGUID(result,0,pets); break; // pet guid collection - case DTT_MAIL: - StoreGUID(result,0,mails); // mail id collection - StoreGUID(result,6,texts); break; // item text id collection - case DTT_MAIL_ITEM: - StoreGUID(result,1,items); break; // item guid collection - default: break; + case DTT_INVENTORY: + StoreGUID(result,3,items); break; // item guid collection + case DTT_ITEM: + StoreGUID(result,0,ITEM_FIELD_ITEM_TEXT_ID,texts); break; + // item text id collection + case DTT_PET: + StoreGUID(result,0,pets); break; // pet guid collection + case DTT_MAIL: + StoreGUID(result,0,mails); // mail id collection + StoreGUID(result,7,texts); break; // item text id collection + case DTT_MAIL_ITEM: + StoreGUID(result,1,items); break; // item guid collection + default: break; } dump += CreateDumpString(tableTo, result); @@ -332,7 +332,7 @@ void PlayerDumpWriter::DumpTable(std::string& dump, uint32 guid, char const*tabl std::string PlayerDumpWriter::GetDump(uint32 guid) { std::string dump; - + dump += "IMPORTANT NOTE: This sql queries not created for apply directly, use '.pdump load' command in console or client chat instead.\n"; dump += "IMPORTANT NOTE: NOT APPLY ITS DIRECTLY to character DB or you will DAMAGE and CORRUPT character DB\n\n"; @@ -395,7 +395,7 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s { QueryResult *result = CharacterDatabase.PQuery("SELECT COUNT(guid) FROM characters WHERE account = '%d'", account); uint8 charcount = 0; - if ( result ) + if (result) { Field *fields=result->Fetch(); charcount = fields[0].GetUInt8(); @@ -407,7 +407,7 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s } FILE *fin = fopen(file.c_str(), "r"); - if(!fin) + if (!fin) return DUMP_FILE_OPEN_ERROR; QueryResult * result = NULL; @@ -415,7 +415,7 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s // make sure the same guid doesn't already exist and is safe to use bool incHighest = true; - if(guid != 0 && guid < objmgr.m_hiCharGuid) + if (guid != 0 && guid < objmgr.m_hiCharGuid) { result = CharacterDatabase.PQuery("SELECT * FROM characters WHERE guid = '%d'", guid); if (result) @@ -429,10 +429,10 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s guid = objmgr.m_hiCharGuid; // normalize the name if specified and check if it exists - if(!normalizePlayerName(name)) + if (!normalizePlayerName(name)) name = ""; - if(ObjectMgr::IsValidName(name,true)) + if (ObjectMgr::CheckPlayerName(name,true) == CHAR_NAME_SUCCESS) { CharacterDatabase.escape_string(name); // for safe, we use name only for sql quearies anyway result = CharacterDatabase.PQuery("SELECT * FROM characters WHERE name = '%s'", name.c_str()); @@ -442,7 +442,8 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s delete result; } } - else name = ""; + else + name = ""; // name encoded or empty @@ -453,6 +454,7 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s std::map<uint32,uint32> items; std::map<uint32,uint32> mails; + std::map<uint32,uint32> itemTexts; char buf[32000] = ""; typedef std::map<uint32, uint32> PetIds; // old->new petid relation @@ -547,8 +549,8 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s if (result) { delete result; - // rename on login: `at_login` field 30 in raw field list - if(!changenth(line, 30, "1")) + + if(!changenth(line, 37, "1")) // rename on login: `at_login` field 37 in raw field list ROLLBACK(DUMP_FILE_BROKEN); } } @@ -581,6 +583,8 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s ROLLBACK(DUMP_FILE_BROKEN); if(!changetoknth(vals, ITEM_FIELD_OWNER+1, newguid)) ROLLBACK(DUMP_FILE_BROKEN); + if(!changetokGuid(vals, ITEM_FIELD_ITEM_TEXT_ID+1, itemTexts, objmgr.m_ItemTextId,true)) + ROLLBACK(DUMP_FILE_BROKEN); if(!changenth(line, 3, vals.c_str())) ROLLBACK(DUMP_FILE_BROKEN); break; @@ -638,10 +642,12 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s } case DTT_MAIL: // mail { - // id,messageType,stationery,sender,receiver + // id,messageType,stationery,mailtemplate,sender,receiver,subject,itemText if(!changeGuid(line, 1, mails, objmgr.m_mailid)) ROLLBACK(DUMP_FILE_BROKEN); - if(!changenth(line, 5, newguid)) + if(!changenth(line, 6, newguid)) + ROLLBACK(DUMP_FILE_BROKEN); + if(!changeGuid(line, 8, itemTexts, objmgr.m_ItemTextId)) ROLLBACK(DUMP_FILE_BROKEN); break; } @@ -656,6 +662,18 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s ROLLBACK(DUMP_FILE_BROKEN); break; } + case DTT_ITEM_TEXT: // item_text + { + // id + if(!changeGuid(line, 1, itemTexts, objmgr.m_ItemTextId)) + ROLLBACK(DUMP_FILE_BROKEN); + + // add it to cache + uint32 id= atoi(getnth(line,1).c_str()); + std::string text = getnth(line,2); + objmgr.AddItemText(id,text); + break; + } default: sLog.outError("Unknown dump table type: %u",type); break; @@ -669,6 +687,7 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s objmgr.m_hiItemGuid += items.size(); objmgr.m_mailid += mails.size(); + objmgr.m_ItemTextId += itemTexts.size(); if(incHighest) ++objmgr.m_hiCharGuid; |