diff --git a/src/game/PlayerDump.cpp b/src/game/PlayerDump.cpp index 27172f625..520f47610 100644 --- a/src/game/PlayerDump.cpp +++ b/src/game/PlayerDump.cpp @@ -24,15 +24,16 @@ #include "ObjectMgr.h" // Character Dump tables -#define DUMP_TABLE_COUNT 21 - struct DumpTable { char const* name; DumpTableType type; + + // helpers + bool isValid() const { return name != NULL; } }; -static DumpTable dumpTables[DUMP_TABLE_COUNT] = +static DumpTable dumpTables[] = { { "characters", DTT_CHARACTER }, { "character_achievement", DTT_CHAR_TABLE }, @@ -55,6 +56,7 @@ static DumpTable dumpTables[DUMP_TABLE_COUNT] = { "pet_aura", DTT_PET_TABLE }, { "pet_spell", DTT_PET_TABLE }, { "pet_spell_cooldown", DTT_PET_TABLE }, + { NULL, DTT_CHAR_TABLE }, // end marker }; // Low level functions @@ -258,7 +260,7 @@ void StoreGUID(QueryResult *result,uint32 data,uint32 field, std::set& g } // Writing - High-level functions -void PlayerDumpWriter::DumpTable(std::string& dump, uint32 guid, char const*tableFrom, char const*tableTo, DumpTableType type) +void PlayerDumpWriter::DumpTableContent(std::string& dump, uint32 guid, char const*tableFrom, char const*tableTo, DumpTableType type) { GUIDs const* guids = NULL; char const* fieldname = NULL; @@ -362,8 +364,8 @@ std::string PlayerDumpWriter::GetDump(uint32 guid) else sLog.outError("Character DB not have 'character_db_version' table, revision guard query not added to pdump."); - for(int i = 0; i < DUMP_TABLE_COUNT; ++i) - DumpTable(dump, guid, dumpTables[i].name, dumpTables[i].name, dumpTables[i].type); + for(DumpTable* itr = &dumpTables[0]; itr->isValid(); ++itr) + DumpTableContent(dump, guid, itr->name, itr->name, itr->type); // TODO: Add instance/group.. // TODO: Add a dump level option to skip some non-important tables @@ -497,17 +499,17 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s } DumpTableType type; - uint8 i; - for(i = 0; i < DUMP_TABLE_COUNT; ++i) + DumpTable* dTable = &dumpTables[0]; + for(; dTable->isValid(); ++dTable) { - if (tn == dumpTables[i].name) + if (tn == dTable->name) { - type = dumpTables[i].type; + type = dTable->type; break; } } - if (i == DUMP_TABLE_COUNT) + if (!dTable->isValid()) { sLog.outError("LoadPlayerDump: Unknown table: '%s'!", tn.c_str()); ROLLBACK(DUMP_FILE_BROKEN); diff --git a/src/game/PlayerDump.h b/src/game/PlayerDump.h index 90fd2ac0e..b22a616ce 100644 --- a/src/game/PlayerDump.h +++ b/src/game/PlayerDump.h @@ -75,7 +75,7 @@ class PlayerDumpWriter : public PlayerDump private: typedef std::set GUIDs; - void DumpTable(std::string& dump, uint32 guid, char const*tableFrom, char const*tableTo, DumpTableType type); + void DumpTableContent(std::string& dump, uint32 guid, char const*tableFrom, char const*tableTo, DumpTableType type); std::string GenerateWhereStr(char const* field, GUIDs const& guids, GUIDs::const_iterator& itr); std::string GenerateWhereStr(char const* field, uint32 guid); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 7dc5e951e..2697fb968 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8894" + #define REVISION_NR "8895" #endif // __REVISION_NR_H__