summaryrefslogtreecommitdiff
path: root/src/strings.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-08-05 14:08:38 +0000
committerrubidium <rubidium@openttd.org>2007-08-05 14:08:38 +0000
commitf6933e18701de289a439b658282549079d511b19 (patch)
tree654acd5f96b2843fc7ad3ee95a1151f095fd21fe /src/strings.cpp
parent8cea2059a5c32ce8ff284f37536ea3a9cbb30e53 (diff)
downloadopenttd-f6933e18701de289a439b658282549079d511b19.tar.xz
(svn r10792) -Fix [FS#1104]: when determining the gender of a string, do not assume that the gender is in the front of the string when there can be case switching code at that location.
Diffstat (limited to 'src/strings.cpp')
-rw-r--r--src/strings.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/strings.cpp b/src/strings.cpp
index 78df8facd..70e995ba2 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -680,7 +680,18 @@ static char* FormatString(char* buff, const char* str, const int64* argv, uint c
const char* s = GetStringPtr(argv_orig[(byte)*str++]); // contains the string that determines gender.
int len;
int gender = 0;
- if (s != NULL && Utf8Consume(&s) == SCC_GENDER_INDEX) gender = (byte)s[0];
+ if (s != NULL) {
+ wchar_t c = Utf8Consume(&s);
+ /* Switch case is always put before genders, so remove those bits */
+ if (c == SCC_SWITCH_CASE) {
+ /* Skip to the last (i.e. default) case */
+ for (uint num = (byte)*s++; num != 0; num--) s += 3 + (s[1] << 8) + s[2];
+
+ 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, &len);
buff += len;
break;