mirror of https://github.com/OpenTTD/OpenTTD
(svn r9373) -Fix (r9271): the chosen language was not stored nor read properly in/from the cfg.
parent
48f2bf9bb1
commit
154c7c4bcf
|
@ -1116,7 +1116,8 @@ bool ReadLanguagePack(int lang_index)
|
||||||
free(_langpack_offs);
|
free(_langpack_offs);
|
||||||
_langpack_offs = langpack_offs;
|
_langpack_offs = langpack_offs;
|
||||||
|
|
||||||
ttd_strlcpy(_dynlang.curr_file, _dynlang.ent[lang_index].file, lengthof(_dynlang.curr_file));
|
const char *c_file = strrchr(_dynlang.ent[lang_index].file, PATHSEPCHAR) + 1;
|
||||||
|
ttd_strlcpy(_dynlang.curr_file, c_file, lengthof(_dynlang.curr_file));
|
||||||
|
|
||||||
_dynlang.curr = lang_index;
|
_dynlang.curr = lang_index;
|
||||||
SetCurrentGrfLangID(_langpack->isocode);
|
SetCurrentGrfLangID(_langpack->isocode);
|
||||||
|
@ -1165,7 +1166,7 @@ static int CDECL LanguageCompareFunc(const void *a, const void *b)
|
||||||
static bool UniqueLanguageFile(const Language *langs, uint max, const char *language)
|
static bool UniqueLanguageFile(const Language *langs, uint max, const char *language)
|
||||||
{
|
{
|
||||||
for (uint i = 0; i < max; i++) {
|
for (uint i = 0; i < max; i++) {
|
||||||
const char *f_name = strrchr(langs[i].file, PATHSEPCHAR);
|
const char *f_name = strrchr(langs[i].file, PATHSEPCHAR) + 1;
|
||||||
if (strcmp(f_name, language) == 0) return false; // duplicates
|
if (strcmp(f_name, language) == 0) return false; // duplicates
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1268,7 +1269,8 @@ void InitializeLanguagePacks()
|
||||||
/* We are trying to find a default language. The priority is by
|
/* We are trying to find a default language. The priority is by
|
||||||
* configuration file, local environment and last, if nothing found,
|
* configuration file, local environment and last, if nothing found,
|
||||||
* english. If def equals -1, we have not picked a default language */
|
* english. If def equals -1, we have not picked a default language */
|
||||||
if (strcmp(dl->ent[dl->num].file, dl->curr_file) == 0) chosen_language = dl->num;
|
const char *lang_file = strrchr(dl->ent[dl->num].file, PATHSEPCHAR) + 1;
|
||||||
|
if (strcmp(lang_file, dl->curr_file) == 0) chosen_language = dl->num;
|
||||||
|
|
||||||
if (chosen_language == -1) {
|
if (chosen_language == -1) {
|
||||||
if (strcmp (hdr.isocode, "en_GB") == 0) en_GB_fallback = dl->num;
|
if (strcmp (hdr.isocode, "en_GB") == 0) en_GB_fallback = dl->num;
|
||||||
|
|
|
@ -325,7 +325,7 @@ struct Language {
|
||||||
struct DynamicLanguages {
|
struct DynamicLanguages {
|
||||||
int num; ///< Number of languages
|
int num; ///< Number of languages
|
||||||
int curr; ///< Currently selected language index
|
int curr; ///< Currently selected language index
|
||||||
char curr_file[MAX_PATH]; ///< Currently selected language file (needed for saving the filename of the loaded language
|
char curr_file[MAX_PATH]; ///< Currently selected language file name without path (needed for saving the filename of the loaded language).
|
||||||
StringID dropdown[MAX_LANG + 1]; ///< List of languages in the settings gui
|
StringID dropdown[MAX_LANG + 1]; ///< List of languages in the settings gui
|
||||||
Language ent[MAX_LANG]; ///< Information about the languages
|
Language ent[MAX_LANG]; ///< Information about the languages
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue