Core/PlayerDump: general revamping

- Changed insert queries to include column names, check columns on dump load
- Modify and search columns by name instead of storing magic offsets
- Fully forward and backward compatible with previous dumps
- Added better logs, C++11-ize code
This commit is contained in:
ariel-
2017-05-26 12:06:38 -03:00
parent 4fcea41519
commit 9bdbd69655
3 changed files with 744 additions and 466 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -57,16 +57,18 @@ enum DumpReturn
DUMP_SUCCESS,
DUMP_FILE_OPEN_ERROR,
DUMP_TOO_MANY_CHARS,
DUMP_UNEXPECTED_END,
DUMP_FILE_BROKEN,
DUMP_CHARACTER_DELETED
};
struct DumpTable;
struct TableStruct;
class StringTransaction;
class TC_GAME_API PlayerDump
{
public:
typedef std::set<ObjectGuid::LowType> DumpGuidSet;
typedef std::map<ObjectGuid::LowType, ObjectGuid::LowType> DumpGuidMap;
static void InitializeTables();
protected:
PlayerDump() { }
@@ -81,13 +83,14 @@ class TC_GAME_API PlayerDumpWriter : public PlayerDump
DumpReturn WriteDump(std::string const& file, ObjectGuid::LowType guid);
private:
bool DumpTable(std::string& dump, ObjectGuid::LowType guid, char const* tableFrom, char const* tableTo, DumpTableType type);
std::string GenerateWhereStr(char const* field, DumpGuidSet const& guids, DumpGuidSet::const_iterator& itr);
std::string GenerateWhereStr(char const* field, ObjectGuid::LowType guid);
bool AppendTable(StringTransaction& trans, ObjectGuid::LowType guid, TableStruct const& tableStruct, DumpTable const& dumpTable);
void PopulateGuids(ObjectGuid::LowType guid);
DumpGuidSet pets;
DumpGuidSet mails;
DumpGuidSet items;
std::set<ObjectGuid::LowType> _pets;
std::set<ObjectGuid::LowType> _mails;
std::set<ObjectGuid::LowType> _items;
std::set<uint64> _itemSets;
};
class TC_GAME_API PlayerDumpReader : public PlayerDump

View File

@@ -55,6 +55,7 @@
#include "OutdoorPvPMgr.h"
#include "PetitionMgr.h"
#include "Player.h"
#include "PlayerDump.h"
#include "PoolMgr.h"
#include "QueryCallback.h"
#include "ScriptMgr.h"
@@ -1433,6 +1434,9 @@ void World::SetInitialWorldSettings()
MMAP::MMapManager* mmmgr = MMAP::MMapFactory::createOrGetMMapManager();
mmmgr->InitializeThreadUnsafe(mapIds);
TC_LOG_INFO("server.loading", "Initializing PlayerDump tables...");
PlayerDump::InitializeTables();
TC_LOG_INFO("server.loading", "Loading SpellInfo store...");
sSpellMgr->LoadSpellInfoStore();