(svn r6289) -Fix(r6108) : case 0x48 (generic text) should not have been set over newstations.

It grabbed everyting. Instead, we are now using ids for that purpose,  0xC9, oxD0, 0xDC (FS#304 by Osai)
- Protect newgrf text from entries of 1 char and fewer
- Protect currency name from an overrun of ids
Thanks to glx
This commit is contained in:
belugas 2006-09-01 02:56:02 +00:00
parent 718c0214bf
commit c05c81f35c
2 changed files with 13 additions and 8 deletions

View File

@ -1090,10 +1090,11 @@ static bool GlobalVarChangeInfo(uint gvid, int numinfo, int prop, byte **bufp, i
case 0x0A: // Currency display names case 0x0A: // Currency display names
FOR_EACH_OBJECT { FOR_EACH_OBJECT {
uint curidx = gvid + i;
StringID newone = GetGRFStringID(_cur_grffile->grfid,grf_load_word(&buf)); StringID newone = GetGRFStringID(_cur_grffile->grfid,grf_load_word(&buf));
if (newone != STR_UNDEFINED) { if ((newone != STR_UNDEFINED) && (curidx < NUM_CURRENCY)) {
_currency_specs[gvid + i].name = newone; _currency_specs[curidx].name = newone;
} }
} }
break; break;
@ -1153,7 +1154,7 @@ static bool GlobalVarChangeInfo(uint gvid, int numinfo, int prop, byte **bufp, i
} }
break; break;
case 0x0F: // Euro introduction datess case 0x0F: // Euro introduction dates
FOR_EACH_OBJECT { FOR_EACH_OBJECT {
uint curidx = gvid +i; uint curidx = gvid +i;
Year year_euro = grf_load_word(&buf); Year year_euro = grf_load_word(&buf);
@ -1900,11 +1901,6 @@ static void FeatureNewName(byte *buf, int len)
break; break;
} }
case 0x48 : { // this will allow things like currencies new strings, and everything else
AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, id);
break;
}
default: default:
switch (GB(id, 8, 8)) { switch (GB(id, 8, 8)) {
case 0xC4: /* Station class name */ case 0xC4: /* Station class name */
@ -1924,6 +1920,12 @@ static void FeatureNewName(byte *buf, int len)
} }
break; break;
case 0xC9:
case 0xD0:
case 0xDC:
AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED);
break;
default: default:
DEBUG(grf, 7) ("FeatureNewName: Unsupported ID (0x%04X)", id); DEBUG(grf, 7) ("FeatureNewName: Unsupported ID (0x%04X)", id);
break; break;

View File

@ -204,6 +204,9 @@ StringID AddGRFString(uint32 grfid, uint16 stringid, byte langid_to_add, bool ne
GRFText *newtext; GRFText *newtext;
uint id; uint id;
/* We do not allow strings of only one char or even fewer*/
if (strlen(text_to_add) <= 1) return STR_EMPTY;
/* When working with the old language scheme (grf_version is less than 7) 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 * English or American is among the set bits, simply add it as English in
* the new scheme, i.e. as langid = 1. * the new scheme, i.e. as langid = 1.