Core/Misc: Adding localization DBC. (#95)

This commit is contained in:
Rival
2016-08-15 22:26:45 +04:00
committed by Shin
parent eddebedb2d
commit 3cae546532
2 changed files with 24 additions and 4 deletions
+21 -4
View File
@@ -1850,26 +1850,43 @@ void World::SetInitialWorldSettings()
void World::DetectDBCLang() 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); ChrRacesEntry const* race = sChrRacesStore.LookupEntry(1);
std::string availableLocalsStr; std::string availableLocalsStr;
uint8 locale = TOTAL_LOCALES; uint8 default_locale = TOTAL_LOCALES;
for (uint8 i = locale-1; i < TOTAL_LOCALES; --i) // -1 will be 255 due to uint8 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 if (race->name[i][0] != '\0') // check by race names
{ {
locale = i; default_locale = i;
m_availableDbcLocaleMask |= (1 << i);
availableLocalsStr += localeNames[i]; availableLocalsStr += localeNames[i];
availableLocalsStr += " "; 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?)"); sLog->outError("Unable to determine your DBC Locale! (corrupt DBC?)");
exit(1); 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("Using %s DBC Locale as default. All available DBC locales: %s", localeNames[GetDefaultDbcLocale()], availableLocalsStr.empty() ? "<none>" : availableLocalsStr.c_str());
sLog->outString(); sLog->outString();
} }
+3
View File
@@ -754,6 +754,8 @@ class World
void UpdateRealmCharCount(uint32 accid); void UpdateRealmCharCount(uint32 accid);
LocaleConstant GetAvailableDbcLocale(LocaleConstant locale) const { if (m_availableDbcLocaleMask & (1 << locale)) return locale; else return m_defaultDbcLocale; }
// used World DB version // used World DB version
void LoadDBVersion(); void LoadDBVersion();
char const* GetDBVersion() const { return m_DBVersion.c_str(); } char const* GetDBVersion() const { return m_DBVersion.c_str(); }
@@ -824,6 +826,7 @@ class World
uint32 m_playerLimit; uint32 m_playerLimit;
AccountTypes m_allowedSecurityLevel; AccountTypes m_allowedSecurityLevel;
LocaleConstant m_defaultDbcLocale; // from config for one from loaded DBC locales LocaleConstant m_defaultDbcLocale; // from config for one from loaded DBC locales
uint32 m_availableDbcLocaleMask; // by loaded DBC
void DetectDBCLang(); void DetectDBCLang();
bool m_allowMovement; bool m_allowMovement;
std::string m_motd; std::string m_motd;