aboutsummaryrefslogtreecommitdiff
path: root/src/game/ObjectMgr.cpp
diff options
context:
space:
mode:
authormegamage <none@none>2009-07-10 08:25:33 +0800
committermegamage <none@none>2009-07-10 08:25:33 +0800
commit6976043e228b35687125e66f19933c44ebc561ba (patch)
tree4c8a8372c34bf276854c0c38e39bbe3b2c6d36b5 /src/game/ObjectMgr.cpp
parent474af870d71a46c02b28a713c19080af6e2f5781 (diff)
[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
Diffstat (limited to 'src/game/ObjectMgr.cpp')
-rw-r--r--src/game/ObjectMgr.cpp40
1 files changed, 28 insertions, 12 deletions
diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp
index bff6975ae81..cbe113d6f6f 100644
--- a/src/game/ObjectMgr.cpp
+++ b/src/game/ObjectMgr.cpp
@@ -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 strictMask = sWorld.getConfig(CONFIG_STRICT_PLAYER_NAMES);
+ uint32 minName = sWorld.getConfig(CONFIG_MIN_PLAYER_NAME);
+ if(wname.size() < minName)
+ return CHAR_NAME_TOO_SHORT;
- return isValidString(wname,strictMask,false,create);
+ uint32 strictMask = sWorld.getConfig(CONFIG_STRICT_PLAYER_NAMES);
+ 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 )