Fix client hanging when default language cannot be determined

The loop was not terminating correctly, so the client hangs when the language index file is missing.
This commit is contained in:
Robert Müller 2023-04-05 21:24:52 +02:00
parent 1112c9e6b7
commit 5db9f029e4

View file

@ -148,6 +148,14 @@ void CLocalizationDatabase::LoadIndexfile(IStorage *pStorage, IConsole *pConsole
void CLocalizationDatabase::SelectDefaultLanguage(IConsole *pConsole, char *pFilename, size_t Length) const void CLocalizationDatabase::SelectDefaultLanguage(IConsole *pConsole, char *pFilename, size_t Length) const
{ {
if(Languages().empty())
return;
if(Languages().size() == 1)
{
str_copy(pFilename, Languages()[0].m_FileName.c_str(), Length);
return;
}
char aLocaleStr[128]; char aLocaleStr[128];
os_locale_str(aLocaleStr, sizeof(aLocaleStr)); os_locale_str(aLocaleStr, sizeof(aLocaleStr));
@ -194,7 +202,7 @@ void CLocalizationDatabase::SelectDefaultLanguage(IConsole *pConsole, char *pFil
} }
// Stop if no more locale segments are left // Stop if no more locale segments are left
if(i == 0) if(i <= 0)
break; break;
} }
} }