mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-02 09:40:35 +00:00
(svn r12317) -Fix [FS#1815]: Map string IDs that are embedded from other strings.
This commit is contained in:
parent
6bdc8e5fae
commit
9ccce57438
@ -2019,7 +2019,6 @@ enum {
|
||||
*/
|
||||
static void ChangeIndustryProduction(Industry *i, bool monthly)
|
||||
{
|
||||
extern StringID MapGRFStringID(uint32 grfid, StringID str);
|
||||
StringID str = STR_NULL;
|
||||
bool closeit = false;
|
||||
const IndustrySpec *indspec = GetIndustrySpec(i->type);
|
||||
|
@ -3859,12 +3859,12 @@ static void ScanInfo(byte *buf, int len)
|
||||
|
||||
len -= 6;
|
||||
const char *name = grf_load_string(&buf, len);
|
||||
_cur_grfconfig->name = TranslateTTDPatchCodes(name);
|
||||
_cur_grfconfig->name = TranslateTTDPatchCodes(grfid, name);
|
||||
|
||||
len -= strlen(name) + 1;
|
||||
if (len > 0) {
|
||||
const char *info = grf_load_string(&buf, len);
|
||||
_cur_grfconfig->info = TranslateTTDPatchCodes(info);
|
||||
_cur_grfconfig->info = TranslateTTDPatchCodes(grfid, info);
|
||||
}
|
||||
|
||||
/* GLS_INFOSCAN only looks for the action 8, so we can skip the rest of the file */
|
||||
@ -4034,7 +4034,7 @@ static void GRFLoadError(byte *buf, int len)
|
||||
const char *message = grf_load_string(&buf, len);
|
||||
len -= (strlen(message) + 1);
|
||||
|
||||
error->custom_message = TranslateTTDPatchCodes(message);
|
||||
error->custom_message = TranslateTTDPatchCodes(_cur_grffile->grfid, message);
|
||||
} else {
|
||||
error->message = msgstr[message_id];
|
||||
}
|
||||
@ -4043,7 +4043,7 @@ static void GRFLoadError(byte *buf, int len)
|
||||
const char *data = grf_load_string(&buf, len);
|
||||
len -= (strlen(data) + 1);
|
||||
|
||||
error->data = TranslateTTDPatchCodes(data);
|
||||
error->data = TranslateTTDPatchCodes(_cur_grffile->grfid, data);
|
||||
}
|
||||
|
||||
/* Only two parameter numbers can be used in the string. */
|
||||
@ -4558,7 +4558,7 @@ static void FeatureTownName(byte *buf, int len)
|
||||
if (!check_length(len, 1, "FeatureTownName: style name")) return;
|
||||
const char *name = grf_load_string(&buf, len);
|
||||
len -= strlen(name) + 1;
|
||||
grfmsg(6, "FeatureTownName: lang 0x%X -> '%s'", lang, TranslateTTDPatchCodes(name));
|
||||
grfmsg(6, "FeatureTownName: lang 0x%X -> '%s'", lang, TranslateTTDPatchCodes(grfid, name));
|
||||
|
||||
townname->name[nb_gen] = AddGRFString(grfid, id, lang, new_scheme, name, STR_UNDEFINED);
|
||||
|
||||
@ -4611,7 +4611,7 @@ static void FeatureTownName(byte *buf, int len)
|
||||
} else {
|
||||
const char *text = grf_load_string(&buf, len);
|
||||
len -= strlen(text) + 1;
|
||||
townname->partlist[id][i].parts[j].data.text = TranslateTTDPatchCodes(text);
|
||||
townname->partlist[id][i].parts[j].data.text = TranslateTTDPatchCodes(grfid, text);
|
||||
grfmsg(6, "FeatureTownName: part %d, text %d, '%s' (with probability %d)", i, j, townname->partlist[id][i].parts[j].data.text, prob);
|
||||
}
|
||||
townname->partlist[id][i].parts[j].prob = prob;
|
||||
|
@ -128,4 +128,6 @@ void CDECL grfmsg(int severity, const char *str, ...);
|
||||
bool HasGrfMiscBit(GrfMiscBit bit);
|
||||
bool GetGlobalVariable(byte param, uint32 *value);
|
||||
|
||||
StringID MapGRFStringID(uint32 grfid, StringID str);
|
||||
|
||||
#endif /* NEWGRF_H */
|
||||
|
@ -192,7 +192,7 @@ static GRFTextEntry _grf_text[(1 << TABSIZE) * 3];
|
||||
static byte _currentLangID = GRFLX_ENGLISH; ///< by default, english is used.
|
||||
|
||||
|
||||
char *TranslateTTDPatchCodes(const char *str)
|
||||
char *TranslateTTDPatchCodes(uint32 grfid, const char *str)
|
||||
{
|
||||
char *tmp = MallocT<char>(strlen(str) * 10 + 1); // Allocate space to allow for expansion
|
||||
char *d = tmp;
|
||||
@ -241,7 +241,7 @@ char *TranslateTTDPatchCodes(const char *str)
|
||||
string = *str++;
|
||||
string |= *str++ << 8;
|
||||
d += Utf8Encode(d, SCC_STRING_ID);
|
||||
d += Utf8Encode(d, string);
|
||||
d += Utf8Encode(d, MapGRFStringID(grfid, string));
|
||||
break;
|
||||
}
|
||||
case 0x82:
|
||||
@ -345,7 +345,7 @@ StringID AddGRFString(uint32 grfid, uint16 stringid, byte langid_to_add, bool ne
|
||||
/* Too many strings allocated, return empty */
|
||||
if (id == lengthof(_grf_text)) return STR_EMPTY;
|
||||
|
||||
translatedtext = TranslateTTDPatchCodes(text_to_add);
|
||||
translatedtext = TranslateTTDPatchCodes(grfid, text_to_add);
|
||||
|
||||
GRFText *newtext = GRFText::New(langid_to_add, translatedtext);
|
||||
|
||||
|
@ -11,7 +11,7 @@ StringID GetGRFStringID(uint32 grfid, uint16 stringid);
|
||||
const char *GetGRFStringPtr(uint16 stringid);
|
||||
void CleanUpStrings();
|
||||
void SetCurrentGrfLangID(const char *iso_name);
|
||||
char *TranslateTTDPatchCodes(const char *str);
|
||||
char *TranslateTTDPatchCodes(uint32 grfid, const char *str);
|
||||
|
||||
bool CheckGrfLangID(byte lang_id, byte grf_version);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user