mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-29 05:11:55 +01:00
Core/World: refactored locale detection to resolve a ill-defined for loop warning
This commit is contained in:
@@ -2247,29 +2247,32 @@ void World::DetectDBCLang()
|
||||
std::string availableLocalsStr;
|
||||
|
||||
uint8 default_locale = TOTAL_LOCALES;
|
||||
for (uint8 i = default_locale-1; i < TOTAL_LOCALES; --i) // -1 will be 255 due to uint8
|
||||
for (uint8 i = LOCALE_enUS; i < TOTAL_LOCALES; ++i)
|
||||
{
|
||||
if (race->Name[i][0] != '\0') // check by race names
|
||||
{
|
||||
default_locale = i;
|
||||
// Mark the first found locale as default locale
|
||||
if (default_locale == TOTAL_LOCALES)
|
||||
default_locale = i;
|
||||
|
||||
m_availableDbcLocaleMask |= (1 << i);
|
||||
availableLocalsStr += localeNames[i];
|
||||
availableLocalsStr += " ";
|
||||
}
|
||||
}
|
||||
|
||||
if (m_availableDbcLocaleMask == 0)
|
||||
{
|
||||
TC_LOG_ERROR("server.loading", "Unable to determine your DBC Locale! (corrupt DBC?)");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
TC_LOG_ERROR("server.loading", "Unable to determine your DBC Locale! (corrupt DBC?)");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
m_defaultDbcLocale = LocaleConstant(default_locale);
|
||||
|
||||
TC_LOG_INFO("server.loading", "Using {} DBC Locale as default. All available DBC locales: {}", localeNames[m_defaultDbcLocale], availableLocalsStr.empty() ? "<none>" : availableLocalsStr);
|
||||
|
||||
Reference in New Issue
Block a user