mirror of
https://github.com/mangosfour/server.git
synced 2025-12-16 22:37:02 +00:00
[8895] Use NULL-terminator instead table count in pdump code.
Also rename function to avoid use same name with type.
This commit is contained in:
parent
1e3100d664
commit
a7cd0f8f44
3 changed files with 15 additions and 13 deletions
|
|
@ -24,15 +24,16 @@
|
||||||
#include "ObjectMgr.h"
|
#include "ObjectMgr.h"
|
||||||
|
|
||||||
// Character Dump tables
|
// Character Dump tables
|
||||||
#define DUMP_TABLE_COUNT 21
|
|
||||||
|
|
||||||
struct DumpTable
|
struct DumpTable
|
||||||
{
|
{
|
||||||
char const* name;
|
char const* name;
|
||||||
DumpTableType type;
|
DumpTableType type;
|
||||||
|
|
||||||
|
// helpers
|
||||||
|
bool isValid() const { return name != NULL; }
|
||||||
};
|
};
|
||||||
|
|
||||||
static DumpTable dumpTables[DUMP_TABLE_COUNT] =
|
static DumpTable dumpTables[] =
|
||||||
{
|
{
|
||||||
{ "characters", DTT_CHARACTER },
|
{ "characters", DTT_CHARACTER },
|
||||||
{ "character_achievement", DTT_CHAR_TABLE },
|
{ "character_achievement", DTT_CHAR_TABLE },
|
||||||
|
|
@ -55,6 +56,7 @@ static DumpTable dumpTables[DUMP_TABLE_COUNT] =
|
||||||
{ "pet_aura", DTT_PET_TABLE },
|
{ "pet_aura", DTT_PET_TABLE },
|
||||||
{ "pet_spell", DTT_PET_TABLE },
|
{ "pet_spell", DTT_PET_TABLE },
|
||||||
{ "pet_spell_cooldown", DTT_PET_TABLE },
|
{ "pet_spell_cooldown", DTT_PET_TABLE },
|
||||||
|
{ NULL, DTT_CHAR_TABLE }, // end marker
|
||||||
};
|
};
|
||||||
|
|
||||||
// Low level functions
|
// Low level functions
|
||||||
|
|
@ -258,7 +260,7 @@ void StoreGUID(QueryResult *result,uint32 data,uint32 field, std::set<uint32>& g
|
||||||
}
|
}
|
||||||
|
|
||||||
// Writing - High-level functions
|
// 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;
|
GUIDs const* guids = NULL;
|
||||||
char const* fieldname = NULL;
|
char const* fieldname = NULL;
|
||||||
|
|
@ -362,8 +364,8 @@ std::string PlayerDumpWriter::GetDump(uint32 guid)
|
||||||
else
|
else
|
||||||
sLog.outError("Character DB not have 'character_db_version' table, revision guard query not added to pdump.");
|
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)
|
for(DumpTable* itr = &dumpTables[0]; itr->isValid(); ++itr)
|
||||||
DumpTable(dump, guid, dumpTables[i].name, dumpTables[i].name, dumpTables[i].type);
|
DumpTableContent(dump, guid, itr->name, itr->name, itr->type);
|
||||||
|
|
||||||
// TODO: Add instance/group..
|
// TODO: Add instance/group..
|
||||||
// TODO: Add a dump level option to skip some non-important tables
|
// 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;
|
DumpTableType type;
|
||||||
uint8 i;
|
DumpTable* dTable = &dumpTables[0];
|
||||||
for(i = 0; i < DUMP_TABLE_COUNT; ++i)
|
for(; dTable->isValid(); ++dTable)
|
||||||
{
|
{
|
||||||
if (tn == dumpTables[i].name)
|
if (tn == dTable->name)
|
||||||
{
|
{
|
||||||
type = dumpTables[i].type;
|
type = dTable->type;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == DUMP_TABLE_COUNT)
|
if (!dTable->isValid())
|
||||||
{
|
{
|
||||||
sLog.outError("LoadPlayerDump: Unknown table: '%s'!", tn.c_str());
|
sLog.outError("LoadPlayerDump: Unknown table: '%s'!", tn.c_str());
|
||||||
ROLLBACK(DUMP_FILE_BROKEN);
|
ROLLBACK(DUMP_FILE_BROKEN);
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ class PlayerDumpWriter : public PlayerDump
|
||||||
private:
|
private:
|
||||||
typedef std::set<uint32> GUIDs;
|
typedef std::set<uint32> 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, GUIDs const& guids, GUIDs::const_iterator& itr);
|
||||||
std::string GenerateWhereStr(char const* field, uint32 guid);
|
std::string GenerateWhereStr(char const* field, uint32 guid);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "8894"
|
#define REVISION_NR "8895"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue