aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/game/DataStores/DBCStores.cpp22
-rw-r--r--src/server/game/DataStores/DBCStores.h2
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp4
3 files changed, 17 insertions, 11 deletions
diff --git a/src/server/game/DataStores/DBCStores.cpp b/src/server/game/DataStores/DBCStores.cpp
index 6e15d104de8..051b5e824bf 100644
--- a/src/server/game/DataStores/DBCStores.cpp
+++ b/src/server/game/DataStores/DBCStores.cpp
@@ -145,7 +145,7 @@ DBCStorage <MovieEntry> sMovieStore(MovieEntryfmt);
DBCStorage<NamesProfanityEntry> sNamesProfanityStore(NamesProfanityEntryfmt);
DBCStorage<NamesReservedEntry> sNamesReservedStore(NamesReservedEntryfmt);
-typedef std::array<std::vector<std::regex>, TOTAL_LOCALES> NameValidationRegexContainer;
+typedef std::array<std::vector<std::wregex>, TOTAL_LOCALES> NameValidationRegexContainer;
NameValidationRegexContainer NamesProfaneValidators;
NameValidationRegexContainer NamesReservedValidators;
@@ -410,11 +410,14 @@ void LoadDBCStores(const std::string& dataPath)
continue;
ASSERT(namesProfanity->Language < TOTAL_LOCALES || namesProfanity->Language == -1);
+ std::wstring wname;
+ ASSERT(Utf8toWStr(namesProfanity->Name, wname));
+
if (namesProfanity->Language != -1)
- NamesProfaneValidators[namesProfanity->Language].emplace_back(namesProfanity->Name, std::regex::icase | std::regex::optimize);
+ NamesProfaneValidators[namesProfanity->Language].emplace_back(wname, std::regex::icase | std::regex::optimize);
else
for (uint32 i = 0; i < TOTAL_LOCALES; ++i)
- NamesProfaneValidators[i].emplace_back(namesProfanity->Name, std::regex::icase | std::regex::optimize);
+ NamesProfaneValidators[i].emplace_back(wname, std::regex::icase | std::regex::optimize);
}
for (uint32 i = 0; i < sNamesReservedStore.GetNumRows(); ++i)
@@ -424,11 +427,14 @@ void LoadDBCStores(const std::string& dataPath)
continue;
ASSERT(namesReserved->Language < TOTAL_LOCALES || namesReserved->Language == -1);
+ std::wstring wname;
+ ASSERT(Utf8toWStr(namesReserved->Name, wname));
+
if (namesReserved->Language != -1)
- NamesReservedValidators[namesReserved->Language].emplace_back(namesReserved->Name, std::regex::icase | std::regex::optimize);
+ NamesReservedValidators[namesReserved->Language].emplace_back(wname, std::regex::icase | std::regex::optimize);
else
for (uint32 i = 0; i < TOTAL_LOCALES; ++i)
- NamesReservedValidators[i].emplace_back(namesReserved->Name, std::regex::icase | std::regex::optimize);
+ NamesReservedValidators[i].emplace_back(wname, std::regex::icase | std::regex::optimize);
}
@@ -1000,17 +1006,17 @@ SkillRaceClassInfoEntry const* GetSkillRaceClassInfo(uint32 skill, uint8 race, u
return NULL;
}
-ResponseCodes ValidateName(std::string const& name, LocaleConstant locale)
+ResponseCodes ValidateName(std::wstring const& name, LocaleConstant locale)
{
if (locale >= TOTAL_LOCALES)
return RESPONSE_FAILURE;
- for (std::regex const& regex : NamesProfaneValidators[locale])
+ for (std::wregex const& regex : NamesProfaneValidators[locale])
if (std::regex_search(name, regex))
return CHAR_NAME_PROFANE;
// regexes at TOTAL_LOCALES are loaded from NamesReserved which is not locale specific
- for (std::regex const& regex : NamesReservedValidators[locale])
+ for (std::wregex const& regex : NamesReservedValidators[locale])
if (std::regex_search(name, regex))
return CHAR_NAME_RESERVED;
diff --git a/src/server/game/DataStores/DBCStores.h b/src/server/game/DataStores/DBCStores.h
index 00b4141555f..128ff7ad1b8 100644
--- a/src/server/game/DataStores/DBCStores.h
+++ b/src/server/game/DataStores/DBCStores.h
@@ -75,7 +75,7 @@ typedef std::unordered_multimap<uint32, SkillRaceClassInfoEntry const*> SkillRac
typedef std::pair<SkillRaceClassInfoMap::iterator, SkillRaceClassInfoMap::iterator> SkillRaceClassInfoBounds;
TC_GAME_API SkillRaceClassInfoEntry const* GetSkillRaceClassInfo(uint32 skill, uint8 race, uint8 class_);
-TC_GAME_API ResponseCodes ValidateName(std::string const& name, LocaleConstant locale);
+TC_GAME_API ResponseCodes ValidateName(std::wstring const& name, LocaleConstant locale);
TC_GAME_API EmotesTextSoundEntry const* FindTextSoundEmoteFor(uint32 emote, uint32 race, uint32 gender);
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index 772e9b970a2..bbd0cee2a51 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -7701,7 +7701,7 @@ ResponseCodes ObjectMgr::CheckPlayerName(std::string const& name, LocaleConstant
if (wname[i] == wname[i-1] && wname[i] == wname[i-2])
return CHAR_NAME_THREE_CONSECUTIVE;
- return ValidateName(name, locale);
+ return ValidateName(wname, locale);
}
bool ObjectMgr::IsValidCharterName(const std::string& name)
@@ -7739,7 +7739,7 @@ PetNameInvalidReason ObjectMgr::CheckPetName(const std::string& name, LocaleCons
if (!isValidString(wname, strictMask, false))
return PET_NAME_MIXED_LANGUAGES;
- switch (ValidateName(name, locale))
+ switch (ValidateName(wname, locale))
{
case CHAR_NAME_PROFANE:
return PET_NAME_PROFANE;