2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2008-05-06 15:11:33 +00:00
|
|
|
/** @file namegen.cpp Town name generators. */
|
2007-03-21 03:06:21 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
#include "stdafx.h"
|
2008-03-28 09:15:08 +00:00
|
|
|
#include "namegen_func.h"
|
2008-01-07 14:23:25 +00:00
|
|
|
#include "string_func.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-01-13 01:21:35 +00:00
|
|
|
#include "table/namegen.h"
|
|
|
|
|
2005-01-12 22:10:50 +00:00
|
|
|
static inline uint32 SeedChance(int shift_by, int max, uint32 seed)
|
2004-12-31 14:43:47 +00:00
|
|
|
{
|
2005-10-03 21:20:01 +00:00
|
|
|
return (GB(seed, shift_by, 16) * max) >> 16;
|
2005-01-12 22:10:50 +00:00
|
|
|
}
|
|
|
|
|
2005-03-06 23:21:57 +00:00
|
|
|
static inline uint32 SeedModChance(int shift_by, int max, uint32 seed)
|
|
|
|
{
|
|
|
|
/* This actually gives *MUCH* more even distribution of the values
|
|
|
|
* than SeedChance(), which is absolutely horrible in that. If
|
|
|
|
* you do not believe me, try with i.e. the Czech town names,
|
|
|
|
* compare the words (nicely visible on prefixes) generated by
|
|
|
|
* SeedChance() and SeedModChance(). Do not get dicouraged by the
|
|
|
|
* never-use-modulo myths, which hold true only for the linear
|
|
|
|
* congruential generators (and Random() isn't such a generator).
|
|
|
|
* --pasky */
|
|
|
|
// TODO: Perhaps we should use it for all the name generators? --pasky
|
|
|
|
return (seed >> shift_by) % max;
|
|
|
|
}
|
|
|
|
|
2005-01-12 22:10:50 +00:00
|
|
|
static inline int32 SeedChanceBias(int shift_by, int max, uint32 seed, int bias)
|
|
|
|
{
|
|
|
|
return SeedChance(shift_by, max + bias, seed) - bias;
|
2004-12-31 14:43:47 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-01-23 13:09:35 +00:00
|
|
|
static void ReplaceWords(const char *org, const char *rep, char *buf)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2008-09-29 16:27:02 +00:00
|
|
|
if (strncmp(buf, org, 4) == 0) strncpy(buf, rep, 4); // Safe as the string in buf is always more than 4 characters long.
|
2004-12-31 14:43:47 +00:00
|
|
|
}
|
|
|
|
|
2006-10-22 10:08:49 +00:00
|
|
|
static byte MakeEnglishOriginalTownName(char *buf, uint32 seed, const char *last)
|
2004-12-31 14:43:47 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* null terminates the string for strcat */
|
2006-10-22 10:08:49 +00:00
|
|
|
strecpy(buf, "", last);
|
2004-12-31 14:43:47 +00:00
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* optional first segment */
|
2005-01-12 22:10:50 +00:00
|
|
|
i = SeedChanceBias(0, lengthof(name_original_english_1), seed, 50);
|
|
|
|
if (i >= 0)
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_original_english_1[i], last);
|
2004-12-31 14:43:47 +00:00
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* mandatory middle segments */
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_original_english_2[SeedChance(4, lengthof(name_original_english_2), seed)], last);
|
|
|
|
strecat(buf, name_original_english_3[SeedChance(7, lengthof(name_original_english_3), seed)], last);
|
|
|
|
strecat(buf, name_original_english_4[SeedChance(10, lengthof(name_original_english_4), seed)], last);
|
|
|
|
strecat(buf, name_original_english_5[SeedChance(13, lengthof(name_original_english_5), seed)], last);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* optional last segment */
|
2005-01-12 22:10:50 +00:00
|
|
|
i = SeedChanceBias(15, lengthof(name_original_english_6), seed, 60);
|
|
|
|
if (i >= 0)
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_original_english_6[i], last);
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-12-31 14:43:47 +00:00
|
|
|
if (buf[0] == 'C' && (buf[1] == 'e' || buf[1] == 'i'))
|
|
|
|
buf[0] = 'K';
|
|
|
|
|
2005-01-23 12:04:40 +00:00
|
|
|
ReplaceWords("Cunt", "East", buf);
|
|
|
|
ReplaceWords("Slag", "Pits", buf);
|
|
|
|
ReplaceWords("Slut", "Edin", buf);
|
|
|
|
//ReplaceWords("Fart", "Boot", buf);
|
|
|
|
ReplaceWords("Drar", "Quar", buf);
|
|
|
|
ReplaceWords("Dreh", "Bash", buf);
|
|
|
|
ReplaceWords("Frar", "Shor", buf);
|
|
|
|
ReplaceWords("Grar", "Aber", buf);
|
|
|
|
ReplaceWords("Brar", "Over", buf);
|
|
|
|
ReplaceWords("Wrar", "Inve", buf);
|
2004-12-31 14:43:47 +00:00
|
|
|
|
|
|
|
return 0;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2004-12-31 14:43:47 +00:00
|
|
|
|
2006-10-22 10:08:49 +00:00
|
|
|
static byte MakeEnglishAdditionalTownName(char *buf, uint32 seed, const char *last)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
int i;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* null terminates the string for strcat */
|
2006-10-22 10:08:49 +00:00
|
|
|
strecpy(buf, "", last);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* optional first segment */
|
2005-01-12 22:10:50 +00:00
|
|
|
i = SeedChanceBias(0, lengthof(name_additional_english_prefix), seed, 50);
|
|
|
|
if (i >= 0)
|
2007-04-18 22:10:36 +00:00
|
|
|
strecat(buf, name_additional_english_prefix[i], last);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-01-12 22:10:50 +00:00
|
|
|
if (SeedChance(3, 20, seed) >= 14) {
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_additional_english_1a[SeedChance(6, lengthof(name_additional_english_1a), seed)], last);
|
2005-01-12 21:33:43 +00:00
|
|
|
} else {
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_additional_english_1b1[SeedChance(6, lengthof(name_additional_english_1b1), seed)], last);
|
|
|
|
strecat(buf, name_additional_english_1b2[SeedChance(9, lengthof(name_additional_english_1b2), seed)], last);
|
2005-01-12 22:10:50 +00:00
|
|
|
if (SeedChance(11, 20, seed) >= 4) {
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_additional_english_1b3a[SeedChance(12, lengthof(name_additional_english_1b3a), seed)], last);
|
2005-01-12 21:33:43 +00:00
|
|
|
} else {
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_additional_english_1b3b[SeedChance(12, lengthof(name_additional_english_1b3b), seed)], last);
|
2004-12-31 14:43:47 +00:00
|
|
|
}
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_additional_english_2[SeedChance(14, lengthof(name_additional_english_2), seed)], last);
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* optional last segment */
|
2005-01-12 22:10:50 +00:00
|
|
|
i = SeedChanceBias(15, lengthof(name_additional_english_3), seed, 60);
|
|
|
|
if (i >= 0)
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_additional_english_3[i], last);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-01-23 12:04:40 +00:00
|
|
|
ReplaceWords("Cunt", "East", buf);
|
|
|
|
ReplaceWords("Slag", "Pits", buf);
|
|
|
|
ReplaceWords("Slut", "Edin", buf);
|
|
|
|
ReplaceWords("Fart", "Boot", buf);
|
|
|
|
ReplaceWords("Drar", "Quar", buf);
|
|
|
|
ReplaceWords("Dreh", "Bash", buf);
|
|
|
|
ReplaceWords("Frar", "Shor", buf);
|
|
|
|
ReplaceWords("Grar", "Aber", buf);
|
|
|
|
ReplaceWords("Brar", "Over", buf);
|
|
|
|
ReplaceWords("Wrar", "Stan", buf);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2004-12-31 14:43:47 +00:00
|
|
|
return 0;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2006-10-22 10:08:49 +00:00
|
|
|
static byte MakeAustrianTownName(char *buf, uint32 seed, const char *last)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2004-12-31 14:43:47 +00:00
|
|
|
int i, j = 0;
|
2006-10-22 10:08:49 +00:00
|
|
|
strecpy(buf, "", last);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* Bad, Maria, Gross, ... */
|
2005-01-12 22:10:50 +00:00
|
|
|
i = SeedChanceBias(0, lengthof(name_austrian_a1), seed, 15);
|
2006-10-22 10:08:49 +00:00
|
|
|
if (i >= 0) strecat(buf, name_austrian_a1[i], last);
|
2004-12-31 14:43:47 +00:00
|
|
|
|
2005-01-12 22:10:50 +00:00
|
|
|
i = SeedChance(4, 6, seed);
|
2005-01-12 21:33:43 +00:00
|
|
|
if (i >= 4) {
|
2007-03-21 03:06:21 +00:00
|
|
|
/* Kaisers-kirchen */
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_austrian_a2[SeedChance( 7, lengthof(name_austrian_a2), seed)], last);
|
|
|
|
strecat(buf, name_austrian_a3[SeedChance(13, lengthof(name_austrian_a3), seed)], last);
|
2005-01-12 21:33:43 +00:00
|
|
|
} else if (i >= 2) {
|
2007-03-21 03:06:21 +00:00
|
|
|
/* St. Johann */
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_austrian_a5[SeedChance( 7, lengthof(name_austrian_a5), seed)], last);
|
|
|
|
strecat(buf, name_austrian_a6[SeedChance( 9, lengthof(name_austrian_a6), seed)], last);
|
2004-12-31 14:43:47 +00:00
|
|
|
j = 1; // More likely to have a " an der " or " am "
|
2005-01-12 21:33:43 +00:00
|
|
|
} else {
|
2007-03-21 03:06:21 +00:00
|
|
|
/* Zell */
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_austrian_a4[SeedChance( 7, lengthof(name_austrian_a4), seed)], last);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2005-01-12 22:10:50 +00:00
|
|
|
i = SeedChance(1, 6, seed);
|
2005-01-12 21:33:43 +00:00
|
|
|
if (i >= 4 - j) {
|
2007-03-21 03:06:21 +00:00
|
|
|
/* an der Donau (rivers) */
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_austrian_f1[SeedChance(4, lengthof(name_austrian_f1), seed)], last);
|
|
|
|
strecat(buf, name_austrian_f2[SeedChance(5, lengthof(name_austrian_f2), seed)], last);
|
2005-01-12 21:33:43 +00:00
|
|
|
} else if (i >= 2 - j) {
|
2007-03-21 03:06:21 +00:00
|
|
|
/* am Dachstein (mountains) */
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_austrian_b1[SeedChance(4, lengthof(name_austrian_b1), seed)], last);
|
|
|
|
strecat(buf, name_austrian_b2[SeedChance(5, lengthof(name_austrian_b2), seed)], last);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-10-22 10:08:49 +00:00
|
|
|
static byte MakeGermanTownName(char *buf, uint32 seed, const char *last)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2005-01-12 21:11:26 +00:00
|
|
|
uint i;
|
|
|
|
uint seed_derivative;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* null terminates the string for strcat */
|
2006-10-22 10:08:49 +00:00
|
|
|
strecpy(buf, "", last);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-01-12 22:10:50 +00:00
|
|
|
seed_derivative = SeedChance(7, 28, seed);
|
2005-01-12 21:11:26 +00:00
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* optional prefix */
|
2005-01-12 21:11:26 +00:00
|
|
|
if (seed_derivative == 12 || seed_derivative == 19) {
|
2005-01-12 22:10:50 +00:00
|
|
|
i = SeedChance(2, lengthof(name_german_pre), seed);
|
2007-04-18 22:10:36 +00:00
|
|
|
strecat(buf, name_german_pre[i], last);
|
2004-08-10 14:42:52 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* mandatory middle segments including option of hardcoded name */
|
2005-03-05 14:54:11 +00:00
|
|
|
i = SeedChance(3, lengthof(name_german_real) + lengthof(name_german_1), seed);
|
|
|
|
if (i < lengthof(name_german_real)) {
|
2007-04-18 22:10:36 +00:00
|
|
|
strecat(buf, name_german_real[i], last);
|
2005-01-12 21:33:43 +00:00
|
|
|
} else {
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_german_1[i - lengthof(name_german_real)], last);
|
2005-01-12 21:11:26 +00:00
|
|
|
|
2005-01-12 22:10:50 +00:00
|
|
|
i = SeedChance(5, lengthof(name_german_2), seed);
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_german_2[i], last);
|
2004-08-10 14:42:52 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* optional suffix */
|
2005-01-12 21:11:26 +00:00
|
|
|
if (seed_derivative == 24) {
|
2005-01-12 22:10:50 +00:00
|
|
|
i = SeedChance(9,
|
2005-01-12 21:11:26 +00:00
|
|
|
lengthof(name_german_4_an_der) + lengthof(name_german_4_am), seed);
|
|
|
|
if (i < lengthof(name_german_4_an_der)) {
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_german_3_an_der[0], last);
|
|
|
|
strecat(buf, name_german_4_an_der[i], last);
|
2004-08-10 14:42:52 +00:00
|
|
|
} else {
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_german_3_am[0], last);
|
|
|
|
strecat(buf, name_german_4_am[i - lengthof(name_german_4_an_der)], last);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2004-12-31 14:43:47 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-10-22 10:08:49 +00:00
|
|
|
static byte MakeSpanishTownName(char *buf, uint32 seed, const char *last)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2006-10-22 10:08:49 +00:00
|
|
|
strecpy(buf, name_spanish_real[SeedChance(0, lengthof(name_spanish_real), seed)], last);
|
2004-09-10 19:02:27 +00:00
|
|
|
return 0;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2006-10-22 10:08:49 +00:00
|
|
|
static byte MakeFrenchTownName(char *buf, uint32 seed, const char *last)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2006-10-22 10:08:49 +00:00
|
|
|
strecpy(buf, name_french_real[SeedChance(0, lengthof(name_french_real), seed)], last);
|
2004-08-09 17:04:08 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-10-22 10:08:49 +00:00
|
|
|
static byte MakeSillyTownName(char *buf, uint32 seed, const char *last)
|
2004-09-10 19:02:27 +00:00
|
|
|
{
|
2006-10-22 10:08:49 +00:00
|
|
|
strecpy(buf, name_silly_1[SeedChance( 0, lengthof(name_silly_1), seed)], last);
|
|
|
|
strecat(buf, name_silly_2[SeedChance(16, lengthof(name_silly_2), seed)], last);
|
2004-08-09 17:04:08 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-10-22 10:08:49 +00:00
|
|
|
static byte MakeSwedishTownName(char *buf, uint32 seed, const char *last)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* null terminates the string for strcat */
|
2006-10-22 10:08:49 +00:00
|
|
|
strecpy(buf, "", last);
|
2004-12-31 14:43:47 +00:00
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* optional first segment */
|
2005-01-12 22:10:50 +00:00
|
|
|
i = SeedChanceBias(0, lengthof(name_swedish_1), seed, 50);
|
|
|
|
if (i >= 0)
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_swedish_1[i], last);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* mandatory middle segments including option of hardcoded name */
|
2005-01-12 22:10:50 +00:00
|
|
|
if (SeedChance(4, 5, seed) >= 3) {
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_swedish_2[SeedChance( 7, lengthof(name_swedish_2), seed)], last);
|
2005-01-12 21:33:43 +00:00
|
|
|
} else {
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_swedish_2a[SeedChance( 7, lengthof(name_swedish_2a), seed)], last);
|
|
|
|
strecat(buf, name_swedish_2b[SeedChance(10, lengthof(name_swedish_2b), seed)], last);
|
|
|
|
strecat(buf, name_swedish_2c[SeedChance(13, lengthof(name_swedish_2c), seed)], last);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_swedish_3[SeedChance(16, lengthof(name_swedish_3), seed)], last);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-10-22 10:08:49 +00:00
|
|
|
static byte MakeDutchTownName(char *buf, uint32 seed, const char *last)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* null terminates the string for strcat */
|
2006-10-22 10:08:49 +00:00
|
|
|
strecpy(buf, "", last);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* optional first segment */
|
2005-01-12 22:10:50 +00:00
|
|
|
i = SeedChanceBias(0, lengthof(name_dutch_1), seed, 50);
|
|
|
|
if (i >= 0)
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_dutch_1[i], last);
|
2004-12-31 14:43:47 +00:00
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* mandatory middle segments including option of hardcoded name */
|
2005-01-12 22:10:50 +00:00
|
|
|
if (SeedChance(6, 9, seed) > 4) {
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_dutch_2[SeedChance( 9, lengthof(name_dutch_2), seed)], last);
|
2005-01-12 21:33:43 +00:00
|
|
|
} else {
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_dutch_3[SeedChance( 9, lengthof(name_dutch_3), seed)], last);
|
|
|
|
strecat(buf, name_dutch_4[SeedChance(12, lengthof(name_dutch_4), seed)], last);
|
2004-12-31 14:43:47 +00:00
|
|
|
}
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_dutch_5[SeedChance(15, lengthof(name_dutch_5), seed)], last);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-10-22 10:08:49 +00:00
|
|
|
static byte MakeFinnishTownName(char *buf, uint32 seed, const char *last)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2007-03-21 03:06:21 +00:00
|
|
|
/* null terminates the string for strcat */
|
2006-10-22 10:08:49 +00:00
|
|
|
strecpy(buf, "", last);
|
2004-12-31 14:43:47 +00:00
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* Select randomly if town name should consists of one or two parts. */
|
2005-01-12 22:10:50 +00:00
|
|
|
if (SeedChance(0, 15, seed) >= 10) {
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_finnish_real[SeedChance(2, lengthof(name_finnish_real), seed)], last);
|
2006-06-27 21:25:53 +00:00
|
|
|
} else if (SeedChance(0, 15, seed) >= 5) {
|
2007-04-15 22:30:26 +00:00
|
|
|
/* A two-part name by combining one of name_finnish_1 + "la"/"lä"
|
2007-03-21 03:06:21 +00:00
|
|
|
* 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. */
|
2006-03-01 19:20:35 +00:00
|
|
|
uint sel = SeedChance( 0, lengthof(name_finnish_1), seed);
|
2006-10-22 10:08:49 +00:00
|
|
|
char *end;
|
|
|
|
strecat(buf, name_finnish_1[sel], last);
|
|
|
|
end = &buf[strlen(buf)-1];
|
|
|
|
if (*end == 'i')
|
|
|
|
*end = 'e';
|
2006-03-01 19:20:35 +00:00
|
|
|
if (strstr(buf, "a") || strstr(buf, "o") || strstr(buf, "u") ||
|
|
|
|
strstr(buf, "A") || strstr(buf, "O") || strstr(buf, "U"))
|
|
|
|
{
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, "la", last);
|
2006-03-01 19:20:35 +00:00
|
|
|
} else {
|
2007-04-15 22:30:26 +00:00
|
|
|
strecat(buf, "lä", last);
|
2006-03-01 19:20:35 +00:00
|
|
|
}
|
2006-06-27 21:25:53 +00:00
|
|
|
} else {
|
2007-03-21 03:06:21 +00:00
|
|
|
/* 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. */
|
2006-03-01 19:20:35 +00:00
|
|
|
uint sel = SeedChance(2,
|
|
|
|
lengthof(name_finnish_1) + lengthof(name_finnish_2), seed);
|
|
|
|
if (sel >= lengthof(name_finnish_1)) {
|
2008-04-18 04:37:06 +00:00
|
|
|
strecat(buf, name_finnish_2[sel - lengthof(name_finnish_1)], last);
|
2006-03-01 19:20:35 +00:00
|
|
|
} else {
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_finnish_1[sel], last);
|
2006-03-01 19:20:35 +00:00
|
|
|
}
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_finnish_3[SeedChance(10, lengthof(name_finnish_3), seed)], last);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2004-12-31 14:43:47 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-10-22 10:08:49 +00:00
|
|
|
static byte MakePolishTownName(char *buf, uint32 seed, const char *last)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2005-01-09 21:25:44 +00:00
|
|
|
uint i;
|
|
|
|
uint j;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* null terminates the string for strcat */
|
2006-10-22 10:08:49 +00:00
|
|
|
strecpy(buf, "", last);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* optional first segment */
|
2005-01-12 22:10:50 +00:00
|
|
|
i = SeedChance(0,
|
2005-01-12 21:33:43 +00:00
|
|
|
lengthof(name_polish_2_o) + lengthof(name_polish_2_m) +
|
|
|
|
lengthof(name_polish_2_f) + lengthof(name_polish_2_n),
|
|
|
|
seed);
|
2005-01-12 22:10:50 +00:00
|
|
|
j = SeedChance(2, 20, seed);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
|
2005-01-12 21:33:43 +00:00
|
|
|
if (i < lengthof(name_polish_2_o)) {
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_polish_2_o[SeedChance(3, lengthof(name_polish_2_o), seed)], last);
|
2005-01-12 21:33:43 +00:00
|
|
|
} else if (i < lengthof(name_polish_2_m) + lengthof(name_polish_2_o)) {
|
2004-12-31 14:43:47 +00:00
|
|
|
if (j < 4)
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_polish_1_m[SeedChance(5, lengthof(name_polish_1_m), seed)], last);
|
2004-12-31 14:43:47 +00:00
|
|
|
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_polish_2_m[SeedChance(7, lengthof(name_polish_2_m), seed)], last);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2004-12-31 14:43:47 +00:00
|
|
|
if (j >= 4 && j < 16)
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_polish_3_m[SeedChance(10, lengthof(name_polish_3_m), seed)], last);
|
2005-01-12 21:33:43 +00:00
|
|
|
} else if (i < lengthof(name_polish_2_f) + lengthof(name_polish_2_m) + lengthof(name_polish_2_o)) {
|
2004-12-31 14:43:47 +00:00
|
|
|
if (j < 4)
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_polish_1_f[SeedChance(5, lengthof(name_polish_1_f), seed)], last);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_polish_2_f[SeedChance(7, lengthof(name_polish_2_f), seed)], last);
|
2004-12-31 14:43:47 +00:00
|
|
|
|
|
|
|
if (j >= 4 && j < 16)
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_polish_3_f[SeedChance(10, lengthof(name_polish_3_f), seed)], last);
|
2005-01-12 21:33:43 +00:00
|
|
|
} else {
|
2004-12-31 14:43:47 +00:00
|
|
|
if (j < 4)
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_polish_1_n[SeedChance(5, lengthof(name_polish_1_n), seed)], last);
|
2004-12-31 14:43:47 +00:00
|
|
|
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_polish_2_n[SeedChance(7, lengthof(name_polish_2_n), seed)], last);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2004-12-31 14:43:47 +00:00
|
|
|
if (j >= 4 && j < 16)
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_polish_3_n[SeedChance(10, lengthof(name_polish_3_n), seed)], last);
|
2004-12-31 14:43:47 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-10-22 10:08:49 +00:00
|
|
|
static byte MakeCzechTownName(char *buf, uint32 seed, const char *last)
|
2004-08-23 21:40:01 +00:00
|
|
|
{
|
2005-03-05 21:00:13 +00:00
|
|
|
/* Probability of prefixes/suffixes */
|
|
|
|
/* 0..11 prefix, 12..13 prefix+suffix, 14..17 suffix, 18..31 nothing */
|
|
|
|
int prob_tails;
|
|
|
|
bool do_prefix, do_suffix, dynamic_subst;
|
|
|
|
/* IDs of the respective parts */
|
2005-03-09 19:42:37 +00:00
|
|
|
int prefix = 0, ending = 0, suffix = 0;
|
|
|
|
uint postfix = 0;
|
|
|
|
uint stem;
|
2005-03-05 21:00:13 +00:00
|
|
|
/* The select criteria. */
|
2005-03-09 19:42:37 +00:00
|
|
|
CzechGender gender;
|
|
|
|
CzechChoose choose;
|
|
|
|
CzechAllow allow;
|
2005-03-05 21:00:13 +00:00
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* 1:3 chance to use a real name. */
|
2005-03-06 23:21:57 +00:00
|
|
|
if (SeedModChance(0, 4, seed) == 0) {
|
2006-10-22 10:08:49 +00:00
|
|
|
strecpy(buf, name_czech_real[SeedModChance(4, lengthof(name_czech_real), seed)], last);
|
2005-03-05 21:00:13 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* NUL terminates the string for strcat() */
|
2006-10-22 10:08:49 +00:00
|
|
|
strecpy(buf, "", last);
|
2005-03-05 21:00:13 +00:00
|
|
|
|
2005-03-06 23:21:57 +00:00
|
|
|
prob_tails = SeedModChance(2, 32, seed);
|
2005-03-05 21:00:13 +00:00
|
|
|
do_prefix = prob_tails < 12;
|
|
|
|
do_suffix = prob_tails > 11 && prob_tails < 17;
|
|
|
|
|
2005-03-06 23:21:57 +00:00
|
|
|
if (do_prefix) prefix = SeedModChance(5, lengthof(name_czech_adj) * 12, seed) / 12;
|
|
|
|
if (do_suffix) suffix = SeedModChance(7, lengthof(name_czech_suffix), seed);
|
2007-03-21 03:06:21 +00:00
|
|
|
/* 3:1 chance 3:1 to use dynamic substantive */
|
2005-03-09 19:42:37 +00:00
|
|
|
stem = SeedModChance(9,
|
|
|
|
lengthof(name_czech_subst_full) + 3 * lengthof(name_czech_subst_stem),
|
|
|
|
seed);
|
|
|
|
if (stem < lengthof(name_czech_subst_full)) {
|
2007-03-21 03:06:21 +00:00
|
|
|
/* That was easy! */
|
2005-03-05 21:00:13 +00:00
|
|
|
dynamic_subst = false;
|
|
|
|
gender = name_czech_subst_full[stem].gender;
|
|
|
|
choose = name_czech_subst_full[stem].choose;
|
|
|
|
allow = name_czech_subst_full[stem].allow;
|
|
|
|
} else {
|
|
|
|
unsigned int map[lengthof(name_czech_subst_ending)];
|
|
|
|
int ending_start = -1, ending_stop = -1;
|
|
|
|
int i;
|
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* Load the substantive */
|
2005-03-05 21:00:13 +00:00
|
|
|
dynamic_subst = true;
|
|
|
|
stem -= lengthof(name_czech_subst_full);
|
|
|
|
stem %= lengthof(name_czech_subst_stem);
|
|
|
|
gender = name_czech_subst_stem[stem].gender;
|
|
|
|
choose = name_czech_subst_stem[stem].choose;
|
|
|
|
allow = name_czech_subst_stem[stem].allow;
|
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* Load the postfix (1:1 chance that a postfix will be inserted) */
|
2005-03-06 23:21:57 +00:00
|
|
|
postfix = SeedModChance(14, lengthof(name_czech_subst_postfix) * 2, seed);
|
2005-03-05 21:00:13 +00:00
|
|
|
|
|
|
|
if (choose & CZC_POSTFIX) {
|
2007-03-21 03:06:21 +00:00
|
|
|
/* Always get a real postfix. */
|
2005-03-05 21:00:13 +00:00
|
|
|
postfix %= lengthof(name_czech_subst_postfix);
|
|
|
|
}
|
|
|
|
if (choose & CZC_NOPOSTFIX) {
|
2007-03-21 03:06:21 +00:00
|
|
|
/* Always drop a postfix. */
|
2005-03-05 21:00:13 +00:00
|
|
|
postfix += lengthof(name_czech_subst_postfix);
|
|
|
|
}
|
2006-06-27 21:25:53 +00:00
|
|
|
if (postfix < lengthof(name_czech_subst_postfix)) {
|
2005-03-05 21:00:13 +00:00
|
|
|
choose |= CZC_POSTFIX;
|
2006-06-27 21:25:53 +00:00
|
|
|
} else {
|
2005-03-05 21:00:13 +00:00
|
|
|
choose |= CZC_NOPOSTFIX;
|
2006-06-27 21:25:53 +00:00
|
|
|
}
|
2005-03-05 21:00:13 +00:00
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* Localize the array segment containing a good gender */
|
2005-03-05 21:00:13 +00:00
|
|
|
for (ending = 0; ending < (int) lengthof(name_czech_subst_ending); ending++) {
|
2005-03-09 19:42:37 +00:00
|
|
|
const CzechNameSubst *e = &name_czech_subst_ending[ending];
|
2005-03-05 21:00:13 +00:00
|
|
|
|
2005-03-09 19:42:37 +00:00
|
|
|
if (gender == CZG_FREE ||
|
|
|
|
(gender == CZG_NFREE && e->gender != CZG_SNEUT && e->gender != CZG_PNEUT) ||
|
|
|
|
gender == e->gender) {
|
2005-03-05 21:00:13 +00:00
|
|
|
if (ending_start < 0)
|
|
|
|
ending_start = ending;
|
|
|
|
|
|
|
|
} else if (ending_start >= 0) {
|
|
|
|
ending_stop = ending - 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ending_stop < 0) {
|
2007-03-21 03:06:21 +00:00
|
|
|
/* Whoa. All the endings matched. */
|
2005-03-05 21:00:13 +00:00
|
|
|
ending_stop = ending - 1;
|
|
|
|
}
|
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* Make a sequential map of the items with good mask */
|
2005-03-05 21:00:13 +00:00
|
|
|
i = 0;
|
|
|
|
for (ending = ending_start; ending <= ending_stop; ending++) {
|
2005-03-09 19:42:37 +00:00
|
|
|
const CzechNameSubst *e = &name_czech_subst_ending[ending];
|
2005-03-05 21:00:13 +00:00
|
|
|
|
|
|
|
if ((e->choose & choose) == choose && (e->allow & allow) != 0)
|
|
|
|
map[i++] = ending;
|
|
|
|
}
|
|
|
|
assert(i > 0);
|
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* Load the ending */
|
2005-03-06 23:21:57 +00:00
|
|
|
ending = map[SeedModChance(16, i, seed)];
|
2007-03-21 03:06:21 +00:00
|
|
|
/* Override possible CZG_*FREE; this must be a real gender,
|
|
|
|
* otherwise we get overflow when modifying the adjectivum. */
|
2005-03-05 21:00:13 +00:00
|
|
|
gender = name_czech_subst_ending[ending].gender;
|
|
|
|
assert(gender != CZG_FREE && gender != CZG_NFREE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (do_prefix && (name_czech_adj[prefix].choose & choose) != choose) {
|
2007-03-21 03:06:21 +00:00
|
|
|
/* Throw away non-matching prefix. */
|
2005-03-05 21:00:13 +00:00
|
|
|
do_prefix = false;
|
|
|
|
}
|
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* Now finally construct the name */
|
2005-03-05 21:00:13 +00:00
|
|
|
|
|
|
|
if (do_prefix) {
|
2005-03-09 19:42:37 +00:00
|
|
|
CzechPattern pattern = name_czech_adj[prefix].pattern;
|
2006-08-20 12:09:32 +00:00
|
|
|
size_t endpos;
|
2005-03-05 21:00:13 +00:00
|
|
|
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_czech_adj[prefix].name, last);
|
2005-03-05 21:00:13 +00:00
|
|
|
endpos = strlen(buf) - 1;
|
2006-11-16 22:05:33 +00:00
|
|
|
/* Find the first character in a UTF-8 sequence */
|
|
|
|
while (GB(buf[endpos], 6, 2) == 2) endpos--;
|
2005-03-05 21:00:13 +00:00
|
|
|
if (gender == CZG_SMASC && pattern == CZP_PRIVL) {
|
|
|
|
/* -ovX -> -uv */
|
|
|
|
buf[endpos - 2] = 'u';
|
|
|
|
assert(buf[endpos - 1] == 'v');
|
|
|
|
buf[endpos] = '\0';
|
|
|
|
} else {
|
2006-11-16 22:05:33 +00:00
|
|
|
strecpy(buf + endpos, name_czech_patmod[gender][pattern], last);
|
2005-03-05 21:00:13 +00:00
|
|
|
}
|
|
|
|
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, " ", last);
|
2005-03-05 21:00:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (dynamic_subst) {
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_czech_subst_stem[stem].name, last);
|
2005-03-09 19:42:37 +00:00
|
|
|
if (postfix < lengthof(name_czech_subst_postfix)) {
|
2005-03-05 22:21:02 +00:00
|
|
|
const char *poststr = name_czech_subst_postfix[postfix];
|
|
|
|
const char *endstr = name_czech_subst_ending[ending].name;
|
2006-08-20 12:09:32 +00:00
|
|
|
size_t postlen, endlen;
|
2005-03-05 21:00:13 +00:00
|
|
|
|
2005-03-05 22:21:02 +00:00
|
|
|
postlen = strlen(poststr);
|
|
|
|
endlen = strlen(endstr);
|
|
|
|
assert(postlen > 0 && endlen > 0);
|
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* Kill the "avava" and "Jananna"-like cases */
|
2005-03-09 19:42:37 +00:00
|
|
|
if (postlen < 2 || postlen > endlen || (
|
|
|
|
(poststr[1] != 'v' || poststr[1] != endstr[1]) &&
|
|
|
|
poststr[2] != endstr[1])
|
|
|
|
) {
|
2006-08-20 12:09:32 +00:00
|
|
|
size_t buflen;
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, poststr, last);
|
2005-03-05 22:21:02 +00:00
|
|
|
buflen = strlen(buf);
|
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* k-i -> c-i, h-i -> z-i */
|
2005-03-05 22:21:02 +00:00
|
|
|
if (endstr[0] == 'i') {
|
2005-03-09 19:42:37 +00:00
|
|
|
switch (buf[buflen - 1]) {
|
|
|
|
case 'k': buf[buflen - 1] = 'c'; break;
|
|
|
|
case 'h': buf[buflen - 1] = 'z'; break;
|
|
|
|
default: break;
|
|
|
|
}
|
2005-03-05 22:21:02 +00:00
|
|
|
}
|
|
|
|
}
|
2005-03-05 21:00:13 +00:00
|
|
|
}
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_czech_subst_ending[ending].name, last);
|
2005-03-05 21:00:13 +00:00
|
|
|
} else {
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_czech_subst_full[stem].name, last);
|
2005-03-05 21:00:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (do_suffix) {
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, " ", last);
|
|
|
|
strecat(buf, name_czech_suffix[suffix], last);
|
2005-03-05 21:00:13 +00:00
|
|
|
}
|
|
|
|
|
2004-09-10 19:02:27 +00:00
|
|
|
return 0;
|
2004-08-23 21:40:01 +00:00
|
|
|
}
|
|
|
|
|
2006-10-22 10:08:49 +00:00
|
|
|
static byte MakeRomanianTownName(char *buf, uint32 seed, const char *last)
|
2004-09-13 12:28:11 +00:00
|
|
|
{
|
2006-10-22 10:08:49 +00:00
|
|
|
strecpy(buf, name_romanian_real[SeedChance(0, lengthof(name_romanian_real), seed)], last);
|
2004-12-31 14:43:47 +00:00
|
|
|
return 0;
|
2004-09-13 12:28:11 +00:00
|
|
|
}
|
2004-09-13 23:43:54 +00:00
|
|
|
|
2006-10-22 10:08:49 +00:00
|
|
|
static byte MakeSlovakTownName(char *buf, uint32 seed, const char *last)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2006-10-22 10:08:49 +00:00
|
|
|
strecpy(buf, name_slovak_real[SeedChance(0, lengthof(name_slovak_real), seed)], last);
|
2004-09-10 19:02:27 +00:00
|
|
|
return 0;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2006-10-22 10:08:49 +00:00
|
|
|
static byte MakeNorwegianTownName(char *buf, uint32 seed, const char *last)
|
2005-01-09 00:17:01 +00:00
|
|
|
{
|
2006-10-22 10:08:49 +00:00
|
|
|
strecpy(buf, "", last);
|
2005-01-09 20:45:07 +00:00
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* Use first 4 bit from seed to decide whether or not this town should
|
|
|
|
* have a real name 3/16 chance. Bit 0-3 */
|
2005-01-12 22:10:50 +00:00
|
|
|
if (SeedChance(0, 15, seed) < 3) {
|
2007-03-21 03:06:21 +00:00
|
|
|
/* Use 7bit for the realname table index. Bit 4-10 */
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_norwegian_real[SeedChance(4, lengthof(name_norwegian_real), seed)], last);
|
2005-01-12 21:33:43 +00:00
|
|
|
} else {
|
2007-03-21 03:06:21 +00:00
|
|
|
/* Use 7bit for the first fake part. Bit 4-10 */
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_norwegian_1[SeedChance(4, lengthof(name_norwegian_1), seed)], last);
|
2007-03-21 03:06:21 +00:00
|
|
|
/* Use 7bit for the last fake part. Bit 11-17 */
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_norwegian_2[SeedChance(11, lengthof(name_norwegian_2), seed)], last);
|
2005-01-09 20:45:07 +00:00
|
|
|
}
|
|
|
|
|
2005-01-09 00:17:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-10-22 10:08:49 +00:00
|
|
|
static byte MakeHungarianTownName(char *buf, uint32 seed, const char *last)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2005-01-09 21:25:44 +00:00
|
|
|
uint i;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* null terminates the string for strcat */
|
2006-10-22 10:08:49 +00:00
|
|
|
strecpy(buf, "", last);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-01-12 22:10:50 +00:00
|
|
|
if (SeedChance(12, 15, seed) < 3) {
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_hungarian_real[SeedChance(0, lengthof(name_hungarian_real), seed)], last);
|
2005-01-12 21:33:43 +00:00
|
|
|
} else {
|
2007-03-21 03:06:21 +00:00
|
|
|
/* optional first segment */
|
2005-01-12 22:10:50 +00:00
|
|
|
i = SeedChance(3, lengthof(name_hungarian_1) * 3, seed);
|
2005-01-12 21:11:26 +00:00
|
|
|
if (i < lengthof(name_hungarian_1))
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_hungarian_1[i], last);
|
2004-12-31 14:43:47 +00:00
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* mandatory middle segments */
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_hungarian_2[SeedChance(3, lengthof(name_hungarian_2), seed)], last);
|
|
|
|
strecat(buf, name_hungarian_3[SeedChance(6, lengthof(name_hungarian_3), seed)], last);
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* optional last segment */
|
2005-01-12 22:10:50 +00:00
|
|
|
i = SeedChance(10, lengthof(name_hungarian_4) * 3, seed);
|
|
|
|
if (i < lengthof(name_hungarian_4)) {
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_hungarian_4[i], last);
|
2004-12-31 14:43:47 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2004-12-31 14:43:47 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-10-22 10:08:49 +00:00
|
|
|
static byte MakeSwissTownName(char *buf, uint32 seed, const char *last)
|
2005-01-15 21:41:49 +00:00
|
|
|
{
|
2006-10-22 10:08:49 +00:00
|
|
|
strecpy(buf, name_swiss_real[SeedChance(0, lengthof(name_swiss_real), seed)], last);
|
2005-01-15 21:41:49 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-10-22 10:08:49 +00:00
|
|
|
static byte MakeDanishTownName(char *buf, uint32 seed, const char *last)
|
2005-09-16 10:37:21 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* null terminates the string for strcat */
|
2006-10-22 10:08:49 +00:00
|
|
|
strecpy(buf, "", last);
|
2005-09-16 10:37:21 +00:00
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* optional first segment */
|
2005-09-16 10:37:21 +00:00
|
|
|
i = SeedChanceBias(0, lengthof(name_danish_1), seed, 50);
|
|
|
|
if (i >= 0)
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_danish_1[i], last);
|
2005-09-16 10:37:21 +00:00
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* middle segments removed as this algorithm seems to create much more realistic names */
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_danish_2[SeedChance( 7, lengthof(name_danish_2), seed)], last);
|
|
|
|
strecat(buf, name_danish_3[SeedChance(16, lengthof(name_danish_3), seed)], last);
|
2005-09-16 10:37:21 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-10-22 10:08:49 +00:00
|
|
|
static byte MakeTurkishTownName(char *buf, uint32 seed, const char *last)
|
2006-05-01 09:25:23 +00:00
|
|
|
{
|
|
|
|
uint i;
|
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* null terminates the string for strcat */
|
2006-10-22 10:08:49 +00:00
|
|
|
strecpy(buf, "", last);
|
2006-05-01 09:25:23 +00:00
|
|
|
|
|
|
|
if ((i = SeedModChance(0, 5, seed)) == 0) {
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_turkish_prefix[SeedModChance( 2, lengthof(name_turkish_prefix), seed)], last);
|
2006-05-01 09:25:23 +00:00
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* middle segment */
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_turkish_middle[SeedModChance( 4, lengthof(name_turkish_middle), seed)], last);
|
2006-05-01 09:25:23 +00:00
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* optional suffix */
|
2006-05-01 09:25:23 +00:00
|
|
|
if (SeedModChance(0, 7, seed) == 0) {
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_turkish_suffix[SeedModChance( 10, lengthof(name_turkish_suffix), seed)], last);
|
2006-05-01 09:25:23 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (i == 1 || i == 2) {
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_turkish_prefix[SeedModChance( 2, lengthof(name_turkish_prefix), seed)], last);
|
|
|
|
strecat(buf, name_turkish_suffix[SeedModChance( 4, lengthof(name_turkish_suffix), seed)], last);
|
2006-05-01 09:25:23 +00:00
|
|
|
} else {
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_turkish_real[SeedModChance( 4, lengthof(name_turkish_real), seed)], last);
|
2006-05-01 09:25:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-07-17 20:27:17 +00:00
|
|
|
static const char *mascul_femin_italian[] = {
|
|
|
|
"o",
|
|
|
|
"a",
|
|
|
|
};
|
|
|
|
|
2006-10-22 10:08:49 +00:00
|
|
|
static byte MakeItalianTownName(char *buf, uint32 seed, const char *last)
|
|
|
|
{
|
|
|
|
strecpy(buf, "", last);
|
2006-07-16 00:32:00 +00:00
|
|
|
|
2006-07-17 20:27:17 +00:00
|
|
|
if (SeedModChance(0, 6, seed) == 0) { // real city names
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_italian_real[SeedModChance(4, lengthof(name_italian_real), seed)], last);
|
2006-07-16 00:32:00 +00:00
|
|
|
} else {
|
2006-07-17 20:27:17 +00:00
|
|
|
uint i;
|
|
|
|
|
|
|
|
if (SeedModChance(0, 8, seed) == 0) { // prefix
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_italian_pref[SeedModChance(11, lengthof(name_italian_pref), seed)], last);
|
2006-07-16 00:32:00 +00:00
|
|
|
}
|
|
|
|
|
2006-07-17 20:27:17 +00:00
|
|
|
i = SeedChance(0, 2, seed);
|
2006-07-16 00:32:00 +00:00
|
|
|
if (i == 0) { // masculine form
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_italian_1m[SeedModChance(4, lengthof(name_italian_1m), seed)], last);
|
2006-07-17 20:27:17 +00:00
|
|
|
} else { // feminine form
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_italian_1f[SeedModChance(4, lengthof(name_italian_1f), seed)], last);
|
2006-07-16 00:32:00 +00:00
|
|
|
}
|
|
|
|
|
2006-07-17 20:27:17 +00:00
|
|
|
if (SeedModChance(3, 3, seed) == 0) {
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_italian_2[SeedModChance(11, lengthof(name_italian_2), seed)], last);
|
2007-04-18 22:10:36 +00:00
|
|
|
strecat(buf, mascul_femin_italian[i], last);
|
2006-07-16 00:32:00 +00:00
|
|
|
} else {
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_italian_2i[SeedModChance(16, lengthof(name_italian_2i), seed)], last);
|
2006-07-16 00:32:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (SeedModChance(15, 4, seed) == 0) {
|
2006-07-17 20:27:17 +00:00
|
|
|
if (SeedModChance(5, 2, seed) == 0) { // generic suffix
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_italian_3[SeedModChance(4, lengthof(name_italian_3), seed)], last);
|
2006-07-17 20:27:17 +00:00
|
|
|
} else { // river name suffix
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_italian_river1[SeedModChance(4, lengthof(name_italian_river1), seed)], last);
|
|
|
|
strecat(buf, name_italian_river2[SeedModChance(16, lengthof(name_italian_river2), seed)], last);
|
2006-07-16 00:32:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-10-22 10:08:49 +00:00
|
|
|
static byte MakeCatalanTownName(char *buf, uint32 seed, const char *last)
|
|
|
|
{
|
|
|
|
strecpy(buf, "", last);
|
2006-08-20 09:52:15 +00:00
|
|
|
|
|
|
|
if (SeedModChance(0, 3, seed) == 0) { // real city names
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_catalan_real[SeedModChance(4, lengthof(name_catalan_real), seed)], last);
|
2006-08-20 09:52:15 +00:00
|
|
|
} else {
|
|
|
|
uint i;
|
2006-08-29 14:45:39 +00:00
|
|
|
|
2006-08-20 09:52:15 +00:00
|
|
|
if (SeedModChance(0, 2, seed) == 0) { // prefix
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_catalan_pref[SeedModChance(11, lengthof(name_catalan_pref), seed)], last);
|
2006-08-20 09:52:15 +00:00
|
|
|
}
|
2006-08-29 14:45:39 +00:00
|
|
|
|
|
|
|
i = SeedChance(0, 2, seed);
|
|
|
|
if (i == 0) { // masculine form
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_catalan_1m[SeedModChance(4, lengthof(name_catalan_1m), seed)], last);
|
|
|
|
strecat(buf, name_catalan_2m[SeedModChance(11, lengthof(name_catalan_2m), seed)], last);
|
2006-08-29 14:45:39 +00:00
|
|
|
} else { // feminine form
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_catalan_1f[SeedModChance(4, lengthof(name_catalan_1f), seed)], last);
|
|
|
|
strecat(buf, name_catalan_2f[SeedModChance(11, lengthof(name_catalan_2f), seed)], last);
|
2006-08-29 14:45:39 +00:00
|
|
|
}
|
2006-08-20 09:52:15 +00:00
|
|
|
|
|
|
|
|
2006-08-29 14:45:39 +00:00
|
|
|
if (SeedModChance(15, 5, seed) == 0) {
|
|
|
|
if (SeedModChance(5, 2, seed) == 0) { // generic suffix
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_catalan_3[SeedModChance(4, lengthof(name_catalan_3), seed)], last);
|
2006-08-29 14:45:39 +00:00
|
|
|
} else { // river name suffix
|
2006-10-22 10:08:49 +00:00
|
|
|
strecat(buf, name_catalan_river1[SeedModChance(4, lengthof(name_catalan_river1), seed)], last);
|
2006-08-20 09:52:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-01-12 21:33:43 +00:00
|
|
|
TownNameGenerator * const _town_name_generators[] =
|
|
|
|
{
|
2004-12-31 14:43:47 +00:00
|
|
|
MakeEnglishOriginalTownName,
|
2004-08-09 17:04:08 +00:00
|
|
|
MakeFrenchTownName,
|
|
|
|
MakeGermanTownName,
|
2004-12-31 14:43:47 +00:00
|
|
|
MakeEnglishAdditionalTownName,
|
2004-08-09 17:04:08 +00:00
|
|
|
MakeSpanishTownName,
|
|
|
|
MakeSillyTownName,
|
|
|
|
MakeSwedishTownName,
|
|
|
|
MakeDutchTownName,
|
|
|
|
MakeFinnishTownName,
|
|
|
|
MakePolishTownName,
|
2004-11-15 12:11:43 +00:00
|
|
|
MakeSlovakTownName,
|
2005-01-09 00:17:01 +00:00
|
|
|
MakeNorwegianTownName,
|
2004-08-09 17:04:08 +00:00
|
|
|
MakeHungarianTownName,
|
2004-09-13 12:28:11 +00:00
|
|
|
MakeAustrianTownName,
|
2004-09-16 10:07:52 +00:00
|
|
|
MakeRomanianTownName,
|
|
|
|
MakeCzechTownName,
|
2005-01-15 21:41:49 +00:00
|
|
|
MakeSwissTownName,
|
2005-09-16 10:37:21 +00:00
|
|
|
MakeDanishTownName,
|
2006-05-01 09:25:23 +00:00
|
|
|
MakeTurkishTownName,
|
2006-07-16 00:32:00 +00:00
|
|
|
MakeItalianTownName,
|
2006-08-20 09:52:15 +00:00
|
|
|
MakeCatalanTownName,
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|