summaryrefslogtreecommitdiff
path: root/src/strings.cpp
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2008-01-29 17:09:00 +0000
committerpeter1138 <peter1138@openttd.org>2008-01-29 17:09:00 +0000
commit3e017833b207f8c6e1ce58b7bbd13200d481407f (patch)
tree36668cb43b7188c31198678a500d50939212b8c1 /src/strings.cpp
parent9e7ad199b57ebd7103d83c4cfc6698cdcceda869 (diff)
downloadopenttd-3e017833b207f8c6e1ce58b7bbd13200d481407f.tar.xz
(svn r12015) -Fix [FS#1716] (Revert r11422): Patch in FS#1430 avoided instead of fixed the problem. GetStringWithArgs() discards information that SCC_GENDER_LIST needs to work. Now use pointers to retrieve GRF strings, so that GetStringPtr() will work correctly. This is advantageous as now no buffer copy is made when using all GRF strings.
Diffstat (limited to 'src/strings.cpp')
-rw-r--r--src/strings.cpp25
1 files changed, 13 insertions, 12 deletions
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) {