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

* 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)

--HG--
branch : trunk
This commit is contained in:
megamage committed 2009-07-10 08:25:33 +08:00
1 parent 474af870d7
commit 6976043e22
11 files changed
+113 -47

No files matched your search

+28 -12
View File
@@ -7071,18 +7071,24 @@ bool isValidString(std::wstring wstr, uint32 strictMask, bool numericOrSpace, bo
return false;
}
bool ObjectMgr::IsValidName( const std::string& name, bool create )
uint8 ObjectMgr::CheckPlayerName( const std::string& name, bool create )
{
std::wstring wname;
if(!Utf8toWStr(name,wname))
return false;
return CHAR_NAME_INVALID_CHARACTER;
if(wname.size() < 1 || wname.size() > MAX_PLAYER_NAME)
return false;
if(wname.size() > MAX_PLAYER_NAME)
return CHAR_NAME_TOO_LONG;
uint32 minName = sWorld.getConfig(CONFIG_MIN_PLAYER_NAME);
if(wname.size() < minName)
return CHAR_NAME_TOO_SHORT;
uint32 strictMask = sWorld.getConfig(CONFIG_STRICT_PLAYER_NAMES);
return isValidString(wname,strictMask,false,create);
if(!isValidString(wname,strictMask,false,create))
return CHAR_NAME_MIXED_LANGUAGES;
return CHAR_NAME_SUCCESS;
}
bool ObjectMgr::IsValidCharterName( const std::string& name )
@@ -7091,7 +7097,11 @@ bool ObjectMgr::IsValidCharterName( const std::string& name )
if(!Utf8toWStr(name,wname))
return false;
if(wname.size() < 1)
if(wname.size() > MAX_CHARTER_NAME)
return false;
uint32 minName = sWorld.getConfig(CONFIG_MIN_CHARTER_NAME);
if(wname.size() < minName)
return false;
uint32 strictMask = sWorld.getConfig(CONFIG_STRICT_CHARTER_NAMES);
@@ -7099,18 +7109,24 @@ bool ObjectMgr::IsValidCharterName( const std::string& name )
return isValidString(wname,strictMask,true);
}
bool ObjectMgr::IsValidPetName( const std::string& name )
PetNameInvalidReason ObjectMgr::CheckPetName( const std::string& name )
{
std::wstring wname;
if(!Utf8toWStr(name,wname))
return false;
return PET_NAME_INVALID;
if(wname.size() < 1)
return false;
if(wname.size() > MAX_PET_NAME)
return PET_NAME_TOO_LONG;
uint32 minName = sWorld.getConfig(CONFIG_MIN_PET_NAME);
if(wname.size() < minName)
return PET_NAME_TOO_SHORT;
uint32 strictMask = sWorld.getConfig(CONFIG_STRICT_PET_NAMES);
if(!isValidString(wname,strictMask,false))
return PET_NAME_MIXED_LANGUAGES;
return isValidString(wname,strictMask,false);
return PET_NAME_SUCCESS;
}
int ObjectMgr::GetIndexForLocale( LocaleConstant loc )