summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--newgrf_text.c10
-rw-r--r--strings.c18
2 files changed, 25 insertions, 3 deletions
diff --git a/newgrf_text.c b/newgrf_text.c
index 15a3a27ff..621e40325 100644
--- a/newgrf_text.c
+++ b/newgrf_text.c
@@ -257,6 +257,8 @@ StringID AddGRFString(uint32 grfid, uint16 stringid, byte langid_to_add, bool ne
return (GRFTAB << TABSIZE) + id;
}
+/* Used to remember the grfid that the last retrieved string came from */
+static uint32 _last_grfid = 0;
/**
* Returns the index for this stringid associated with its grfID
@@ -264,6 +266,10 @@ StringID AddGRFString(uint32 grfid, uint16 stringid, byte langid_to_add, bool ne
StringID GetGRFStringID(uint32 grfid, uint16 stringid)
{
uint id;
+
+ /* grfid is zero when we're being called via an include */
+ if (grfid == 0) grfid = _last_grfid;
+
for (id = 0; id < _num_grf_texts; id++) {
if (_grf_text[id].grfid == grfid && _grf_text[id].stringid == stringid) {
return (GRFTAB << TABSIZE) + id;
@@ -280,6 +286,10 @@ char *GetGRFString(char *buff, uint16 stringid)
const GRFText *search_text;
assert(_grf_text[stringid].grfid != 0);
+
+ /* Remember this grfid in case the string has included text */
+ _last_grfid = _grf_text[stringid].grfid;
+
/*Search the list of lang-strings of this stringid for current lang */
for (search_text = _grf_text[stringid].textholder; search_text != NULL; search_text = search_text->next) {
if (search_text->langid == _currentLangID) {
diff --git a/strings.c b/strings.c
index 67669a5e4..7166b28cf 100644
--- a/strings.c
+++ b/strings.c
@@ -172,6 +172,7 @@ static char *GetStringWithArgs(char *buffr, uint string, const int32 *argv)
{
uint index = GB(string, 0, 11);
uint tab = GB(string, 11, 5);
+ char buff[512];
if (GB(string, 0, 16) == 0) error("!invalid string id 0 in GetString");
@@ -190,14 +191,25 @@ static char *GetStringWithArgs(char *buffr, uint string, const int32 *argv)
case 15:
return GetName(index, buffr);
+ case 26:
+ /* Include string within newgrf text (format code 81) */
+ if (HASBIT(index, 10)) {
+ StringID string = GetGRFStringID(0, 0xD000 + GB(index, 0, 10));
+ return GetStringWithArgs(buffr, string, argv);
+ }
+ break;
+
case 28:
- return GetGRFString(buffr, index);
+ GetGRFString(buff, index);
+ return FormatString(buffr, buff, argv, 0);
case 29:
- return GetGRFString(buffr, index + 0x800);
+ GetGRFString(buff, index + 0x800);
+ return FormatString(buffr, buff, argv, 0);
case 30:
- return GetGRFString(buffr, index + 0x1000);
+ GetGRFString(buff, index + 0x1000);
+ return FormatString(buffr, buff, argv, 0);
case 31:
// dynamic strings. These are NOT to be passed through the formatter,