aboutsummaryrefslogtreecommitdiff
path: root/src/game/ObjectMgr.cpp
diff options
context:
space:
mode:
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 )