2004-08-09 17:04:08 +00:00
|
|
|
#include "stdafx.h"
|
|
|
|
#include "ttd.h"
|
|
|
|
|
2004-12-31 14:43:47 +00:00
|
|
|
#include "table/namegen.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
|
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-01-12 22:10:50 +00:00
|
|
|
return ((uint16)(seed >> shift_by) * max) >> 16;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
2004-12-31 14:43:47 +00:00
|
|
|
static void ReplaceWords(byte a, byte b, byte c, byte d, byte e, byte f, byte g, byte h, byte *buf)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2005-01-12 21:33:43 +00:00
|
|
|
if (buf[0] == a && buf[1] == b && buf[2] == c && buf[3] == d) {
|
2004-12-31 14:43:47 +00:00
|
|
|
buf[0] = e;
|
|
|
|
buf[1] = f;
|
|
|
|
buf[2] = g;
|
|
|
|
buf[3] = h;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static byte MakeEnglishOriginalTownName(byte *buf, uint32 seed)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
//null terminates the string for strcat
|
|
|
|
strcpy(buf, "");
|
|
|
|
|
|
|
|
// optional first segment
|
2005-01-12 22:10:50 +00:00
|
|
|
i = SeedChanceBias(0, lengthof(name_original_english_1), seed, 50);
|
|
|
|
if (i >= 0)
|
2004-12-31 14:43:47 +00:00
|
|
|
strcat(buf,name_original_english_1[i]);
|
|
|
|
|
|
|
|
//mandatory middle segments
|
2005-01-12 22:10:50 +00:00
|
|
|
strcat(buf, name_original_english_2[SeedChance(4, lengthof(name_original_english_2), seed)]);
|
|
|
|
strcat(buf, name_original_english_3[SeedChance(7, lengthof(name_original_english_3), seed)]);
|
|
|
|
strcat(buf, name_original_english_4[SeedChance(10, lengthof(name_original_english_4), seed)]);
|
|
|
|
strcat(buf, name_original_english_5[SeedChance(13, lengthof(name_original_english_5), seed)]);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2004-12-31 14:43:47 +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)
|
2004-12-31 14:43:47 +00:00
|
|
|
strcat(buf, name_original_english_6[i]);
|
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';
|
|
|
|
|
|
|
|
ReplaceWords('C','u','n','t', 'E','a','s','t', buf);
|
|
|
|
ReplaceWords('S','l','a','g', 'P','i','t','s', buf);
|
|
|
|
ReplaceWords('S','l','u','t', 'E','d','i','n', buf);
|
2005-01-12 21:33:43 +00:00
|
|
|
//ReplaceWords('F','a','r','t', 'B','o','o','t', buf);
|
2004-12-31 14:43:47 +00:00
|
|
|
ReplaceWords('D','r','a','r', 'Q','u','a','r', buf);
|
|
|
|
ReplaceWords('D','r','e','h', 'B','a','s','h', buf);
|
|
|
|
ReplaceWords('F','r','a','r', 'S','h','o','r', buf);
|
|
|
|
ReplaceWords('G','r','a','r', 'A','b','e','r', buf);
|
|
|
|
ReplaceWords('B','r','a','r', 'O','v','e','r', buf);
|
|
|
|
ReplaceWords('W','r','a','r', 'I','n','v','e', buf);
|
|
|
|
|
|
|
|
return 0;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2004-12-31 14:43:47 +00:00
|
|
|
|
|
|
|
static byte MakeEnglishAdditionalTownName(byte *buf, uint32 seed)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
int i;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-12-31 14:43:47 +00:00
|
|
|
//null terminates the string for strcat
|
|
|
|
strcpy(buf, "");
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2004-12-31 14:43:47 +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)
|
2004-12-31 14:43:47 +00:00
|
|
|
strcat(buf,name_additional_english_prefix[i]);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-01-12 22:10:50 +00:00
|
|
|
if (SeedChance(3, 20, seed) >= 14) {
|
|
|
|
strcat(buf, name_additional_english_1a[SeedChance(6, lengthof(name_additional_english_1a), seed)]);
|
2005-01-12 21:33:43 +00:00
|
|
|
} else {
|
2005-01-12 22:10:50 +00:00
|
|
|
strcat(buf, name_additional_english_1b1[SeedChance(6, lengthof(name_additional_english_1b1), seed)]);
|
|
|
|
strcat(buf, name_additional_english_1b2[SeedChance(9, lengthof(name_additional_english_1b2), seed)]);
|
|
|
|
if (SeedChance(11, 20, seed) >= 4) {
|
|
|
|
strcat(buf, name_additional_english_1b3a[SeedChance(12, lengthof(name_additional_english_1b3a), seed)]);
|
2005-01-12 21:33:43 +00:00
|
|
|
} else {
|
2005-01-12 22:10:50 +00:00
|
|
|
strcat(buf, name_additional_english_1b3b[SeedChance(12, lengthof(name_additional_english_1b3b), seed)]);
|
2004-12-31 14:43:47 +00:00
|
|
|
}
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-01-12 22:10:50 +00:00
|
|
|
strcat(buf, name_additional_english_2[SeedChance(14, lengthof(name_additional_english_2), seed)]);
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-12-31 14:43:47 +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)
|
2004-12-31 14:43:47 +00:00
|
|
|
strcat(buf, name_additional_english_3[i]);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2004-12-31 14:43:47 +00:00
|
|
|
ReplaceWords('C','u','n','t', 'E','a','s','t', buf);
|
|
|
|
ReplaceWords('S','l','a','g', 'P','i','t','s', buf);
|
|
|
|
ReplaceWords('S','l','u','t', 'E','d','i','n', buf);
|
|
|
|
ReplaceWords('F','a','r','t', 'B','o','o','t', buf);
|
|
|
|
ReplaceWords('D','r','a','r', 'Q','u','a','r', buf);
|
|
|
|
ReplaceWords('D','r','e','h', 'B','a','s','h', buf);
|
|
|
|
ReplaceWords('F','r','a','r', 'S','h','o','r', buf);
|
|
|
|
ReplaceWords('G','r','a','r', 'A','b','e','r', buf);
|
|
|
|
ReplaceWords('B','r','a','r', 'O','v','e','r', buf);
|
|
|
|
ReplaceWords('W','r','a','r', 'S','t','a','n', 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
|
|
|
}
|
|
|
|
|
|
|
|
static byte MakeAustrianTownName(byte *buf, uint32 seed)
|
|
|
|
{
|
2004-12-31 14:43:47 +00:00
|
|
|
int i, j = 0;
|
|
|
|
strcpy(buf, "");
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
// Bad, Maria, Gross, ...
|
2005-01-12 22:10:50 +00:00
|
|
|
i = SeedChanceBias(0, lengthof(name_austrian_a1), seed, 15);
|
2004-12-31 14:43:47 +00:00
|
|
|
if (i >= 0) strcat(buf, name_austrian_a1[i]);
|
|
|
|
|
2005-01-12 22:10:50 +00:00
|
|
|
i = SeedChance(4, 6, seed);
|
2005-01-12 21:33:43 +00:00
|
|
|
if (i >= 4) {
|
2004-12-31 14:43:47 +00:00
|
|
|
// Kaisers-kirchen
|
2005-01-12 22:10:50 +00:00
|
|
|
strcat(buf, name_austrian_a2[SeedChance( 7, lengthof(name_austrian_a2), seed)]);
|
|
|
|
strcat(buf, name_austrian_a3[SeedChance(13, lengthof(name_austrian_a3), seed)]);
|
2005-01-12 21:33:43 +00:00
|
|
|
} else if (i >= 2) {
|
2004-12-31 14:43:47 +00:00
|
|
|
// St. Johann
|
2005-01-12 22:10:50 +00:00
|
|
|
strcat(buf, name_austrian_a5[SeedChance( 7, lengthof(name_austrian_a5), seed)]);
|
|
|
|
strcat(buf, name_austrian_a6[SeedChance( 9, lengthof(name_austrian_a6), seed)]);
|
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 {
|
2004-12-31 14:43:47 +00:00
|
|
|
// Zell
|
2005-01-12 22:10:50 +00:00
|
|
|
strcat(buf, name_austrian_a4[SeedChance( 7, lengthof(name_austrian_a4), seed)]);
|
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) {
|
2004-12-31 14:43:47 +00:00
|
|
|
// an der Donau (rivers)
|
2005-01-12 22:10:50 +00:00
|
|
|
strcat(buf, name_austrian_f1[SeedChance(4, lengthof(name_austrian_f1), seed)]);
|
|
|
|
strcat(buf, name_austrian_f2[SeedChance(5, lengthof(name_austrian_f2), seed)]);
|
2005-01-12 21:33:43 +00:00
|
|
|
} else if (i >= 2 - j) {
|
2004-12-31 14:43:47 +00:00
|
|
|
// am Dachstein (mountains)
|
2005-01-12 22:10:50 +00:00
|
|
|
strcat(buf, name_austrian_b1[SeedChance(4, lengthof(name_austrian_b1), seed)]);
|
|
|
|
strcat(buf, name_austrian_b2[SeedChance(5, lengthof(name_austrian_b2), seed)]);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static byte MakeGermanTownName(byte *buf, uint32 seed)
|
|
|
|
{
|
2005-01-12 21:11:26 +00:00
|
|
|
uint i;
|
|
|
|
uint seed_derivative;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-12-31 14:43:47 +00:00
|
|
|
//null terminates the string for strcat
|
|
|
|
strcpy(buf, "");
|
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
|
|
|
|
|
|
|
//optional prefix
|
|
|
|
if (seed_derivative == 12 || seed_derivative == 19) {
|
2005-01-12 22:10:50 +00:00
|
|
|
i = SeedChance(2, lengthof(name_german_pre), seed);
|
2004-12-31 14:43:47 +00:00
|
|
|
strcat(buf,name_german_pre[i]);
|
2004-08-10 14:42:52 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2004-12-31 14:43:47 +00:00
|
|
|
// mandatory middle segments including option of hardcoded name
|
2005-01-12 22:10:50 +00:00
|
|
|
i = SeedChance(3, lengthof(name_german_hardcoded) + lengthof(name_german_1), seed);
|
2005-01-12 21:11:26 +00:00
|
|
|
if (i < lengthof(name_german_hardcoded)) {
|
2004-12-31 14:43:47 +00:00
|
|
|
strcat(buf,name_german_hardcoded[i]);
|
2005-01-12 21:33:43 +00:00
|
|
|
} else {
|
2005-01-12 21:11:26 +00:00
|
|
|
strcat(buf, name_german_1[i - lengthof(name_german_hardcoded)]);
|
|
|
|
|
2005-01-12 22:10:50 +00:00
|
|
|
i = SeedChance(5, lengthof(name_german_2), seed);
|
2005-01-12 21:11:26 +00:00
|
|
|
strcat(buf, name_german_2[i]);
|
2004-08-10 14:42:52 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-01-12 21:11:26 +00:00
|
|
|
// optional suffix
|
|
|
|
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)) {
|
|
|
|
strcat(buf, name_german_3_an_der[0]);
|
|
|
|
strcat(buf, name_german_4_an_der[i]);
|
2004-08-10 14:42:52 +00:00
|
|
|
} else {
|
2005-01-12 21:11:26 +00:00
|
|
|
strcat(buf, name_german_3_am[0]);
|
|
|
|
strcat(buf, name_german_4_am[i - lengthof(name_german_4_an_der)]);
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static byte MakeSpanishTownName(byte *buf, uint32 seed)
|
|
|
|
{
|
2005-01-12 22:10:50 +00:00
|
|
|
strcpy(buf, name_spanish_1[SeedChance(0, lengthof(name_spanish_1), seed)]);
|
2004-09-10 19:02:27 +00:00
|
|
|
return 0;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static byte MakeFrenchTownName(byte *buf, uint32 seed)
|
|
|
|
{
|
2005-01-12 22:10:50 +00:00
|
|
|
strcpy(buf, name_french_1[SeedChance(0, lengthof(name_french_1), seed)]);
|
2004-08-09 17:04:08 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static byte MakeSillyTownName(byte *buf, uint32 seed)
|
2004-09-10 19:02:27 +00:00
|
|
|
{
|
2005-01-12 22:10:50 +00:00
|
|
|
strcpy(buf, name_silly_1[SeedChance( 0, lengthof(name_silly_1), seed)]);
|
|
|
|
strcat(buf, name_silly_2[SeedChance(16, lengthof(name_silly_2), seed)]);
|
2004-08-09 17:04:08 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static byte MakeSwedishTownName(byte *buf, uint32 seed)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2004-12-31 14:43:47 +00:00
|
|
|
//null terminates the string for strcat
|
|
|
|
strcpy(buf, "");
|
|
|
|
|
|
|
|
// optional first segment
|
2005-01-12 22:10:50 +00:00
|
|
|
i = SeedChanceBias(0, lengthof(name_swedish_1), seed, 50);
|
|
|
|
if (i >= 0)
|
2004-12-31 14:43:47 +00:00
|
|
|
strcat(buf, name_swedish_1[i]);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2004-12-31 14:43:47 +00:00
|
|
|
// mandatory middle segments including option of hardcoded name
|
2005-01-12 22:10:50 +00:00
|
|
|
if (SeedChance(4, 5, seed) >= 3) {
|
|
|
|
strcat(buf, name_swedish_2[SeedChance( 7, lengthof(name_swedish_2), seed)]);
|
2005-01-12 21:33:43 +00:00
|
|
|
} else {
|
2005-01-12 22:10:50 +00:00
|
|
|
strcat(buf, name_swedish_2a[SeedChance( 7, lengthof(name_swedish_2a), seed)]);
|
|
|
|
strcat(buf, name_swedish_2b[SeedChance(10, lengthof(name_swedish_2b), seed)]);
|
|
|
|
strcat(buf, name_swedish_2c[SeedChance(13, lengthof(name_swedish_2c), seed)]);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2005-01-12 22:10:50 +00:00
|
|
|
strcat(buf, name_swedish_3[SeedChance(16, lengthof(name_swedish_3), seed)]);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static byte MakeDutchTownName(byte *buf, uint32 seed)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2004-12-31 14:43:47 +00:00
|
|
|
//null terminates the string for strcat
|
|
|
|
strcpy(buf, "");
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2004-12-31 14:43:47 +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)
|
2004-12-31 14:43:47 +00:00
|
|
|
strcat(buf, name_dutch_1[i]);
|
|
|
|
|
|
|
|
// mandatory middle segments including option of hardcoded name
|
2005-01-12 22:10:50 +00:00
|
|
|
if (SeedChance(6, 9, seed) > 4) {
|
|
|
|
strcat(buf, name_dutch_2[SeedChance( 9, lengthof(name_dutch_2), seed)]);
|
2005-01-12 21:33:43 +00:00
|
|
|
} else {
|
2005-01-12 22:10:50 +00:00
|
|
|
strcat(buf, name_dutch_3[SeedChance( 9, lengthof(name_dutch_3), seed)]);
|
|
|
|
strcat(buf, name_dutch_4[SeedChance(12, lengthof(name_dutch_4), seed)]);
|
2004-12-31 14:43:47 +00:00
|
|
|
}
|
2005-01-12 22:10:50 +00:00
|
|
|
strcat(buf, name_dutch_5[SeedChance(15, lengthof(name_dutch_5), seed)]);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static byte MakeFinnishTownName(byte *buf, uint32 seed)
|
|
|
|
{
|
2004-12-31 14:43:47 +00:00
|
|
|
//null terminates the string for strcat
|
|
|
|
strcpy(buf, "");
|
|
|
|
|
|
|
|
// 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) {
|
|
|
|
strcat(buf, name_finnish_1[SeedChance( 2, lengthof(name_finnish_1), seed)]);
|
2005-01-12 21:33:43 +00:00
|
|
|
} else {
|
2005-01-12 22:10:50 +00:00
|
|
|
strcat(buf, name_finnish_2a[SeedChance( 2, lengthof(name_finnish_2a), seed)]);
|
|
|
|
strcat(buf, name_finnish_2b[SeedChance(10, lengthof(name_finnish_2b), seed)]);
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static byte MakePolishTownName(byte *buf, uint32 seed)
|
|
|
|
{
|
2005-01-09 21:25:44 +00:00
|
|
|
uint i;
|
|
|
|
uint j;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2004-12-31 14:43:47 +00:00
|
|
|
//null terminates the string for strcat
|
|
|
|
strcpy(buf, "");
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2004-12-31 14:43:47 +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)) {
|
2005-01-12 22:10:50 +00:00
|
|
|
strcat(buf, name_polish_2_o[SeedChance(3, lengthof(name_polish_2_o), seed)]);
|
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)
|
2005-01-12 22:10:50 +00:00
|
|
|
strcat(buf, name_polish_1_m[SeedChance(5, lengthof(name_polish_1_m), seed)]);
|
2004-12-31 14:43:47 +00:00
|
|
|
|
2005-01-12 22:10:50 +00:00
|
|
|
strcat(buf, name_polish_2_m[SeedChance(7, lengthof(name_polish_2_m), seed)]);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2004-12-31 14:43:47 +00:00
|
|
|
if (j >= 4 && j < 16)
|
2005-01-12 22:10:50 +00:00
|
|
|
strcat(buf, name_polish_3_m[SeedChance(10, lengthof(name_polish_3_m), seed)]);
|
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)
|
2005-01-12 22:10:50 +00:00
|
|
|
strcat(buf, name_polish_1_f[SeedChance(5, lengthof(name_polish_1_f), seed)]);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-01-12 22:10:50 +00:00
|
|
|
strcat(buf, name_polish_2_f[SeedChance(7, lengthof(name_polish_2_f), seed)]);
|
2004-12-31 14:43:47 +00:00
|
|
|
|
|
|
|
if (j >= 4 && j < 16)
|
2005-01-12 22:10:50 +00:00
|
|
|
strcat(buf, name_polish_3_f[SeedChance(10, lengthof(name_polish_3_f), seed)]);
|
2005-01-12 21:33:43 +00:00
|
|
|
} else {
|
2004-12-31 14:43:47 +00:00
|
|
|
if (j < 4)
|
2005-01-12 22:10:50 +00:00
|
|
|
strcat(buf, name_polish_1_n[SeedChance(5, lengthof(name_polish_1_n), seed)]);
|
2004-12-31 14:43:47 +00:00
|
|
|
|
2005-01-12 22:10:50 +00:00
|
|
|
strcat(buf, name_polish_2_n[SeedChance(7, lengthof(name_polish_2_n), seed)]);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2004-12-31 14:43:47 +00:00
|
|
|
if (j >= 4 && j < 16)
|
2005-01-12 22:10:50 +00:00
|
|
|
strcat(buf, name_polish_3_n[SeedChance(10, lengthof(name_polish_3_n), seed)]);
|
2004-12-31 14:43:47 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-08-23 21:40:01 +00:00
|
|
|
static byte MakeCzechTownName(byte *buf, uint32 seed)
|
|
|
|
{
|
2005-01-12 22:10:50 +00:00
|
|
|
strcpy(buf, name_czech_1[SeedChance(0, lengthof(name_czech_1), seed)]);
|
2004-09-10 19:02:27 +00:00
|
|
|
return 0;
|
2004-08-23 21:40:01 +00:00
|
|
|
}
|
|
|
|
|
2004-09-13 12:28:11 +00:00
|
|
|
static byte MakeRomanianTownName(byte *buf, uint32 seed)
|
|
|
|
{
|
2005-01-12 22:10:50 +00:00
|
|
|
strcpy(buf, name_romanian_1[SeedChance(0, lengthof(name_romanian_1), seed)]);
|
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
|
|
|
|
2004-11-15 12:11:43 +00:00
|
|
|
static byte MakeSlovakTownName(byte *buf, uint32 seed)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2005-01-12 22:10:50 +00:00
|
|
|
strcpy(buf, name_slovakish_1[SeedChance(0, lengthof(name_slovakish_1), seed)]);
|
2004-09-10 19:02:27 +00:00
|
|
|
return 0;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2005-01-09 00:17:01 +00:00
|
|
|
static byte MakeNorwegianTownName(byte *buf, uint32 seed)
|
|
|
|
{
|
|
|
|
strcpy(buf, "");
|
2005-01-09 20:45:07 +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) {
|
2005-01-09 20:45:07 +00:00
|
|
|
// Use 7bit for the realname table index. Bit 4-10
|
2005-01-12 22:10:50 +00:00
|
|
|
strcat(buf, name_norwegian_real[SeedChance(4, lengthof(name_norwegian_real), seed)]);
|
2005-01-12 21:33:43 +00:00
|
|
|
} else {
|
2005-01-09 20:45:07 +00:00
|
|
|
// Use 7bit for the first fake part. Bit 4-10
|
2005-01-12 22:10:50 +00:00
|
|
|
strcat(buf, name_norwegian_1[SeedChance(4, lengthof(name_norwegian_1), seed)]);
|
2005-01-09 20:45:07 +00:00
|
|
|
// Use 7bit for the last fake part. Bit 11-17
|
2005-01-12 22:10:50 +00:00
|
|
|
strcat(buf, name_norwegian_2[SeedChance(11, lengthof(name_norwegian_2), seed)]);
|
2005-01-09 20:45:07 +00:00
|
|
|
}
|
|
|
|
|
2005-01-09 00:17:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
static byte MakeHungarianTownName(byte *buf, uint32 seed)
|
|
|
|
{
|
2005-01-09 21:25:44 +00:00
|
|
|
uint i;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2004-12-31 14:43:47 +00:00
|
|
|
//null terminates the string for strcat
|
|
|
|
strcpy(buf, "");
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-01-12 22:10:50 +00:00
|
|
|
if (SeedChance(12, 15, seed) < 3) {
|
|
|
|
strcat(buf, name_hungarian_real[SeedChance(0, lengthof(name_hungarian_real), seed)]);
|
2005-01-12 21:33:43 +00:00
|
|
|
} else {
|
2004-12-31 14:43:47 +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))
|
2004-12-31 14:43:47 +00:00
|
|
|
strcat(buf, name_hungarian_1[i]);
|
|
|
|
|
|
|
|
// mandatory middle segments
|
2005-01-12 22:10:50 +00:00
|
|
|
strcat(buf, name_hungarian_2[SeedChance(3, lengthof(name_hungarian_2), seed)]);
|
|
|
|
strcat(buf, name_hungarian_3[SeedChance(6, lengthof(name_hungarian_3), seed)]);
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-12-31 14:43:47 +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)) {
|
2004-12-31 14:43:47 +00:00
|
|
|
strcat(buf, name_hungarian_4[i]);
|
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
|
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,
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
2004-08-10 14:42:52 +00:00
|
|
|
|
2004-12-31 14:43:47 +00:00
|
|
|
// DO WE NEED THIS ANY MORE?
|
2004-08-10 14:42:52 +00:00
|
|
|
#define FIXNUM(x, y, z) (((((x) << 16) / (y)) + 1) << z)
|
|
|
|
|
|
|
|
uint32 GetOldTownName(uint32 townnameparts, byte old_town_name_type)
|
|
|
|
{
|
|
|
|
switch (old_town_name_type) {
|
|
|
|
case 0: case 3: /* English, American */
|
|
|
|
/* Already OK */
|
|
|
|
return townnameparts;
|
2005-01-12 21:33:43 +00:00
|
|
|
|
2004-08-10 14:42:52 +00:00
|
|
|
case 1: /* French */
|
|
|
|
/* For some reason 86 needs to be subtracted from townnameparts
|
2004-12-31 14:43:47 +00:00
|
|
|
* 0000 0000 0000 0000 0000 0000 1111 1111 */
|
|
|
|
return FIXNUM(townnameparts - 86, lengthof(name_french_1), 0);
|
2005-01-12 21:33:43 +00:00
|
|
|
|
2004-08-10 14:42:52 +00:00
|
|
|
case 2: /* German */
|
2004-08-16 14:48:35 +00:00
|
|
|
DEBUG(misc, 0) ("German Townnames are buggy... (%d)", townnameparts);
|
2004-08-10 14:42:52 +00:00
|
|
|
return townnameparts;
|
2005-01-12 21:33:43 +00:00
|
|
|
|
2004-08-10 14:42:52 +00:00
|
|
|
case 4: /* Latin-American */
|
|
|
|
/* 0000 0000 0000 0000 0000 0000 1111 1111 */
|
2004-12-31 14:43:47 +00:00
|
|
|
return FIXNUM(townnameparts, lengthof(name_spanish_1), 0);
|
2005-01-12 21:33:43 +00:00
|
|
|
|
2004-08-10 14:42:52 +00:00
|
|
|
case 5: /* Silly */
|
|
|
|
/* NUM_SILLY_1 - lower 16 bits
|
2004-12-31 14:43:47 +00:00
|
|
|
* NUM_SILLY_2 - upper 16 bits without leading 1 (first 8 bytes)
|
|
|
|
* 1000 0000 2222 2222 0000 0000 1111 1111 */
|
|
|
|
return FIXNUM(townnameparts, lengthof(name_silly_1), 0) | FIXNUM(((townnameparts >> 16)&0xFF), lengthof(name_silly_2), 16);
|
2004-08-10 14:42:52 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|