summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/newgrf_text.cpp8
-rw-r--r--src/newgrf_text.h2
-rw-r--r--src/strings.cpp25
-rw-r--r--src/strings_func.h1
4 files changed, 19 insertions, 17 deletions
diff --git a/src/newgrf_text.cpp b/src/newgrf_text.cpp
index 870ad5021..07d1c8323 100644
--- a/src/newgrf_text.cpp
+++ b/src/newgrf_text.cpp
@@ -405,7 +405,7 @@ StringID GetGRFStringID(uint32 grfid, uint16 stringid)
}
-char *GetGRFString(char *buff, uint16 stringid, const char* last)
+const char *GetGRFStringPtr(uint16 stringid)
{
const GRFText *default_text = NULL;
const GRFText *search_text;
@@ -418,7 +418,7 @@ char *GetGRFString(char *buff, uint16 stringid, const char* last)
/*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) {
- return strecpy(buff, search_text->text, last);
+ return search_text->text;
}
/* If the current string is English or American, set it as the
@@ -429,10 +429,10 @@ char *GetGRFString(char *buff, uint16 stringid, const char* last)
}
/* If there is a fallback string, return that */
- if (default_text != NULL) return strecpy(buff, default_text->text, last);
+ if (default_text != NULL) return default_text->text;
/* Use the default string ID if the fallback string isn't available */
- return GetString(buff, _grf_text[stringid].def_string, last);
+ return GetStringPtr(_grf_text[stringid].def_string);
}
/**
diff --git a/src/newgrf_text.h b/src/newgrf_text.h
index 9f77036d8..033d927b9 100644
--- a/src/newgrf_text.h
+++ b/src/newgrf_text.h
@@ -8,7 +8,7 @@
StringID AddGRFString(uint32 grfid, uint16 stringid, byte langid, bool new_scheme, const char *text_to_add, StringID def_string);
StringID GetGRFStringID(uint32 grfid, uint16 stringid);
-char *GetGRFString(char *buff, uint16 stringid, const char* last);
+const char *GetGRFStringPtr(uint16 stringid);
void CleanUpStrings();
void SetCurrentGrfLangID(const char *iso_name);
char *TranslateTTDPatchCodes(const char *str);
diff --git a/src/strings.cpp b/src/strings.cpp
index 4eb19d77d..9338c99a4 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -104,9 +104,14 @@ static const char *_bound_strings[NUM_BOUND_STRINGS];
* the indices will be reused. */
static int _bind_index;
-static const char *GetStringPtr(StringID string)
+const char *GetStringPtr(StringID string)
{
- return _langpack_offs[_langtab_start[string >> 11] + (string & 0x7FF)];
+ switch (GB(string, 11, 5)) {
+ case 28: return GetGRFStringPtr(GB(string, 0, 11));
+ case 29: return GetGRFStringPtr(GB(string, 0, 11) + 0x0800);
+ case 30: return GetGRFStringPtr(GB(string, 0, 11) + 0x1000);
+ default: return _langpack_offs[_langtab_start[string >> 11] + (string & 0x7FF)];
+ }
}
/** The highest 8 bits of string contain the "case index".
@@ -125,7 +130,6 @@ static char *GetStringWithArgs(char *buffr, uint string, const int64 *argv, cons
uint index = GB(string, 0, 11);
uint tab = GB(string, 11, 5);
- char buff[512];
switch (tab) {
case 4:
@@ -139,7 +143,8 @@ static char *GetStringWithArgs(char *buffr, uint string, const int64 *argv, cons
break;
case 15:
- error("Boo!");
+ /* Old table for custom names. This is no longer used */
+ error("Incorrect conversion of custom name string.");
case 26:
/* Include string within newgrf text (format code 81) */
@@ -150,16 +155,13 @@ static char *GetStringWithArgs(char *buffr, uint string, const int64 *argv, cons
break;
case 28:
- GetGRFString(buff, index, lastof(buff));
- return FormatString(buffr, buff, argv, 0, last);
+ return FormatString(buffr, GetGRFStringPtr(index), argv, 0, last);
case 29:
- GetGRFString(buff, index + 0x800, lastof(buff));
- return FormatString(buffr, buff, argv, 0, last);
+ return FormatString(buffr, GetGRFStringPtr(index + 0x0800), argv, 0, last);
case 30:
- GetGRFString(buff, index + 0x1000, lastof(buff));
- return FormatString(buffr, buff, argv, 0, last);
+ return FormatString(buffr, GetGRFStringPtr(index + 0x1000), argv, 0, last);
case 31:
/* dynamic strings. These are NOT to be passed through the formatter,
@@ -695,8 +697,7 @@ static char* FormatString(char* buff, const char* str, const int64* argv, uint c
}
case SCC_GENDER_LIST: { // {G 0 Der Die Das}
- char buffr[512];
- const char *s = GetStringWithArgs(buffr, argv_orig[(byte)*str++], argv, last); // contains the string that determines gender.
+ const char *s = GetStringPtr(argv_orig[(byte)*str++]); // contains the string that determines gender.
int len;
int gender = 0;
if (s != NULL) {
diff --git a/src/strings_func.h b/src/strings_func.h
index 2b876038b..1a53a9b80 100644
--- a/src/strings_func.h
+++ b/src/strings_func.h
@@ -9,6 +9,7 @@
char *InlineString(char *buf, StringID string);
char *GetString(char *buffr, StringID string, const char *last);
+const char *GetStringPtr(StringID string);
extern char _userstring[128];