summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2008-02-29 08:48:01 +0000
committerpeter1138 <peter1138@openttd.org>2008-02-29 08:48:01 +0000
commite40b66861ce77839331b3ff5444a4c547ae32219 (patch)
tree064d47c27a7440a3e1a27e39cc72ef4a99b5dacd
parentb913a135c084aee083aa2df0927179655415bb7b (diff)
downloadopenttd-e40b66861ce77839331b3ff5444a4c547ae32219.tar.xz
(svn r12317) -Fix [FS#1815]: Map string IDs that are embedded from other strings.
-rw-r--r--src/industry_cmd.cpp1
-rw-r--r--src/newgrf.cpp12
-rw-r--r--src/newgrf.h2
-rw-r--r--src/newgrf_text.cpp6
-rw-r--r--src/newgrf_text.h2
5 files changed, 12 insertions, 11 deletions
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 3fcf766dc..7b8d840e9 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -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);
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index 430899490..46a8669e7 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -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;
diff --git a/src/newgrf.h b/src/newgrf.h
index 2f0028f4a..adf43921c 100644
--- a/src/newgrf.h
+++ b/src/newgrf.h
@@ -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 */
diff --git a/src/newgrf_text.cpp b/src/newgrf_text.cpp
index 07d1c8323..261610f46 100644
--- a/src/newgrf_text.cpp
+++ b/src/newgrf_text.cpp
@@ -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);
diff --git a/src/newgrf_text.h b/src/newgrf_text.h
index 033d927b9..e5f4f09ea 100644
--- a/src/newgrf_text.h
+++ b/src/newgrf_text.h
@@ -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);