[8126] Improvemets in player/pet/charter name checks.

* Implement new config options for minimal player/pet/charter name length (2 by default)
* Better error reporting at problems in names.
* Add check from max pet/charter name length (same as for player names at client side)
This commit is contained in:
VladimirMangos 2009-07-05 19:58:26 +04:00
parent 60fe792866
commit 715470a898
12 changed files with 114 additions and 48 deletions

View file

@ -393,7 +393,7 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
{
QueryResult *result = CharacterDatabase.PQuery("SELECT COUNT(guid) FROM characters WHERE account = '%d'", account);
uint8 charcount = 0;
if ( result )
if (result)
{
Field *fields=result->Fetch();
charcount = fields[0].GetUInt8();
@ -405,7 +405,7 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
}
FILE *fin = fopen(file.c_str(), "r");
if(!fin)
if (!fin)
return DUMP_FILE_OPEN_ERROR;
QueryResult * result = NULL;
@ -413,7 +413,7 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
// make sure the same guid doesn't already exist and is safe to use
bool incHighest = true;
if(guid != 0 && guid < objmgr.m_hiCharGuid)
if (guid != 0 && guid < objmgr.m_hiCharGuid)
{
result = CharacterDatabase.PQuery("SELECT * FROM characters WHERE guid = '%d'", guid);
if (result)
@ -427,10 +427,10 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
guid = objmgr.m_hiCharGuid;
// normalize the name if specified and check if it exists
if(!normalizePlayerName(name))
if (!normalizePlayerName(name))
name = "";
if(ObjectMgr::IsValidName(name,true))
if (ObjectMgr::CheckPlayerName(name,true) == CHAR_NAME_SUCCESS)
{
CharacterDatabase.escape_string(name); // for safe, we use name only for sql quearies anyway
result = CharacterDatabase.PQuery("SELECT * FROM characters WHERE name = '%s'", name.c_str());
@ -440,7 +440,8 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
delete result;
}
}
else name = "";
else
name = "";
// name encoded or empty