diff options
author | Rival <dev.rival@mail.ru> | 2016-08-15 22:26:45 +0400 |
---|---|---|
committer | Shin <borzifrancesco@gmail.com> | 2016-08-15 20:26:45 +0200 |
commit | 3cae5465320c91486044b1d3fd05097ae9df89d2 (patch) | |
tree | 3f4611a6731501bdc76d585b31539b4251c11d90 | |
parent | eddebedb2de18fc29aaf7101f5522df9ab1eea44 (diff) |
Core/Misc: Adding localization DBC. (#95)
-rw-r--r-- | src/game/World/World.cpp | 25 | ||||
-rw-r--r-- | src/game/World/World.h | 3 |
2 files changed, 24 insertions, 4 deletions
diff --git a/src/game/World/World.cpp b/src/game/World/World.cpp index 698f1b3f44..61ed66c3aa 100644 --- a/src/game/World/World.cpp +++ b/src/game/World/World.cpp @@ -1850,26 +1850,43 @@ void World::SetInitialWorldSettings() void World::DetectDBCLang() { + uint8 m_lang_confid = sConfigMgr->GetIntDefault("DBC.Locale", 255); + + if (m_lang_confid != 255 && m_lang_confid >= TOTAL_LOCALES) + { + sLog->outError("Incorrect DBC.Locale! Must be >= 0 and < %d (set to 0)", TOTAL_LOCALES); + m_lang_confid = LOCALE_enUS; + } + ChrRacesEntry const* race = sChrRacesStore.LookupEntry(1); std::string availableLocalsStr; - uint8 locale = TOTAL_LOCALES; - for (uint8 i = locale-1; i < TOTAL_LOCALES; --i) // -1 will be 255 due to uint8 + uint8 default_locale = TOTAL_LOCALES; + for (uint8 i = default_locale -1; i < TOTAL_LOCALES; --i) // -1 will be 255 due to uint8 { if (race->name[i][0] != '\0') // check by race names { - locale = i; + default_locale = i; + m_availableDbcLocaleMask |= (1 << i); availableLocalsStr += localeNames[i]; availableLocalsStr += " "; } } - if (locale != GetDefaultDbcLocale()) + if (default_locale != m_lang_confid && m_lang_confid < TOTAL_LOCALES && + (m_availableDbcLocaleMask & (1 << m_lang_confid))) + { + default_locale = m_lang_confid; + } + + if (default_locale >= TOTAL_LOCALES) { sLog->outError("Unable to determine your DBC Locale! (corrupt DBC?)"); exit(1); } + m_defaultDbcLocale = LocaleConstant(default_locale); + sLog->outString("Using %s DBC Locale as default. All available DBC locales: %s", localeNames[GetDefaultDbcLocale()], availableLocalsStr.empty() ? "<none>" : availableLocalsStr.c_str()); sLog->outString(); } diff --git a/src/game/World/World.h b/src/game/World/World.h index d3ca219cd4..1294bc245f 100644 --- a/src/game/World/World.h +++ b/src/game/World/World.h @@ -754,6 +754,8 @@ class World void UpdateRealmCharCount(uint32 accid); + LocaleConstant GetAvailableDbcLocale(LocaleConstant locale) const { if (m_availableDbcLocaleMask & (1 << locale)) return locale; else return m_defaultDbcLocale; } + // used World DB version void LoadDBVersion(); char const* GetDBVersion() const { return m_DBVersion.c_str(); } @@ -824,6 +826,7 @@ class World uint32 m_playerLimit; AccountTypes m_allowedSecurityLevel; LocaleConstant m_defaultDbcLocale; // from config for one from loaded DBC locales + uint32 m_availableDbcLocaleMask; // by loaded DBC void DetectDBCLang(); bool m_allowMovement; std::string m_motd; |