(svn r12317) -Fix [FS#1815]: Map string IDs that are embedded from other strings.
authorpeter1138
Fri, 29 Feb 2008 08:48:01 +0000
changeset 8656 9731ddde8722
parent 8655 091434f42207
child 8657 e089730989d5
(svn r12317) -Fix [FS#1815]: Map string IDs that are embedded from other strings.
src/industry_cmd.cpp
src/newgrf.cpp
src/newgrf.h
src/newgrf_text.cpp
src/newgrf_text.h
--- a/src/industry_cmd.cpp	Fri Feb 29 08:40:49 2008 +0000
+++ b/src/industry_cmd.cpp	Fri Feb 29 08:48:01 2008 +0000
@@ -2019,7 +2019,6 @@
  */
 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);
--- a/src/newgrf.cpp	Fri Feb 29 08:40:49 2008 +0000
+++ b/src/newgrf.cpp	Fri Feb 29 08:48:01 2008 +0000
@@ -3859,12 +3859,12 @@
 
 	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 @@
 		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 @@
 		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 @@
 			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 @@
 			} 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;
--- a/src/newgrf.h	Fri Feb 29 08:40:49 2008 +0000
+++ b/src/newgrf.h	Fri Feb 29 08:48:01 2008 +0000
@@ -128,4 +128,6 @@
 bool HasGrfMiscBit(GrfMiscBit bit);
 bool GetGlobalVariable(byte param, uint32 *value);
 
+StringID MapGRFStringID(uint32 grfid, StringID str);
+
 #endif /* NEWGRF_H */
--- a/src/newgrf_text.cpp	Fri Feb 29 08:40:49 2008 +0000
+++ b/src/newgrf_text.cpp	Fri Feb 29 08:48:01 2008 +0000
@@ -192,7 +192,7 @@
 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 @@
 				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 @@
 	/* 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);
 
--- a/src/newgrf_text.h	Fri Feb 29 08:40:49 2008 +0000
+++ b/src/newgrf_text.h	Fri Feb 29 08:48:01 2008 +0000
@@ -11,7 +11,7 @@
 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);