summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-04-23 18:27:53 +0000
committerpeter1138 <peter1138@openttd.org>2006-04-23 18:27:53 +0000
commitbaebc8d47e33e0c0a9a5cd3943afabeafabc19d9 (patch)
tree0f5c1d602bdc27f39eadaa2e27cc65bc3cab160b
parentb54ebaba70f211044ba8aa39ee13599b3945b2ff (diff)
downloadopenttd-baebc8d47e33e0c0a9a5cd3943afabeafabc19d9.tar.xz
(svn r4550) - NewGRF: update string system to new rules: a grf version of less than 6 uses the old scheme, of 7 or more uses the new scheme. (Moving targets, yay...)
-rw-r--r--newgrf.c3
-rw-r--r--newgrf_text.c16
-rw-r--r--newgrf_text.h2
3 files changed, 11 insertions, 10 deletions
diff --git a/newgrf.c b/newgrf.c
index 584f671e3..a38dceb49 100644
--- a/newgrf.c
+++ b/newgrf.c
@@ -1725,6 +1725,7 @@ static void VehicleNewName(byte *buf, int len)
uint16 id;
uint16 endid;
const char* name;
+ bool new_scheme = _cur_grffile->grf_version < 7;
check_length(len, 6, "VehicleNewName");
buf++;
@@ -1754,7 +1755,7 @@ static void VehicleNewName(byte *buf, int len)
case GSF_ROAD:
case GSF_SHIP:
case GSF_AIRCRAFT: {
- StringID string = AddGRFString(_cur_grffile->grfid, id, lang, name);
+ StringID string = AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name);
if (id < TOTAL_NUM_ENGINES) SetCustomEngineName(id, string);
break;
}
diff --git a/newgrf_text.c b/newgrf_text.c
index 5dc322492..1001ed15b 100644
--- a/newgrf_text.c
+++ b/newgrf_text.c
@@ -64,6 +64,7 @@ typedef enum grf_extended_languages {
GRFLX_PORTUGUESE = 0x36,
GRFLX_BRAZILIAN = 0x37,
GRFLX_TURKISH = 0x3E,
+ GRFLX_UNSPECIFIED = 0x7F,
} grf_language;
@@ -119,28 +120,27 @@ static byte _currentLangID = GRFLX_ENGLISH; //by default, english is used.
/**
- * Add the new read stirng into our structure.
- * TODO : ajust the old scheme to the new one for german,french and spanish
+ * Add the new read string into our structure.
*/
-StringID AddGRFString(uint32 grfid, uint16 stringid, byte langid_to_add, const char *text_to_add)
+StringID AddGRFString(uint32 grfid, uint16 stringid, byte langid_to_add, bool new_scheme, const char *text_to_add)
{
GRFText *newtext;
uint id;
- /* When working with the old language scheme (bit 6 of langid is clear) and
+ /* When working with the old language scheme (grf_version is less than 7) and
* English or American is among the set bits, simply add it as English in
* the new scheme, i.e. as langid = 1.
* If English is set, it is pretty safe to assume the translations are not
* actually translated.
*/
- if (!HASBIT(langid_to_add, 6)) {
+ if (!new_scheme) {
if (HASBITS(langid_to_add, GRFLB_AMERICAN | GRFLB_ENGLISH)) {
langid_to_add = GRFLX_ENGLISH;
} else {
StringID ret = STR_EMPTY;
- if (langid_to_add & GRFLB_GERMAN) ret = AddGRFString(grfid, stringid, 1 << 6 | GRFLX_GERMAN, text_to_add);
- if (langid_to_add & GRFLB_FRENCH) ret = AddGRFString(grfid, stringid, 1 << 6 | GRFLX_FRENCH, text_to_add);
- if (langid_to_add & GRFLB_SPANISH) ret = AddGRFString(grfid, stringid, 1 << 6 | GRFLX_SPANISH, text_to_add);
+ if (langid_to_add & GRFLB_GERMAN) ret = AddGRFString(grfid, stringid, 1 << 6 | GRFLX_GERMAN, true, text_to_add);
+ if (langid_to_add & GRFLB_FRENCH) ret = AddGRFString(grfid, stringid, 1 << 6 | GRFLX_FRENCH, true, text_to_add);
+ if (langid_to_add & GRFLB_SPANISH) ret = AddGRFString(grfid, stringid, 1 << 6 | GRFLX_SPANISH, true, text_to_add);
return ret;
}
}
diff --git a/newgrf_text.h b/newgrf_text.h
index 5d43c4ae2..8d4b3f47f 100644
--- a/newgrf_text.h
+++ b/newgrf_text.h
@@ -30,7 +30,7 @@ typedef struct GRFTextEntry {
} GRFTextEntry;
-StringID AddGRFString(uint32 grfid, uint16 stringid, byte langid, const char *text_to_add);
+StringID AddGRFString(uint32 grfid, uint16 stringid, byte langid, bool new_scheme, const char *text_to_add);
StringID GetGRFStringID(uint32 grfid, uint16 stringid);
char *GetGRFString(char *buff, uint16 stringid);
void CleanUpStrings(void);