From 2a78d3efa9dabae2bbf41474fd868ee856be26b5 Mon Sep 17 00:00:00 2001 From: pasky Date: Sat, 5 Mar 2005 22:21:02 +0000 Subject: [PATCH] (svn r1930) Cleaned up the postfix-ending connecting code and introduced some simple postfix-last-letter transformations when the ending first letter is 'i'. --- namegen.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/namegen.c b/namegen.c index e0a01c2120..660d7dee28 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 {