Changeset - r3641:bf8cbe28f2dc
[Not reviewed]
master
0 3 0
peter1138 - 18 years ago 2006-04-23 18:27:53
peter1138@openttd.org
(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...)
3 files changed with 11 insertions and 10 deletions:
0 comments (0 inline, 0 general)
newgrf.c
Show inline comments
 
@@ -1722,12 +1722,13 @@ static void VehicleNewName(byte *buf, in
 
	uint8 feature;
 
	uint8 lang;
 
	uint8 num;
 
	uint16 id;
 
	uint16 endid;
 
	const char* name;
 
	bool new_scheme = _cur_grffile->grf_version < 7;
 

	
 
	check_length(len, 6, "VehicleNewName");
 
	buf++;
 
	feature  = grf_load_byte(&buf);
 
	lang     = grf_load_byte(&buf);
 
	num      = grf_load_byte(&buf);
 
@@ -1751,13 +1752,13 @@ static void VehicleNewName(byte *buf, in
 

	
 
			switch (feature) {
 
				case GSF_TRAIN:
 
				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;
 
				}
 

	
 
#if 0
 
				case GSF_STATION:
newgrf_text.c
Show inline comments
 
@@ -61,12 +61,13 @@ typedef enum grf_extended_languages {
 
	GRFLX_FRISIAN     = 0x32,
 
	GRFLX_ESTONIAN    = 0x34,
 
	GRFLX_FINNISH     = 0x35,
 
	GRFLX_PORTUGUESE  = 0x36,
 
	GRFLX_BRAZILIAN   = 0x37,
 
	GRFLX_TURKISH     = 0x3E,
 
	GRFLX_UNSPECIFIED = 0x7F,
 
} grf_language;
 

	
 

	
 
typedef struct iso_grf {
 
	char code[6];
 
	byte grfLangID;
 
@@ -116,34 +117,33 @@ const iso_grf iso_codes[] = {
 
static uint _num_grf_texts = 0;
 
static GRFTextEntry _grf_text[(1 << TABSIZE) * 3];
 
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;
 
		}
 
	}
 

	
 
	newtext = calloc(1, sizeof(*newtext));
 
	newtext->langid = GB(langid_to_add, 0, 6);
newgrf_text.h
Show inline comments
 
@@ -27,13 +27,13 @@ typedef struct GRFTextEntry {
 
	uint32 grfid;
 
	uint16 stringid;
 
	GRFText *textholder;
 
} 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);
 
void SetCurrentGrfLangID(const char *iso_name);
 

	
 
#endif /* NEWGRF_TEXT_H */
0 comments (0 inline, 0 general)