fix (core/pdump): Fix Pdump write and load thru TC Cherry picks (#10349)
* fix (core/pdump): Fix Pdump write and load thru TC Cherry picks TC Cherry picks were over 30. I am not listing it all but i am listing authors of said relations that this pr is based on. Co-Authored-By: Brian <runningnak3d@gmail.com> Co-Authored-By: joschiwald <736792+joschiwald@users.noreply.github.com> Co-Authored-By: Shauren <shauren.trinity@gmail.com> Co-Authored-By: SnapperRy <19622383+SnapperRy@users.noreply.github.com> Co-Authored-By: Ariel Silva <ariel-@users.noreply.github.com> Co-Authored-By: Nick <31777+paradox@users.noreply.github.com> Co-Authored-By: r00ty-tc <r00ty-tc@users.noreply.github.com> Co-Authored-By: Jorge García <259712+xurxogr@users.noreply.github.com> Co-Authored-By: Kaelima <kaelima@live.se> Co-Authored-By: Shocker <43253032+shockerqt@users.noreply.github.com> Co-Authored-By: Giacomo Pozzoni <giacomopoz@gmail.com> * fix whitespace formatting look like it had a stroke. * Updated in script notes Updated in script notes to reflect it was a note from tc that was refactored in * Acore::StringTo * acore::stringto Co-authored-by: Brian <runningnak3d@gmail.com> Co-authored-by: joschiwald <736792+joschiwald@users.noreply.github.com> Co-authored-by: Shauren <shauren.trinity@gmail.com> Co-authored-by: SnapperRy <19622383+SnapperRy@users.noreply.github.com> Co-authored-by: Ariel Silva <ariel-@users.noreply.github.com> Co-authored-by: Nick <31777+paradox@users.noreply.github.com> Co-authored-by: r00ty-tc <r00ty-tc@users.noreply.github.com> Co-authored-by: Jorge García <259712+xurxogr@users.noreply.github.com> Co-authored-by: Kaelima <kaelima@live.se> Co-authored-by: Shocker <43253032+shockerqt@users.noreply.github.com> Co-authored-by: Giacomo Pozzoni <giacomopoz@gmail.com> Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -18,37 +18,38 @@
|
|||||||
#ifndef _PLAYER_DUMP_H
|
#ifndef _PLAYER_DUMP_H
|
||||||
#define _PLAYER_DUMP_H
|
#define _PLAYER_DUMP_H
|
||||||
|
|
||||||
#include "Define.h"
|
#include <string>
|
||||||
|
#include <iosfwd>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include "ObjectGuid.h"
|
||||||
|
|
||||||
enum DumpTableType
|
enum DumpTableType
|
||||||
{
|
{
|
||||||
DTT_CHARACTER, // // characters
|
DTT_CHARACTER, // // characters
|
||||||
|
|
||||||
DTT_CHAR_TABLE, // // character_achievement, character_achievement_progress,
|
DTT_CHAR_TABLE, // // character_achievement, character_achievement_progress,
|
||||||
// character_action, character_aura, character_homebind,
|
// character_action, character_aura, character_homebind,
|
||||||
// character_queststatus, character_queststatus_rewarded, character_reputation,
|
// character_queststatus, character_queststatus_rewarded, character_reputation,
|
||||||
// character_spell, character_spell_cooldown, character_ticket, character_talent
|
// character_spell, character_spell_cooldown, character_ticket, character_talent
|
||||||
|
|
||||||
DTT_EQSET_TABLE, // <- guid // character_equipmentsets
|
DTT_EQSET_TABLE, // <- guid // character_equipmentsets
|
||||||
|
|
||||||
DTT_INVENTORY, // -> item guids collection // character_inventory
|
DTT_INVENTORY, // -> item guids collection // character_inventory
|
||||||
|
|
||||||
DTT_MAIL, // -> mail ids collection // mail
|
DTT_MAIL, // -> mail ids collection // mail
|
||||||
// -> item_text
|
// -> item_text
|
||||||
|
|
||||||
DTT_MAIL_ITEM, // <- mail ids // mail_items
|
DTT_MAIL_ITEM, // <- mail ids // mail_items
|
||||||
// -> item guids collection
|
// -> item guids collection
|
||||||
|
|
||||||
DTT_ITEM, // <- item guids // item_instance
|
DTT_ITEM, // <- item guids // item_instance
|
||||||
// -> item_text
|
// -> item_text
|
||||||
|
|
||||||
DTT_ITEM_GIFT, // <- item guids // character_gifts
|
DTT_ITEM_GIFT, // <- item guids // character_gifts
|
||||||
|
|
||||||
DTT_PET, // -> pet guids collection // character_pet
|
DTT_PET, // -> pet guids collection // character_pet
|
||||||
DTT_PET_TABLE, // <- pet guids // pet_aura, pet_spell, pet_spell_cooldown
|
DTT_PET_TABLE // <- pet guids // pet_aura, pet_spell, pet_spell_cooldown
|
||||||
};
|
};
|
||||||
|
|
||||||
enum DumpReturn
|
enum DumpReturn
|
||||||
@@ -56,15 +57,21 @@ enum DumpReturn
|
|||||||
DUMP_SUCCESS,
|
DUMP_SUCCESS,
|
||||||
DUMP_FILE_OPEN_ERROR,
|
DUMP_FILE_OPEN_ERROR,
|
||||||
DUMP_TOO_MANY_CHARS,
|
DUMP_TOO_MANY_CHARS,
|
||||||
DUMP_UNEXPECTED_END,
|
|
||||||
DUMP_FILE_BROKEN,
|
DUMP_FILE_BROKEN,
|
||||||
DUMP_CHARACTER_DELETED
|
DUMP_CHARACTER_DELETED
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct DumpTable;
|
||||||
|
struct TableStruct;
|
||||||
|
class StringTransaction;
|
||||||
|
|
||||||
class PlayerDump
|
class PlayerDump
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
static void InitializeTables();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
PlayerDump() {}
|
PlayerDump() { }
|
||||||
};
|
};
|
||||||
|
|
||||||
class PlayerDumpWriter : public PlayerDump
|
class PlayerDumpWriter : public PlayerDump
|
||||||
@@ -72,18 +79,19 @@ class PlayerDumpWriter : public PlayerDump
|
|||||||
public:
|
public:
|
||||||
PlayerDumpWriter() { }
|
PlayerDumpWriter() { }
|
||||||
|
|
||||||
bool GetDump(uint32 guid, std::string& dump);
|
bool GetDump(ObjectGuid::LowType guid, std::string& dump);
|
||||||
DumpReturn WriteDump(std::string const& file, uint32 guid);
|
DumpReturn WriteDumpToFile(std::string const& file, ObjectGuid::LowType guid);
|
||||||
|
DumpReturn WriteDumpToString(std::string& dump, ObjectGuid::LowType guid);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::set<uint32> GUIDs;
|
bool AppendTable(StringTransaction& trans, ObjectGuid::LowType guid, TableStruct const& tableStruct, DumpTable const& dumpTable);
|
||||||
|
void PopulateGuids(ObjectGuid::LowType guid);
|
||||||
|
|
||||||
bool DumpTable(std::string& dump, uint32 guid, char const* tableFrom, char const* tableTo, DumpTableType type);
|
std::set<ObjectGuid::LowType> _pets;
|
||||||
std::string GenerateWhereStr(char const* field, GUIDs const& guids, GUIDs::const_iterator& itr);
|
std::set<ObjectGuid::LowType> _mails;
|
||||||
std::string GenerateWhereStr(char const* field, uint32 guid);
|
std::set<ObjectGuid::LowType> _items;
|
||||||
|
|
||||||
GUIDs pets;
|
std::set<uint64> _itemSets;
|
||||||
GUIDs mails;
|
|
||||||
GUIDs items;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class PlayerDumpReader : public PlayerDump
|
class PlayerDumpReader : public PlayerDump
|
||||||
@@ -91,7 +99,11 @@ class PlayerDumpReader : public PlayerDump
|
|||||||
public:
|
public:
|
||||||
PlayerDumpReader() { }
|
PlayerDumpReader() { }
|
||||||
|
|
||||||
DumpReturn LoadDump(std::string const& file, uint32 account, std::string name, uint32 guid);
|
DumpReturn LoadDumpFromFile(std::string const& file, uint32 account, std::string name, ObjectGuid::LowType guid);
|
||||||
|
DumpReturn LoadDumpFromString(std::string const& dump, uint32 account, std::string name, ObjectGuid::LowType guid);
|
||||||
|
|
||||||
|
private:
|
||||||
|
DumpReturn LoadDump(std::istream& input, uint32 account, std::string name, ObjectGuid::LowType guid);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -67,6 +67,7 @@
|
|||||||
#include "OutdoorPvPMgr.h"
|
#include "OutdoorPvPMgr.h"
|
||||||
#include "PetitionMgr.h"
|
#include "PetitionMgr.h"
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
|
#include "PlayerDump.h"
|
||||||
#include "PoolMgr.h"
|
#include "PoolMgr.h"
|
||||||
#include "Realm.h"
|
#include "Realm.h"
|
||||||
#include "ScriptMgr.h"
|
#include "ScriptMgr.h"
|
||||||
@@ -1530,6 +1531,9 @@ void World::SetInitialWorldSettings()
|
|||||||
LOG_INFO("server.loading", "Loading spell dbc data corrections...");
|
LOG_INFO("server.loading", "Loading spell dbc data corrections...");
|
||||||
sSpellMgr->LoadDbcDataCorrections();
|
sSpellMgr->LoadDbcDataCorrections();
|
||||||
|
|
||||||
|
LOG_INFO("server.loading", "Initializing PlayerDump tables...");
|
||||||
|
PlayerDump::InitializeTables();
|
||||||
|
|
||||||
LOG_INFO("server.loading", "Loading SpellInfo store...");
|
LOG_INFO("server.loading", "Loading SpellInfo store...");
|
||||||
sSpellMgr->LoadSpellInfoStore();
|
sSpellMgr->LoadSpellInfoStore();
|
||||||
|
|
||||||
|
|||||||
@@ -816,51 +816,96 @@ public:
|
|||||||
if (!ValidatePDumpTarget(handler, name, characterName, characterGUID))
|
if (!ValidatePDumpTarget(handler, name, characterName, characterGUID))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
switch (PlayerDumpReader().LoadDump(fileName, account, name, characterGUID.value_or(0)))
|
switch (PlayerDumpReader().LoadDumpFromFile(fileName, account, name, characterGUID.value_or(0)))
|
||||||
{
|
{
|
||||||
case DUMP_SUCCESS:
|
case DUMP_SUCCESS:
|
||||||
handler->PSendSysMessage(LANG_COMMAND_IMPORT_SUCCESS);
|
handler->PSendSysMessage(LANG_COMMAND_IMPORT_SUCCESS);
|
||||||
break;
|
break;
|
||||||
case DUMP_FILE_OPEN_ERROR:
|
case DUMP_FILE_OPEN_ERROR:
|
||||||
handler->PSendSysMessage(LANG_FILE_OPEN_FAIL, fileName.c_str());
|
handler->PSendSysMessage(LANG_FILE_OPEN_FAIL, fileName.c_str());
|
||||||
handler->SetSentErrorMessage(true);
|
handler->SetSentErrorMessage(true);
|
||||||
return false;
|
return false;
|
||||||
case DUMP_FILE_BROKEN:
|
case DUMP_FILE_BROKEN:
|
||||||
handler->PSendSysMessage(LANG_DUMP_BROKEN, fileName.c_str());
|
handler->PSendSysMessage(LANG_DUMP_BROKEN, fileName.c_str());
|
||||||
handler->SetSentErrorMessage(true);
|
handler->SetSentErrorMessage(true);
|
||||||
return false;
|
return false;
|
||||||
case DUMP_TOO_MANY_CHARS:
|
case DUMP_TOO_MANY_CHARS:
|
||||||
handler->PSendSysMessage(LANG_ACCOUNT_CHARACTER_LIST_FULL, account.GetName().c_str(), account.GetID());
|
handler->PSendSysMessage(LANG_ACCOUNT_CHARACTER_LIST_FULL, account.GetName().c_str(), account.GetID());
|
||||||
handler->SetSentErrorMessage(true);
|
handler->SetSentErrorMessage(true);
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
handler->PSendSysMessage(LANG_COMMAND_IMPORT_FAILED);
|
handler->PSendSysMessage(LANG_COMMAND_IMPORT_FAILED);
|
||||||
handler->SetSentErrorMessage(true);
|
handler->SetSentErrorMessage(true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool HandlePDumpCopyCommand(ChatHandler* handler, PlayerIdentifier player, AccountIdentifier account, Optional<std::string_view> characterName, Optional<ObjectGuid::LowType> characterGUID)
|
||||||
|
{
|
||||||
|
std::string name;
|
||||||
|
if (!ValidatePDumpTarget(handler, name, characterName, characterGUID))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
std::string dump;
|
||||||
|
switch (PlayerDumpWriter().WriteDumpToString(dump, player.GetGUID().GetCounter()))
|
||||||
|
{
|
||||||
|
case DUMP_SUCCESS:
|
||||||
|
break;
|
||||||
|
case DUMP_CHARACTER_DELETED:
|
||||||
|
handler->PSendSysMessage(LANG_COMMAND_EXPORT_DELETED_CHAR);
|
||||||
|
handler->SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
case DUMP_FILE_OPEN_ERROR: // this error code should not happen
|
||||||
|
default:
|
||||||
|
handler->PSendSysMessage(LANG_COMMAND_EXPORT_FAILED);
|
||||||
|
handler->SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (PlayerDumpReader().LoadDumpFromString(dump, account, name, characterGUID.value_or(0)))
|
||||||
|
{
|
||||||
|
case DUMP_SUCCESS:
|
||||||
|
break;
|
||||||
|
case DUMP_TOO_MANY_CHARS:
|
||||||
|
handler->PSendSysMessage(LANG_ACCOUNT_CHARACTER_LIST_FULL, account.GetName().c_str(), account.GetID());
|
||||||
|
handler->SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
case DUMP_FILE_OPEN_ERROR: // this error code should not happen
|
||||||
|
case DUMP_FILE_BROKEN: // this error code should not happen
|
||||||
|
default:
|
||||||
|
handler->PSendSysMessage(LANG_COMMAND_IMPORT_FAILED);
|
||||||
|
handler->SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Original TC Notes from Refactor vvv
|
||||||
|
//ToDo: use a new trinity_string for this commands
|
||||||
|
handler->PSendSysMessage(LANG_COMMAND_IMPORT_SUCCESS);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static bool HandlePDumpWriteCommand(ChatHandler* handler, std::string fileName, PlayerIdentifier player)
|
static bool HandlePDumpWriteCommand(ChatHandler* handler, std::string fileName, PlayerIdentifier player)
|
||||||
{
|
{
|
||||||
switch (PlayerDumpWriter().WriteDump(fileName, player.GetGUID().GetCounter()))
|
switch (PlayerDumpWriter().WriteDumpToFile(fileName, player.GetGUID().GetCounter()))
|
||||||
{
|
{
|
||||||
case DUMP_SUCCESS:
|
case DUMP_SUCCESS:
|
||||||
handler->PSendSysMessage(LANG_COMMAND_EXPORT_SUCCESS);
|
handler->PSendSysMessage(LANG_COMMAND_EXPORT_SUCCESS);
|
||||||
break;
|
break;
|
||||||
case DUMP_FILE_OPEN_ERROR:
|
case DUMP_FILE_OPEN_ERROR:
|
||||||
handler->PSendSysMessage(LANG_FILE_OPEN_FAIL, fileName.c_str());
|
handler->PSendSysMessage(LANG_FILE_OPEN_FAIL, fileName.c_str());
|
||||||
handler->SetSentErrorMessage(true);
|
handler->SetSentErrorMessage(true);
|
||||||
return false;
|
return false;
|
||||||
case DUMP_CHARACTER_DELETED:
|
case DUMP_CHARACTER_DELETED:
|
||||||
handler->PSendSysMessage(LANG_COMMAND_EXPORT_DELETED_CHAR);
|
handler->PSendSysMessage(LANG_COMMAND_EXPORT_DELETED_CHAR);
|
||||||
handler->SetSentErrorMessage(true);
|
handler->SetSentErrorMessage(true);
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
handler->PSendSysMessage(LANG_COMMAND_EXPORT_FAILED);
|
handler->PSendSysMessage(LANG_COMMAND_EXPORT_FAILED);
|
||||||
handler->SetSentErrorMessage(true);
|
handler->SetSentErrorMessage(true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user