mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16:37:01 +00:00
[10026] PDump code fixes and cleanups
* At pdump creating will propertly saved NULL field values. * At pdump loading will skipped adding `character_declinedname` if name in some way will be changed (explicly or at loading)
This commit is contained in:
parent
e431ab55cc
commit
cf5c1c45d6
3 changed files with 83 additions and 50 deletions
|
|
@ -36,13 +36,13 @@ struct DumpTable
|
||||||
|
|
||||||
static DumpTable dumpTables[] =
|
static DumpTable dumpTables[] =
|
||||||
{
|
{
|
||||||
{ "characters", DTT_CHARACTER }, // -> guid
|
{ "characters", DTT_CHARACTER }, // -> guid, must be first for name check
|
||||||
{ "character_account_data", DTT_CHAR_TABLE },
|
{ "character_account_data", DTT_CHAR_TABLE },
|
||||||
{ "character_achievement", DTT_CHAR_TABLE },
|
{ "character_achievement", DTT_CHAR_TABLE },
|
||||||
{ "character_achievement_progress", DTT_CHAR_TABLE },
|
{ "character_achievement_progress", DTT_CHAR_TABLE },
|
||||||
{ "character_action", DTT_CHAR_TABLE },
|
{ "character_action", DTT_CHAR_TABLE },
|
||||||
{ "character_aura", DTT_CHAR_TABLE },
|
{ "character_aura", DTT_CHAR_TABLE },
|
||||||
{ "character_declinedname", DTT_CHAR_TABLE },
|
{ "character_declinedname", DTT_CHAR_NAME_TABLE },
|
||||||
{ "character_equipmentsets", DTT_EQSET_TABLE},
|
{ "character_equipmentsets", DTT_EQSET_TABLE},
|
||||||
{ "character_glyphs", DTT_CHAR_TABLE },
|
{ "character_glyphs", DTT_CHAR_TABLE },
|
||||||
{ "character_homebind", DTT_CHAR_TABLE },
|
{ "character_homebind", DTT_CHAR_TABLE },
|
||||||
|
|
@ -92,12 +92,14 @@ std::string gettoknth(std::string &str, int n)
|
||||||
bool findnth(std::string &str, int n, std::string::size_type &s, std::string::size_type &e)
|
bool findnth(std::string &str, int n, std::string::size_type &s, std::string::size_type &e)
|
||||||
{
|
{
|
||||||
s = str.find("VALUES ('")+9;
|
s = str.find("VALUES ('")+9;
|
||||||
if (s == std::string::npos) return false;
|
if (s == std::string::npos)
|
||||||
|
return false;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
e = str.find("'",s);
|
e = str.find("'",s);
|
||||||
if (e == std::string::npos) return false;
|
if (e == std::string::npos)
|
||||||
|
return false;
|
||||||
} while(str[e-1] == '\\');
|
} while(str[e-1] == '\\');
|
||||||
|
|
||||||
for(int i = 1; i < n; ++i)
|
for(int i = 1; i < n; ++i)
|
||||||
|
|
@ -106,7 +108,8 @@ bool findnth(std::string &str, int n, std::string::size_type &s, std::string::si
|
||||||
{
|
{
|
||||||
s = e+4;
|
s = e+4;
|
||||||
e = str.find("'",s);
|
e = str.find("'",s);
|
||||||
if (e == std::string::npos) return false;
|
if (e == std::string::npos)
|
||||||
|
return false;
|
||||||
} while (str[e-1] == '\\');
|
} while (str[e-1] == '\\');
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -201,20 +204,26 @@ bool changetokGuid(std::string &str, int n, std::map<uint32, uint32> &guidMap, u
|
||||||
|
|
||||||
std::string CreateDumpString(char const* tableName, QueryResult *result)
|
std::string CreateDumpString(char const* tableName, QueryResult *result)
|
||||||
{
|
{
|
||||||
if(!tableName || !result) return "";
|
if (!tableName || !result)
|
||||||
|
return "";
|
||||||
|
|
||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
ss << "INSERT INTO "<< _TABLE_SIM_ << tableName << _TABLE_SIM_ << " VALUES (";
|
ss << "INSERT INTO "<< _TABLE_SIM_ << tableName << _TABLE_SIM_ << " VALUES (";
|
||||||
Field *fields = result->Fetch();
|
Field *fields = result->Fetch();
|
||||||
for(uint32 i = 0; i < result->GetFieldCount(); ++i)
|
for(uint32 i = 0; i < result->GetFieldCount(); ++i)
|
||||||
{
|
{
|
||||||
if (i == 0) ss << "'";
|
if (i != 0)
|
||||||
else ss << ", '";
|
ss << ", ";
|
||||||
|
|
||||||
|
if (fields[i].IsNULL())
|
||||||
|
ss << "NULL";
|
||||||
|
else
|
||||||
|
{
|
||||||
std::string s = fields[i].GetCppString();
|
std::string s = fields[i].GetCppString();
|
||||||
CharacterDatabase.escape_string(s);
|
CharacterDatabase.escape_string(s);
|
||||||
ss << s;
|
|
||||||
|
|
||||||
ss << "'";
|
ss << "'" << s << "'";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ss << ");";
|
ss << ");";
|
||||||
return ss.str();
|
return ss.str();
|
||||||
|
|
@ -394,6 +403,8 @@ DumpReturn PlayerDumpWriter::WriteDump(const std::string& file, uint32 guid)
|
||||||
|
|
||||||
DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, std::string name, uint32 guid)
|
DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, std::string name, uint32 guid)
|
||||||
{
|
{
|
||||||
|
bool nameInvalidated = false; // set when name changed or will requested changed at next login
|
||||||
|
|
||||||
// check character count
|
// check character count
|
||||||
uint32 charcount = sAccountMgr.GetCharactersCount(account);
|
uint32 charcount = sAccountMgr.GetCharactersCount(account);
|
||||||
if (charcount >= 10)
|
if (charcount >= 10)
|
||||||
|
|
@ -508,6 +519,8 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
|
||||||
ROLLBACK(DUMP_FILE_BROKEN);
|
ROLLBACK(DUMP_FILE_BROKEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool execute_ok = true; // false, if need skip soem query
|
||||||
|
|
||||||
// change the data to server values
|
// change the data to server values
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
|
|
@ -516,6 +529,17 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
|
||||||
ROLLBACK(DUMP_FILE_BROKEN);
|
ROLLBACK(DUMP_FILE_BROKEN);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case DTT_CHAR_NAME_TABLE:
|
||||||
|
if (nameInvalidated) // ignore declined names if name will changed in some way
|
||||||
|
{
|
||||||
|
execute_ok = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!changenth(line, 1, newguid)) // character_*.guid update
|
||||||
|
ROLLBACK(DUMP_FILE_BROKEN);
|
||||||
|
break;
|
||||||
|
|
||||||
case DTT_CHARACTER:
|
case DTT_CHARACTER:
|
||||||
{
|
{
|
||||||
if (!changenth(line, 1, newguid)) // characters.guid update
|
if (!changenth(line, 1, newguid)) // characters.guid update
|
||||||
|
|
@ -537,11 +561,18 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
|
||||||
|
|
||||||
if (!changenth(line, 36, "1")) // characters.at_login set to "rename on login"
|
if (!changenth(line, 36, "1")) // characters.at_login set to "rename on login"
|
||||||
ROLLBACK(DUMP_FILE_BROKEN);
|
ROLLBACK(DUMP_FILE_BROKEN);
|
||||||
|
|
||||||
|
nameInvalidated = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(!changenth(line, 3, name.c_str())) // characters.name update
|
else
|
||||||
|
{
|
||||||
|
if (!changenth(line, 3, name.c_str())) // characters.name update
|
||||||
ROLLBACK(DUMP_FILE_BROKEN);
|
ROLLBACK(DUMP_FILE_BROKEN);
|
||||||
|
|
||||||
|
nameInvalidated = true;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DTT_INVENTORY:
|
case DTT_INVENTORY:
|
||||||
|
|
@ -674,7 +705,7 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!CharacterDatabase.Execute(line.c_str()))
|
if (execute_ok && !CharacterDatabase.Execute(line.c_str()))
|
||||||
ROLLBACK(DUMP_FILE_BROKEN);
|
ROLLBACK(DUMP_FILE_BROKEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,15 +25,17 @@
|
||||||
|
|
||||||
enum DumpTableType
|
enum DumpTableType
|
||||||
{
|
{
|
||||||
DTT_CHARACTER, // // characters
|
DTT_CHARACTER, // -> guid, name // characters
|
||||||
|
|
||||||
DTT_CHAR_TABLE, // // character_account_data, character_achievement,
|
DTT_CHAR_TABLE, // // character_account_data, character_achievement,
|
||||||
// character_achievement_progress, character_action,
|
// character_achievement_progress, character_action,
|
||||||
// character_aura, character_declinedname, character_glyphs,
|
// character_aura, character_glyphs,
|
||||||
// character_homebind, character_queststatus,
|
// character_homebind, character_queststatus,
|
||||||
// character_reputation, character_skills, character_spell,
|
// character_reputation, character_skills, character_spell,
|
||||||
// character_spell_cooldown, character_talent, character_ticket
|
// character_spell_cooldown, character_talent, character_ticket
|
||||||
|
|
||||||
|
DTT_CHAR_NAME_TABLE,// <- guid, name // character_declinedname
|
||||||
|
|
||||||
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
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "10025"
|
#define REVISION_NR "10026"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue