summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpasky <pasky@openttd.org>2005-03-05 22:21:02 +0000
committerpasky <pasky@openttd.org>2005-03-05 22:21:02 +0000
commit2a78d3efa9dabae2bbf41474fd868ee856be26b5 (patch)
tree298b742e0265d96e3412edc70b718a1951a01de4
parentd0f9cc27a3b1709ca0a6a8b466f87be8d6e5f8a7 (diff)
downloadopenttd-2a78d3efa9dabae2bbf41474fd868ee856be26b5.tar.xz
(svn r1930) Cleaned up the postfix-ending connecting code and introduced some simple postfix-last-letter transformations when the ending first letter is 'i'.
-rw-r--r--namegen.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/namegen.c b/namegen.c
index e0a01c212..660d7dee2 100644
--- a/namegen.c
+++ b/namegen.c
@@ -450,17 +450,30 @@ static byte MakeCzechTownName(char *buf, uint32 seed)
if (dynamic_subst) {
strcat(buf, name_czech_subst_stem[stem].name);
if (postfix < (int) lengthof(name_czech_subst_postfix)) {
+ const char *poststr = name_czech_subst_postfix[postfix];
+ const char *endstr = name_czech_subst_ending[ending].name;
int postlen, endlen;
- postlen = strlen(name_czech_subst_postfix[postfix]);
- endlen = strlen(name_czech_subst_ending[ending].name);
+ postlen = strlen(poststr);
+ endlen = strlen(endstr);
+ assert(postlen > 0 && endlen > 0);
+
// Kill the "avava" and "Jananna"-like cases
- if (2 > postlen || postlen > endlen
- || (name_czech_subst_postfix[postfix][1]
- != name_czech_subst_ending[ending].name[1]
- && name_czech_subst_postfix[postfix][2]
- != name_czech_subst_ending[ending].name[1]))
- strcat(buf, name_czech_subst_postfix[postfix]);
+ if (postlen < 2 || postlen > endlen
+ || ((poststr[1] != 'v' || poststr[1] != endstr[1])
+ && poststr[2] != endstr[1])) {
+ int buflen;
+ strcat(buf, poststr);
+ buflen = strlen(buf);
+
+ // k-i -> c-i, h-i -> z-i
+ if (endstr[0] == 'i') {
+ if (buf[buflen - 1] == 'k')
+ buf[buflen - 1] = 'c';
+ else if (buf[buflen - 1] == 'h')
+ buf[buflen - 1] = 'z';
+ }
+ }
}
strcat(buf, name_czech_subst_ending[ending].name);
} else {