File diff r192:731807cde462 → r193:6aa65dc5a4b4
namegen.c
Show inline comments
 
@@ -8,28 +8,28 @@ static void AppendPart(byte **buf, int n
 
{
 
	byte *s;
 

	
 
	while (--num>=0) {
 
		do names++; while (names[-1]);
 
	}
 
	
 

	
 
	for(s=*buf; (*s++ = *names++) != 0;) {}
 
	*buf = s - 1;
 
}
 

	
 
#define MK(x) x "\x0"
 

	
 
#define NUM_ENGLISH_1 4
 
static const char english_1[] = 
 
static const char english_1[] =
 
	MK("Great ")
 
	MK("Little ")
 
	MK("New ")
 
	MK("Fort ")
 
;
 

	
 
#define NUM_ENGLISH_2 26 
 
#define NUM_ENGLISH_2 26
 
static const char english_2[] =
 
	MK("Wr")
 
	MK("B")
 
	MK("C")
 
	MK("Ch")
 
	MK("Br")
 
@@ -54,36 +54,36 @@ static const char english_2[] =
 
	MK("T")
 
	MK("Tr")
 
	MK("W")
 
;
 

	
 
#define NUM_ENGLISH_3 8
 
static const char english_3[] = 
 
static const char english_3[] =
 
	MK("ar")
 
	MK("a")
 
	MK("e")
 
	MK("in")
 
	MK("on")
 
	MK("u")
 
	MK("un")
 
	MK("en")
 
;
 

	
 
#define NUM_ENGLISH_4 7
 
static const char english_4[] = 
 
static const char english_4[] =
 
	MK("n")
 
	MK("ning")
 
	MK("ding")
 
	MK("d")
 
	MK("")
 
	MK("t")
 
	MK("fing")
 
;
 

	
 
#define NUM_ENGLISH_5 23
 
static const char english_5[] = 
 
static const char english_5[] =
 
	MK("ville")
 
	MK("ham")
 
	MK("field")
 
	MK("ton")
 
	MK("town")
 
	MK("bridge")
 
@@ -104,13 +104,13 @@ static const char english_5[] =
 
	MK("well")
 
	MK("hattan")
 
	MK("burg")
 
;
 

	
 
#define NUM_ENGLISH_6 9
 
static const char english_6[] = 
 
static const char english_6[] =
 
	MK("-on-sea")
 
	MK(" Bay")
 
	MK(" Market")
 
	MK(" Cross")
 
	MK(" Bridge")
 
	MK(" Falls")
 
@@ -127,31 +127,31 @@ static byte MakeEnglishTownName(byte *bu
 
	byte result;
 
	byte *start;
 

	
 
	i = GETNUM(0, 54) - 50;
 
	if (i >= 0)
 
		AppendPart(&buf, i, english_1);
 
	
 

	
 
	start = buf;
 

	
 
	AppendPart(&buf, GETNUM(4, NUM_ENGLISH_2), english_2);
 
	AppendPart(&buf, GETNUM(7, NUM_ENGLISH_3), english_3);
 
	AppendPart(&buf, GETNUM(10, NUM_ENGLISH_4), english_4);
 
	AppendPart(&buf, GETNUM(13, NUM_ENGLISH_5), english_5);
 

	
 
	i = GETNUM(15, NUM_ENGLISH_6 + 60) - 60;
 

	
 
	result = 0;
 
	
 

	
 
	if (i >= 0) {
 
		if (i <= 1) result = NG_EDGE;
 
		AppendPart(&buf, i, english_6);
 
	}
 

	
 
	if (start[0]=='C' && (start[1] == 'e' || start[1] == 'i'))
 
		start[0] = 'K'; 
 
		start[0] = 'K';
 

	
 
	/* Replace certain words (routine identical to TTD now) */
 

	
 
	REPLACE_WORDS('C','u','n','t',  'E','a','s','t');
 
	REPLACE_WORDS('S','l','a','g',  'P','i','t','s');
 
	REPLACE_WORDS('S','l','u','t',  'E','d','i','n');
 
@@ -164,23 +164,23 @@ static byte MakeEnglishTownName(byte *bu
 
	REPLACE_WORDS('W','r','a','r',  'I','n','v','e');
 

	
 
	return result;
 
}
 

	
 
#define NUM_AUSTRIAN_A1 6
 
static const char austrian_a1[] = 
 
static const char austrian_a1[] =
 
	MK("Bad ")
 
	MK("Deutsch ")
 
	MK("Gross ")
 
	MK("Klein ")
 
	MK("Markt ")
 
	MK("Maria ")
 
;
 

	
 
#define NUM_AUSTRIAN_A2 42
 
static const char austrian_a2[] = 
 
static const char austrian_a2[] =
 
	MK("Aus")
 
	MK("Alten")
 
	MK("Braun")
 
	MK("Vösl")
 
	MK("Mittern")
 
	MK("Nuss")
 
@@ -220,13 +220,13 @@ static const char austrian_a2[] =
 
	MK("Vösen")
 
	MK("Vill")
 
	MK("Weissen")
 
;
 

	
 
#define NUM_AUSTRIAN_A3 16
 
static const char austrian_a3[] = 
 
static const char austrian_a3[] =
 
	MK("see")
 
	MK("bach")
 
	MK("dorf")
 
	MK("ach")
 
	MK("stein")
 
	MK("hofen")
 
@@ -368,14 +368,14 @@ static byte MakeAustrianTownName(byte *b
 
	}
 

	
 
	return 0;
 
}
 

	
 
#define NUM_GERMAN_1 114
 
#define NUM_GERMAN_1_HARDCODED 21 
 
static const char german_1[] = 
 
#define NUM_GERMAN_1_HARDCODED 21
 
static const char german_1[] =
 
	/* hardcoded names */
 
	MK("Berlin")
 
	MK("Bonn")
 
	MK("Bremen")
 
	MK("Cottbus")
 
	MK("Chemnitz")
 
@@ -528,20 +528,20 @@ static const char german_4[] =
 
	MK("Spree")
 
	MK("Donau")
 
	MK("Saale")
 
	MK("Elbe")
 
	/* use "am" */
 
	MK("Main")
 
	
 

	
 
;
 

	
 
static byte MakeGermanTownName(byte *buf, uint32 seed)
 
{
 
	int i;
 
	int ext;
 
	
 

	
 
	ext=GETNUM(7, 28); /* Extension - Prefix / Suffix */
 

	
 
	if ((ext==12) || (ext==19)) {
 
		i=GETNUM(2,NUM_GERMAN_3-2);
 
		AppendPart(&buf, 2+i, german_3);
 
	}
 
@@ -568,13 +568,13 @@ static byte MakeGermanTownName(byte *buf
 
	}
 

	
 
	return 0;
 
}
 

	
 
#define NUM_SPANISH_1 86
 
static const char spanish_1[] = 
 
static const char spanish_1[] =
 
	MK("Caracas")
 
	MK("Maracay")
 
	MK("Maracaibo")
 
	MK("Velencia")
 
	MK("El Dorado")
 
	MK("Morrocoy")
 
@@ -659,17 +659,17 @@ static const char spanish_1[] =
 
	MK("Mendoza")
 
	MK("Santa Rosa");
 

	
 
static byte MakeSpanishTownName(byte *buf, uint32 seed)
 
{
 
	AppendPart(&buf, GETNUM(0, NUM_SPANISH_1), spanish_1);
 
	return 0;	
 
	return 0;
 
}
 

	
 
#define NUM_FRENCH_1 70
 
static const char french_1[] = 
 
static const char french_1[] =
 
	MK("Agincourt")
 
	MK("Lille")
 
	MK("Dinan")
 
	MK("Aubusson")
 
	MK("Rodez")
 
	MK("Bergerac")
 
@@ -681,13 +681,13 @@ static const char french_1[] =
 
	MK("Digne")
 
	MK("Nice")
 
	MK("Cannes")
 
	MK("St. Tropez")
 
	MK("Marseilles")
 
	MK("Narbonne")
 
	MK("Sète") 
 
	MK("Sète")
 
	MK("Aurillac")
 
	MK("Gueret")
 
	MK("Le Creusot")
 
	MK("Nevers")
 
	MK("Auxerre")
 
	MK("Versailles")
 
@@ -748,13 +748,13 @@ static byte MakeAmericanTownName(byte *b
 
{
 
	// make american town names equal to english for now.
 
	return MakeEnglishTownName(buf, seed);
 
}
 

	
 
#define NUM_SILLY_1 88
 
static const char silly_1[] = 
 
static const char silly_1[] =
 
	MK("Binky")
 
	MK("Blubber")
 
	MK("Bumble")
 
	MK("Crinkle")
 
	MK("Crusty")
 
	MK("Dangle")
 
@@ -848,34 +848,34 @@ static const char silly_1[] =
 
	MK("Fizzle")
 
	MK("Frosty")
 
	MK("Griddle")
 
;
 

	
 
#define NUM_SILLY_2 15
 
static const char silly_2[] = 
 
static const char silly_2[] =
 
	MK("ton")
 
	MK("bury")
 
	MK("bottom")
 
	MK("ville")
 
	MK("well")
 
	MK("weed")
 
	MK("worth")
 
	MK("wig")
 
	MK("wick")
 
	MK("wood")
 
	
 

	
 
	MK("pool")
 
	MK("head")
 
	MK("burg")
 
	MK("gate")
 
	MK("bridge")
 
;
 

	
 

	
 
static byte MakeSillyTownName(byte *buf, uint32 seed)
 
{		
 
{
 
	AppendPart(&buf, GETNUM(0, NUM_SILLY_1), silly_1);
 
	AppendPart(&buf, GETNUM(16, NUM_SILLY_2),silly_2);
 
	return 0;
 
}
 

	
 

	
 
@@ -1078,13 +1078,13 @@ static const char dutch_1[] =
 
	MK("Noord ")
 
	MK("Oost ")
 
	MK("West ")
 
	MK("Klein ");
 

	
 
#define NUM_DUTCH_2 57
 
static const char dutch_2[] = 
 
static const char dutch_2[] =
 
	MK("Hoog")
 
	MK("Laag")
 
	MK("Klein")
 
	MK("Groot")
 
	MK("Noorder")
 
	MK("Noord")
 
@@ -1138,13 +1138,13 @@ static const char dutch_2[] =
 
	MK("Haar")
 
	MK("Til")
 
	MK("Loos")
 
	MK("Hil");
 

	
 
#define NUM_DUTCH_3 20
 
static const char dutch_3[] = 
 
static const char dutch_3[] =
 
	MK("Drog")
 
	MK("Nat")
 
	MK("Valk")
 
	MK("Bob")
 
	MK("Dedem")
 
	MK("Kollum")
 
@@ -1159,25 +1159,25 @@ static const char dutch_3[] =
 
	MK("Werk")
 
	MK("Spijk")
 
	MK("Vink")
 
	MK("Wams")
 
	MK("Heerhug")
 
	MK("Koning");
 
	
 

	
 

	
 
#define NUM_DUTCH_4 6
 
static const char dutch_4[] = 
 
static const char dutch_4[] =
 
	MK("e")
 
	MK("er")
 
	MK("el")
 
	MK("en")
 
	MK("o")
 
	MK("s");
 

	
 
#define NUM_DUTCH_5 56
 
static const char dutch_5[] = 
 
static const char dutch_5[] =
 
	MK("stad")
 
	MK("vorst")
 
	MK("dorp")
 
	MK("dam")
 
	MK("beek")
 
	MK("doorn")
 
@@ -1228,19 +1228,19 @@ static const char dutch_5[] =
 
	MK("pomp")
 
	MK("huizen")
 
	MK("bergen")
 
	MK("schede")
 
	MK("mere")
 
	MK("end");
 
	
 

	
 
static byte MakeDutchTownName(byte *buf, uint32 seed)
 
{
 
	int i;
 

	
 
	i = GETNUM(0, 50 + NUM_DUTCH_1) - 50;
 
	if (i >= 0) 
 
	if (i >= 0)
 
		AppendPart(&buf, i, dutch_1);
 

	
 
	i = GETNUM(6, 9);
 
	if(i > 4){
 
		AppendPart(&buf, GETNUM(9, NUM_DUTCH_2), dutch_2);
 
	} else {
 
@@ -1250,13 +1250,13 @@ static byte MakeDutchTownName(byte *buf,
 
	AppendPart(&buf, GETNUM(15, NUM_DUTCH_5), dutch_5);
 

	
 
	return 0;
 
}
 

	
 
#define NUM_FINNISH_1 25
 
static const char finnish_1[] = 
 
static const char finnish_1[] =
 
	MK("Aijala")
 
	MK("Kisko")
 
	MK("Espoo")
 
	MK("Helsinki")
 
	MK("Tapiola")
 
	MK("Järvelä")
 
@@ -1276,15 +1276,15 @@ static const char finnish_1[] =
 
	MK("Raisio")
 
	MK("Taavetti")
 
	MK("Joensuu")
 
	MK("Imatra")
 
	MK("Tapanila")
 
	MK("Pasila");
 
 
 

	
 
#define NUM_FINNISH_2a 26
 
static const char finnish_2a[] = 
 
static const char finnish_2a[] =
 
	MK("Hiekka")
 
	MK("Haapa")
 
	MK("Mylly")
 
	MK("Kivi")
 
	MK("Lappeen")
 
	MK("Lohjan")
 
@@ -1307,13 +1307,13 @@ static const char finnish_2a[] =
 
	MK("Kemi")
 
	MK("Rova")
 
	MK("Martin")
 
	MK("Koivu");
 

	
 
#define NUM_FINNISH_2b 18
 
static const char finnish_2b[] = 
 
static const char finnish_2b[] =
 
	MK("harju")
 
	MK("linna")
 
	MK("järvi")
 
	MK("kallio")
 
	MK("mäki")
 
	MK("nummi")
 
@@ -1573,13 +1573,13 @@ MK(" Wzgorze")
 
MK(" Mosty")
 
MK(" Kujawski")
 
MK(" Malopolski")
 
MK(" Podlaski")
 
MK(" Lesny")
 
;
 
static const char polish_3_f[] = 
 
static const char polish_3_f[] =
 
MK(" Wybudowanie")
 
MK(" Swietokrzyska")
 
MK(" Gorska")
 
MK(" Morska")
 
MK(" Zdroj")
 
MK(" Woda")
 
@@ -1689,13 +1689,13 @@ static byte MakePolishTownName(byte *buf
 
	}
 

	
 
	return 0;
 
}
 

	
 
#define NUM_CZECH_1 82
 
static const char czech_1[] = 
 
static const char czech_1[] =
 
MK("As")
 
MK("Benesov")
 
MK("Beroun")
 
MK("Bezdruzice")
 
MK("Blansko")
 
MK("Breclav")
 
@@ -1777,13 +1777,13 @@ MK("Zlín")
 
MK("Znojmo")
 
;
 

	
 
static byte MakeCzechTownName(byte *buf, uint32 seed)
 
{
 
	AppendPart(&buf, GETNUM(0, NUM_CZECH_1), czech_1);
 
	return 0;	
 
	return 0;
 
}
 

	
 

	
 

	
 
#define NUM_SLOVAKISH_1 87
 
static const char slovakish_1[] =
 
@@ -1876,27 +1876,27 @@ MK("Zlate Moravce")
 
MK("Zvolen")
 
;
 

	
 
static byte MakeSlovakishTownName(byte *buf, uint32 seed)
 
{
 
	AppendPart(&buf, GETNUM(0, NUM_SLOVAKISH_1), slovakish_1);
 
	return 0;	
 
	return 0;
 
}
 

	
 
// Modifiers
 
#define NUM_HUNGARIAN_1 5
 
static const char hungarian_1[] = 
 
static const char hungarian_1[] =
 
	MK("Nagy-")
 
	MK("Kis-")
 
	MK("Felsõ-")
 
	MK("Alsó-")
 
	MK("Új-")
 
;
 

	
 
#define NUM_HUNGARIAN_2 54
 
static const char hungarian_2[] = 
 
static const char hungarian_2[] =
 
// River modifiers
 
// 1 - 10
 
	MK("Bodrog")
 
	MK("Dráva")
 
	MK("Duna")
 
	MK("Hejõ")
 
@@ -1968,13 +1968,13 @@ static const char hungarian_2[] =
 
	MK("Vas")
 
	MK("Vámos")
 
	MK("Vásáros")
 
;
 

	
 
#define NUM_HUNGARIAN_3 16
 
static const char hungarian_3[] = 
 
static const char hungarian_3[] =
 
	MK("apáti")
 
	MK("bába")
 
	MK("bikk")
 
	MK("dob")
 
	MK("fa")
 
	MK("föld")
 
@@ -1988,13 +1988,13 @@ static const char hungarian_3[] =
 
	MK("telek")
 
	MK("vas")
 
	MK("völgy")
 
;
 

	
 
#define NUM_HUNGARIAN_4 5
 
static const char hungarian_4[] = 
 
static const char hungarian_4[] =
 
	MK("alja")
 
	MK("egyháza")
 
	MK("háza")
 
	MK("úr")
 
	MK("vár")
 
;
 
@@ -2051,13 +2051,13 @@ static byte MakeHungarianTownName(byte *
 
		/* Append the prefix if needed */
 
		i = GETNUM(3, NUM_HUNGARIAN_1 * 3);
 
		if (i < NUM_HUNGARIAN_1) AppendPart(&buf, i, hungarian_1);
 

	
 
		AppendPart(&buf, GETNUM(3, NUM_HUNGARIAN_2), hungarian_2);
 
		AppendPart(&buf, GETNUM(6, NUM_HUNGARIAN_3), hungarian_3);
 
		
 

	
 
		i = GETNUM(10, NUM_HUNGARIAN_4 * 3);
 
		if (i < NUM_HUNGARIAN_4) AppendPart(&buf, i, hungarian_4);
 
	}
 
	return 0;
 
}