summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2010-12-09 21:01:50 +0000
committeryexo <yexo@openttd.org>2010-12-09 21:01:50 +0000
commit74d608a67efdd510de27a5fc0ca656be4b4fd024 (patch)
tree30e108a796ffc14c0a76f137e6bda1501e0efffd /src
parent475ac872c938a2ca4edd33d7992462e44695e363 (diff)
downloadopenttd-74d608a67efdd510de27a5fc0ca656be4b4fd024.tar.xz
(svn r21445) -Fix: [NewGRF] fix gender choice lists in newgrf strings.
Change: strgen no longer writes the type of a string for a gender choice list
Diffstat (limited to 'src')
-rw-r--r--src/strgen/strgen.cpp1
-rw-r--r--src/strings.cpp45
2 files changed, 22 insertions, 24 deletions
diff --git a/src/strgen/strgen.cpp b/src/strgen/strgen.cpp
index 21f3683bb..61f731cb0 100644
--- a/src/strgen/strgen.cpp
+++ b/src/strgen/strgen.cpp
@@ -398,7 +398,6 @@ static void EmitGender(char *buf, int value)
assert(IsInsideBS(cmd->value, SCC_CONTROL_START, UINT8_MAX));
PutUtf8(SCC_GENDER_LIST);
- PutByte(cmd->value - SCC_CONTROL_START);
PutByte(TranslateArgumentIdx(argidx, offset));
EmitWordList(words, nw);
}
diff --git a/src/strings.cpp b/src/strings.cpp
index 35e266d01..5e66b5a59 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -792,32 +792,31 @@ static char *FormatString(char *buff, const char *str, int64 *argv, const int64
case SCC_GENDER_LIST: { // {G 0 Der Die Das}
/* First read the meta data from the language file. */
- WChar fmt = SCC_CONTROL_START + (byte)*str++;
byte offset = (byte)*str++;
assert(argv_orig + offset < argve);
- assert(dry_run || argt == NULL || argt_orig[offset] == fmt);
-
- /* Now we need to figure out what text to resolve, i.e.
- * what do we need to draw? So get the actual raw string
- * first using the control code to get said string. */
- char input[4 + 1];
- char *p = input + Utf8Encode(input, fmt);
- *p = '\0';
-
- /* Now do the string formatting. */
- char buf[256];
- bool old_kgd = _keep_gender_data;
- _keep_gender_data = true;
- p = FormatString(buf, input, argv_orig + offset, argve, 0, lastof(buf));
- _keep_gender_data = old_kgd;
- *p = '\0';
-
- /* And determine the string. */
int gender = 0;
- const char *s = buf;
- WChar c = Utf8Consume(&s);
- /* Does this string have a gender, if so, set it */
- if (c == SCC_GENDER_INDEX) gender = (byte)s[0];
+ if (!dry_run && argt != NULL && argt_orig[offset] != 0) {
+ /* Now we need to figure out what text to resolve, i.e.
+ * what do we need to draw? So get the actual raw string
+ * first using the control code to get said string. */
+ char input[4 + 1];
+ char *p = input + Utf8Encode(input, argt_orig[offset]);
+ *p = '\0';
+
+ /* Now do the string formatting. */
+ char buf[256];
+ bool old_kgd = _keep_gender_data;
+ _keep_gender_data = true;
+ p = FormatString(buf, input, argv_orig + offset, argve, 0, lastof(buf));
+ _keep_gender_data = old_kgd;
+ *p = '\0';
+
+ /* And determine the string. */
+ const char *s = buf;
+ WChar c = Utf8Consume(&s);
+ /* Does this string have a gender, if so, set it */
+ if (c == SCC_GENDER_INDEX) gender = (byte)s[0];
+ }
str = ParseStringChoice(str, gender, &buff, last);
break;
}