mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +00:00
[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:
parent
60fe792866
commit
715470a898
12 changed files with 114 additions and 48 deletions
|
|
@ -6645,18 +6645,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 )
|
||||
|
|
@ -6665,7 +6671,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);
|
||||
|
|
@ -6673,18 +6683,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 )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue