diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/common/Common.cpp | 4 | ||||
-rw-r--r-- | src/common/Common.h | 5 | ||||
-rw-r--r-- | src/server/bnetserver/Server/Session.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Achievements/AchievementMgr.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Globals/ObjectMgr.cpp | 26 | ||||
-rw-r--r-- | src/server/game/Texts/CreatureTextMgr.cpp | 2 |
6 files changed, 23 insertions, 18 deletions
diff --git a/src/common/Common.cpp b/src/common/Common.cpp index b768461e274..a176941e6f9 100644 --- a/src/common/Common.cpp +++ b/src/common/Common.cpp @@ -33,11 +33,11 @@ char const* localeNames[TOTAL_LOCALES] = "itIT" }; -LocaleConstant GetLocaleByName(const std::string& name) +LocaleConstant GetLocaleByName(std::string const& name) { for (uint32 i = 0; i < TOTAL_LOCALES; ++i) if (name == localeNames[i]) return LocaleConstant(i); - return LOCALE_enUS; // including enGB case + return TOTAL_LOCALES; } diff --git a/src/common/Common.h b/src/common/Common.h index 732583da0de..f35773e7c70 100644 --- a/src/common/Common.h +++ b/src/common/Common.h @@ -101,6 +101,11 @@ TC_COMMON_API extern char const* localeNames[TOTAL_LOCALES]; TC_COMMON_API LocaleConstant GetLocaleByName(std::string const& name); +constexpr inline bool IsValidLocale(LocaleConstant locale) +{ + return locale < TOTAL_LOCALES&& locale != LOCALE_none; +} + #pragma pack(push, 1) struct LocalizedString diff --git a/src/server/bnetserver/Server/Session.cpp b/src/server/bnetserver/Server/Session.cpp index 6a41c0f1dc2..9e3ec49a0ca 100644 --- a/src/server/bnetserver/Server/Session.cpp +++ b/src/server/bnetserver/Server/Session.cpp @@ -218,7 +218,7 @@ uint32 Battlenet::Session::HandleLogon(authentication::v1::LogonRequest const* l return ERROR_BAD_PLATFORM; } - if (GetLocaleByName(logonRequest->locale()) == LOCALE_enUS && logonRequest->locale() != "enUS") + if (!IsValidLocale(GetLocaleByName(logonRequest->locale()))) { TC_LOG_DEBUG("session", "[Battlenet::LogonRequest] %s attempted to log in with unsupported locale (using %s)!", GetClientInfo().c_str(), logonRequest->locale().c_str()); return ERROR_BAD_LOCALE; diff --git a/src/server/game/Achievements/AchievementMgr.cpp b/src/server/game/Achievements/AchievementMgr.cpp index a0b82470eac..b751ab1e82f 100644 --- a/src/server/game/Achievements/AchievementMgr.cpp +++ b/src/server/game/Achievements/AchievementMgr.cpp @@ -1300,7 +1300,7 @@ void AchievementGlobalMgr::LoadRewardLocales() AchievementRewardLocale& data = _achievementRewardLocales[id]; LocaleConstant locale = GetLocaleByName(localeName); - if (locale == LOCALE_enUS) + if (!IsValidLocale(locale) || locale == LOCALE_enUS) continue; ObjectMgr::AddLocaleString(fields[2].GetString(), locale, data.Subject); diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 2fb6dfa2f51..f0fc3f5e297 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -336,7 +336,7 @@ void ObjectMgr::LoadCreatureLocales() std::string localeName = fields[1].GetString(); LocaleConstant locale = GetLocaleByName(localeName); - if (locale == LOCALE_enUS) + if (!IsValidLocale(locale) || locale == LOCALE_enUS) continue; CreatureLocale& data = _creatureLocaleStore[id]; @@ -371,7 +371,7 @@ void ObjectMgr::LoadGossipMenuItemsLocales() std::string localeName = fields[2].GetString(); LocaleConstant locale = GetLocaleByName(localeName); - if (locale == LOCALE_enUS) + if (!IsValidLocale(locale) || locale == LOCALE_enUS) continue; GossipMenuItemsLocale& data = _gossipMenuItemsLocaleStore[std::make_pair(menuId, optionIndex)]; @@ -401,7 +401,7 @@ void ObjectMgr::LoadPointOfInterestLocales() std::string localeName = fields[1].GetString(); LocaleConstant locale = GetLocaleByName(localeName); - if (locale == LOCALE_enUS) + if (!IsValidLocale(locale) || locale == LOCALE_enUS) continue; PointOfInterestLocale& data = _pointOfInterestLocaleStore[id]; @@ -4758,7 +4758,7 @@ void ObjectMgr::LoadQuestTemplateLocale() std::string localeName = fields[1].GetString(); LocaleConstant locale = GetLocaleByName(localeName); - if (locale == LOCALE_enUS) + if (!IsValidLocale(locale) || locale == LOCALE_enUS) continue; QuestTemplateLocale& data = _questTemplateLocaleStore[id]; @@ -4794,7 +4794,7 @@ void ObjectMgr::LoadQuestObjectivesLocale() std::string localeName = fields[1].GetString(); LocaleConstant locale = GetLocaleByName(localeName); - if (locale == LOCALE_enUS) + if (!IsValidLocale(locale) || locale == LOCALE_enUS) continue; QuestObjectivesLocale& data = _questObjectivesLocaleStore[id]; @@ -4847,7 +4847,7 @@ void ObjectMgr::LoadQuestGreetingLocales() std::string localeName = fields[2].GetString(); LocaleConstant locale = GetLocaleByName(localeName); - if (locale == LOCALE_enUS) + if (!IsValidLocale(locale) || locale == LOCALE_enUS) continue; QuestGreetingLocale& data = _questGreetingLocaleStore[type][id]; @@ -4877,7 +4877,7 @@ void ObjectMgr::LoadQuestOfferRewardLocale() std::string localeName = fields[1].GetString(); LocaleConstant locale = GetLocaleByName(localeName); - if (locale == LOCALE_enUS) + if (!IsValidLocale(locale) || locale == LOCALE_enUS) continue; QuestOfferRewardLocale& data = _questOfferRewardLocaleStore[id]; @@ -4905,7 +4905,7 @@ void ObjectMgr::LoadQuestRequestItemsLocale() std::string localeName = fields[1].GetString(); LocaleConstant locale = GetLocaleByName(localeName); - if (locale == LOCALE_enUS) + if (!IsValidLocale(locale) || locale == LOCALE_enUS) continue; QuestRequestItemsLocale& data = _questRequestItemsLocaleStore[id]; @@ -5545,7 +5545,7 @@ void ObjectMgr::LoadPageTextLocales() std::string localeName = fields[1].GetString(); LocaleConstant locale = GetLocaleByName(localeName); - if (locale == LOCALE_enUS) + if (!IsValidLocale(locale) || locale == LOCALE_enUS) continue; PageTextLocale& data = _pageTextLocaleStore[id]; @@ -6943,7 +6943,7 @@ void ObjectMgr::LoadGameObjectLocales() std::string localeName = fields[1].GetString(); LocaleConstant locale = GetLocaleByName(localeName); - if (locale == LOCALE_enUS) + if (!IsValidLocale(locale) || locale == LOCALE_enUS) continue; GameObjectLocale& data = _gameObjectLocaleStore[id]; @@ -8728,7 +8728,7 @@ void ObjectMgr::LoadTrainers() std::string localeName = fields[1].GetString(); LocaleConstant locale = GetLocaleByName(localeName); - if (locale == LOCALE_enUS) + if (!IsValidLocale(locale) || locale == LOCALE_enUS) continue; if (Trainer::Trainer* trainer = Trinity::Containers::MapGetValuePtr(_trainers, trainerId)) @@ -10477,7 +10477,7 @@ void ObjectMgr::LoadPlayerChoicesLocale() } LocaleConstant locale = GetLocaleByName(localeName); - if (locale == LOCALE_enUS) + if (!IsValidLocale(locale) || locale == LOCALE_enUS) continue; PlayerChoiceLocale& data = _playerChoiceLocales[choiceId]; @@ -10518,7 +10518,7 @@ void ObjectMgr::LoadPlayerChoicesLocale() } LocaleConstant locale = GetLocaleByName(localeName); - if (locale == LOCALE_enUS) + if (!IsValidLocale(locale) || locale == LOCALE_enUS) continue; PlayerChoiceResponseLocale& data = itr->second.Responses[responseId]; diff --git a/src/server/game/Texts/CreatureTextMgr.cpp b/src/server/game/Texts/CreatureTextMgr.cpp index 78e96e12492..30f578aa872 100644 --- a/src/server/game/Texts/CreatureTextMgr.cpp +++ b/src/server/game/Texts/CreatureTextMgr.cpp @@ -197,7 +197,7 @@ void CreatureTextMgr::LoadCreatureTextLocales() std::string localeName = fields[3].GetString(); LocaleConstant locale = GetLocaleByName(localeName); - if (locale == LOCALE_enUS) + if (!IsValidLocale(locale) || locale == LOCALE_enUS) continue; CreatureTextLocale& data = mLocaleTextMap[CreatureTextId(creatureId, groupId, id)]; |