# HG changeset patch # User peter1138 # Date 1162060977 0 # Node ID bd2716c79584c5165f0e4215e971011b1409b4f5 # Parent a9f3eb46f329d0e20ff6423a948638f228903881 (svn r6995) - Codechange: NewGRF; strip bit 7 of the language ID earlier and handle handle a language ID of 0x7F as the preferred default language. diff -r a9f3eb46f329 -r bd2716c79584 newgrf.c --- a/newgrf.c Sat Oct 28 14:37:33 2006 +0000 +++ b/newgrf.c Sat Oct 28 18:42:57 2006 +0000 @@ -1961,13 +1961,17 @@ uint16 endid; const char* name; bool new_scheme = _cur_grffile->grf_version >= 7; + bool generic; check_length(len, 6, "FeatureNewName"); buf++; feature = grf_load_byte(&buf); lang = grf_load_byte(&buf); num = grf_load_byte(&buf); - id = (lang & 0x80) ? grf_load_word(&buf) : grf_load_byte(&buf); + generic = HASBIT(lang, 7); + id = generic ? grf_load_word(&buf) : grf_load_byte(&buf); + + CLRBIT(lang, 7); if (feature <= GSF_AIRCRAFT && id < _vehcounts[feature]) { id += _vehshifts[feature]; @@ -1978,7 +1982,8 @@ id, endid, feature, lang); name = (const char*)buf; /*transfer read value*/ - len -= (lang & 0x80) ? 6 : 5; + len -= generic ? 6 : 5; + for (; id < endid && len > 0; id++) { size_t ofs = strlen(name) + 1; diff -r a9f3eb46f329 -r bd2716c79584 newgrf_text.c --- a/newgrf_text.c Sat Oct 28 14:37:33 2006 +0000 +++ b/newgrf_text.c Sat Oct 28 18:42:57 2006 +0000 @@ -233,7 +233,7 @@ newtext = malloc(sizeof(*newtext) + strlen(text_to_add) + 1); newtext->next = NULL; - newtext->langid = GB(langid_to_add, 0, 6); + newtext->langid = langid_to_add; strcpy(newtext->text, text_to_add); TranslateTTDPatchCodes(newtext->text); @@ -252,7 +252,7 @@ /* Loop through all languages and see if we can replace a string */ for (ptext = &_grf_text[id].textholder; (text = *ptext) != NULL; ptext = &text->next) { - if (text->langid != GB(langid_to_add, 0, 6)) continue; + if (text->langid != langid_to_add) continue; newtext->next = text->next; *ptext = newtext; free(text); @@ -310,7 +310,7 @@ /* If the current string is English or American, set it as the * fallback language if the specific language isn't available. */ - if (search_text->langid == GRFLX_ENGLISH || search_text->langid == GRFLX_AMERICAN) { + if (search_text->langid == GRFLX_UNSPECIFIED || (default_text == NULL && (search_text->langid == GRFLX_ENGLISH || search_text->langid == GRFLX_AMERICAN))) { default_text = search_text; } }