diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/DataStores/DB2Stores.cpp | 22 | ||||
-rw-r--r-- | src/server/game/DataStores/DB2Stores.h | 4 | ||||
-rw-r--r-- | src/server/game/Globals/ObjectMgr.cpp | 2 |
3 files changed, 18 insertions, 10 deletions
diff --git a/src/server/game/DataStores/DB2Stores.cpp b/src/server/game/DataStores/DB2Stores.cpp index d6dc6630581..39bf3eb5501 100644 --- a/src/server/game/DataStores/DB2Stores.cpp +++ b/src/server/game/DataStores/DB2Stores.cpp @@ -652,8 +652,10 @@ void DB2Manager::LoadStores(std::string const& dataPath, uint32 defaultLocale) for (NamesProfanityEntry const* namesProfanity : sNamesProfanityStore) { ASSERT(namesProfanity->Language < TOTAL_LOCALES || namesProfanity->Language == -1); + std::wstring name; + ASSERT(Utf8toWStr(namesProfanity->Name, name)); if (namesProfanity->Language != -1) - _nameValidators[namesProfanity->Language].emplace_back(namesProfanity->Name, std::regex::icase | std::regex::optimize); + _nameValidators[namesProfanity->Language].emplace_back(name, std::regex::icase | std::regex::optimize); else { for (uint32 i = 0; i < TOTAL_LOCALES; ++i) @@ -661,24 +663,30 @@ void DB2Manager::LoadStores(std::string const& dataPath, uint32 defaultLocale) if (i == LOCALE_none) continue; - _nameValidators[i].emplace_back(namesProfanity->Name, std::regex::icase | std::regex::optimize); + _nameValidators[i].emplace_back(name, std::regex::icase | std::regex::optimize); } } } for (NamesReservedEntry const* namesReserved : sNamesReservedStore) - _nameValidators[TOTAL_LOCALES].emplace_back(namesReserved->Name, std::regex::icase | std::regex::optimize); + { + std::wstring name; + ASSERT(Utf8toWStr(namesReserved->Name, name)); + _nameValidators[TOTAL_LOCALES].emplace_back(name, std::regex::icase | std::regex::optimize); + } for (NamesReservedLocaleEntry const* namesReserved : sNamesReservedLocaleStore) { ASSERT(!(namesReserved->LocaleMask & ~((1 << TOTAL_LOCALES) - 1))); + std::wstring name; + ASSERT(Utf8toWStr(namesReserved->Name, name)); for (uint32 i = 0; i < TOTAL_LOCALES; ++i) { if (i == LOCALE_none) continue; if (namesReserved->LocaleMask & (1 << i)) - _nameValidators[i].emplace_back(namesReserved->Name, std::regex::icase | std::regex::optimize); + _nameValidators[i].emplace_back(name, std::regex::icase | std::regex::optimize); } } @@ -1260,14 +1268,14 @@ std::string DB2Manager::GetNameGenEntry(uint8 race, uint8 gender, LocaleConstant return data->Str[sWorld->GetDefaultDbcLocale()]; } -ResponseCodes DB2Manager::ValidateName(std::string const& name, LocaleConstant locale) const +ResponseCodes DB2Manager::ValidateName(std::wstring const& name, LocaleConstant locale) const { - for (std::regex const& regex : _nameValidators[locale]) + for (std::wregex const& regex : _nameValidators[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 : _nameValidators[TOTAL_LOCALES]) + for (std::wregex const& regex : _nameValidators[TOTAL_LOCALES]) if (std::regex_search(name, regex)) return CHAR_NAME_RESERVED; diff --git a/src/server/game/DataStores/DB2Stores.h b/src/server/game/DataStores/DB2Stores.h index 6eacd323fd5..efe9bef5754 100644 --- a/src/server/game/DataStores/DB2Stores.h +++ b/src/server/game/DataStores/DB2Stores.h @@ -241,7 +241,7 @@ public: typedef std::set<MountTypeXCapabilityEntry const*, MountTypeXCapabilityEntryComparator> MountTypeXCapabilitySet; typedef std::unordered_map<uint32, MountTypeXCapabilitySet> MountCapabilitiesByTypeContainer; typedef std::unordered_map<uint32, std::array<std::vector<NameGenEntry const*>, 2>> NameGenContainer; - typedef std::array<std::vector<std::regex>, TOTAL_LOCALES + 1> NameValidationRegexContainer; + typedef std::array<std::vector<std::wregex>, TOTAL_LOCALES + 1> NameValidationRegexContainer; typedef std::unordered_map<uint32, std::set<uint32>> PhaseGroupContainer; typedef std::unordered_map<uint32, std::vector<QuestPackageItemEntry const*>> QuestPackageItemContainer; typedef std::unordered_map<uint32, uint32> RulesetItemUpgradeContainer; @@ -297,7 +297,7 @@ public: MountEntry const* GetMount(uint32 spellId) const; MountEntry const* GetMountById(uint32 id) const; MountTypeXCapabilitySet const* GetMountCapabilities(uint32 mountType) const; - ResponseCodes ValidateName(std::string const& name, LocaleConstant locale) const; + ResponseCodes ValidateName(std::wstring const& name, LocaleConstant locale) const; std::set<uint32> GetPhasesForGroup(uint32 group) const; static PvPDifficultyEntry const* GetBattlegroundBracketByLevel(uint32 mapid, uint32 level); static PvPDifficultyEntry const* GetBattlegroundBracketById(uint32 mapid, BattlegroundBracketId id); diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index ae81cf9a6c4..3b731ef2519 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -7638,7 +7638,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 sDB2Manager.ValidateName(name, locale); + return sDB2Manager.ValidateName(wname, locale); } bool ObjectMgr::IsValidCharterName(const std::string& name) |