changeset 3106:6a45efedde17 draft

(svn r3707) -Fix: made the generated Finnish town names sound more Finnish (ln-) note: <ln-> Bjarni: please go ahead and commit it, i'll take the responsibility if something should go wrong.
author bjarni <bjarni@openttd.org>
date Wed, 01 Mar 2006 19:20:35 +0000
parents b898e9399c98
children 8808dc10ecde
files namegen.c table/namegen.h
diffstat 2 files changed, 66 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/namegen.c
+++ b/namegen.c
@@ -279,9 +279,36 @@
 	// Select randomly if town name should consists of one or two parts.
 	if (SeedChance(0, 15, seed) >= 10) {
 		strcat(buf, name_finnish_real[SeedChance( 2, lengthof(name_finnish_real), seed)]);
-	} else {
-		strcat(buf, name_finnish_1[SeedChance( 2, lengthof(name_finnish_1), seed)]);
-		strcat(buf, name_finnish_2[SeedChance(10, lengthof(name_finnish_2), seed)]);
+	}
+	// A two-part name by combining one of name_finnish_1 + "la"/"lä"
+	// The reason for not having the contents of name_finnish_{1,2} in the same table is
+	// that the ones in name_finnish_2 are not good for this purpose.
+	else if (SeedChance(0, 15, seed) >= 5) {
+		uint sel = SeedChance( 0, lengthof(name_finnish_1), seed);
+		char *last;
+		strcat(buf, name_finnish_1[sel]);
+		last = &buf[strlen(buf)-1];
+		if (*last == 'i')
+			*last = 'e';
+		if (strstr(buf, "a") || strstr(buf, "o") || strstr(buf, "u") ||
+			strstr(buf, "A") || strstr(buf, "O") || strstr(buf, "U"))
+		{
+			strcat(buf, "la");
+		} else {
+			strcat(buf, "lä");
+		}
+	}
+	// A two-part name by combining one of name_finnish_{1,2} + name_finnish_3.
+	// Why aren't name_finnish_{1,2} just one table? See above.
+	else {
+		uint sel = SeedChance(2,
+			lengthof(name_finnish_1) + lengthof(name_finnish_2), seed);
+		if (sel >= lengthof(name_finnish_1)) {
+			strcat(buf, name_finnish_2[sel-lengthof(name_finnish_1)]);
+		} else {
+			strcat(buf, name_finnish_1[sel]);
+		}
+		strcat(buf, name_finnish_3[SeedChance(10, lengthof(name_finnish_3), seed)]);
 	}
 
 	return 0;
--- a/table/namegen.h
+++ b/table/namegen.h
@@ -1221,7 +1221,6 @@
 	"Loviisa",
 	"Kouvola",
 	"Tampere",
-	"Kokkola",
 	"Oulu",
 	"Salo",
 	"Malmi",
@@ -1233,39 +1232,61 @@
 	"Joensuu",
 	"Imatra",
 	"Tapanila",
-	"Pasila"
+	"Pasila",
+	"Turku",
+	"Kupittaa",
+	"Vaasa",
+	"Pori",
+	"Rauma",
+	"Kolari",
+	"Lieksa"
 };
 
 static const char *name_finnish_1[] = {
 	"Hiekka",
 	"Haapa",
 	"Mylly",
-	"Kivi",
-	"Lappeen",
-	"Lohjan",
-	"Savon",
 	"Sauna",
-	"Keri",
 	"Uusi",
 	"Vanha",
-	"Lapin",
 	"Kesä",
 	"Kuusi",
 	"Pelto",
 	"Tuomi",
-	"Pitäjän",
 	"Terva",
 	"Olki",
 	"Heinä",
-	"Kuusan",
 	"Seinä",
-	"Kemi",
 	"Rova",
-	"Martin",
-	"Koivu"
+	"Koivu",
+	"Kokko",
+	"Mänty",
+	"Pihlaja",
+	"Petäjä",
+	"Kielo",
+	"Kauha",
+	"Viita",
+	"Kivi",
+	"Riihi",
+	"Ääne",
+	"Niini"
 };
 
 static const char *name_finnish_2[] = {
+	"Lappeen",
+	"Lohjan",
+	"Savon",
+	"Lapin",
+	"Pitäjän",
+	"Martin",
+	"Kuusan",
+	"Kemi",
+	"Keri",
+	"Hämeen",
+	"Kangas"
+};
+
+static const char *name_finnish_3[] = {
 	"harju",
 	"linna",
 	"järvi",
@@ -1283,7 +1304,8 @@
 	"luoto",
 	"hovi",
 	"ranta",
-	"koski"
+	"koski",
+	"salo"
 };
 
 static const char *name_polish_1_m[] = {