namegen.c
author peter1138
Sun, 22 Oct 2006 10:08:49 +0000
changeset 4919 8ac0256c6009
parent 4441 0365a1fc2116
child 5108 dc67d70b5a45
permissions -rw-r--r--
(svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 1891
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 1891
diff changeset
     2
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     3
#include "stdafx.h"
1891
92a3b0aa0946 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1473
diff changeset
     4
#include "openttd.h"
1299
0a6510cc889b (svn r1803) Move debugging stuff into files of it's own
tron
parents: 1109
diff changeset
     5
#include "debug.h"
2484
8e0c88a833fb (svn r3010) Get rid of quite some dubious casts, either by using GB(), proper types or just removing them
tron
parents: 2431
diff changeset
     6
#include "macros.h"
1306
40038dfdf3ba (svn r1810) Move town name generation declarations into a header of their own
tron
parents: 1299
diff changeset
     7
#include "namegen.h"
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
     8
#include "table/namegen.h"
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
     9
#include "string.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    10
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
    11
static inline uint32 SeedChance(int shift_by, int max, uint32 seed)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    12
{
2484
8e0c88a833fb (svn r3010) Get rid of quite some dubious casts, either by using GB(), proper types or just removing them
tron
parents: 2431
diff changeset
    13
	return (GB(seed, shift_by, 16) * max) >> 16;
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
    14
}
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
    15
1447
3f1c82502413 (svn r1951) Introduced SeedModChance() (which is like SeedChance() but uses simple modulo instead of bitshifting and multiplication), explained why does it work better, used it in MakeCzechTownName() and added a TODO note about possibly using it in the other town name generators too.
pasky
parents: 1426
diff changeset
    16
static inline uint32 SeedModChance(int shift_by, int max, uint32 seed)
3f1c82502413 (svn r1951) Introduced SeedModChance() (which is like SeedChance() but uses simple modulo instead of bitshifting and multiplication), explained why does it work better, used it in MakeCzechTownName() and added a TODO note about possibly using it in the other town name generators too.
pasky
parents: 1426
diff changeset
    17
{
3f1c82502413 (svn r1951) Introduced SeedModChance() (which is like SeedChance() but uses simple modulo instead of bitshifting and multiplication), explained why does it work better, used it in MakeCzechTownName() and added a TODO note about possibly using it in the other town name generators too.
pasky
parents: 1426
diff changeset
    18
	/* This actually gives *MUCH* more even distribution of the values
3f1c82502413 (svn r1951) Introduced SeedModChance() (which is like SeedChance() but uses simple modulo instead of bitshifting and multiplication), explained why does it work better, used it in MakeCzechTownName() and added a TODO note about possibly using it in the other town name generators too.
pasky
parents: 1426
diff changeset
    19
	 * than SeedChance(), which is absolutely horrible in that. If
3f1c82502413 (svn r1951) Introduced SeedModChance() (which is like SeedChance() but uses simple modulo instead of bitshifting and multiplication), explained why does it work better, used it in MakeCzechTownName() and added a TODO note about possibly using it in the other town name generators too.
pasky
parents: 1426
diff changeset
    20
	 * you do not believe me, try with i.e. the Czech town names,
3f1c82502413 (svn r1951) Introduced SeedModChance() (which is like SeedChance() but uses simple modulo instead of bitshifting and multiplication), explained why does it work better, used it in MakeCzechTownName() and added a TODO note about possibly using it in the other town name generators too.
pasky
parents: 1426
diff changeset
    21
	 * compare the words (nicely visible on prefixes) generated by
3f1c82502413 (svn r1951) Introduced SeedModChance() (which is like SeedChance() but uses simple modulo instead of bitshifting and multiplication), explained why does it work better, used it in MakeCzechTownName() and added a TODO note about possibly using it in the other town name generators too.
pasky
parents: 1426
diff changeset
    22
	 * SeedChance() and SeedModChance(). Do not get dicouraged by the
3f1c82502413 (svn r1951) Introduced SeedModChance() (which is like SeedChance() but uses simple modulo instead of bitshifting and multiplication), explained why does it work better, used it in MakeCzechTownName() and added a TODO note about possibly using it in the other town name generators too.
pasky
parents: 1426
diff changeset
    23
	 * never-use-modulo myths, which hold true only for the linear
3f1c82502413 (svn r1951) Introduced SeedModChance() (which is like SeedChance() but uses simple modulo instead of bitshifting and multiplication), explained why does it work better, used it in MakeCzechTownName() and added a TODO note about possibly using it in the other town name generators too.
pasky
parents: 1426
diff changeset
    24
	 * congruential generators (and Random() isn't such a generator).
3f1c82502413 (svn r1951) Introduced SeedModChance() (which is like SeedChance() but uses simple modulo instead of bitshifting and multiplication), explained why does it work better, used it in MakeCzechTownName() and added a TODO note about possibly using it in the other town name generators too.
pasky
parents: 1426
diff changeset
    25
	 * --pasky */
3f1c82502413 (svn r1951) Introduced SeedModChance() (which is like SeedChance() but uses simple modulo instead of bitshifting and multiplication), explained why does it work better, used it in MakeCzechTownName() and added a TODO note about possibly using it in the other town name generators too.
pasky
parents: 1426
diff changeset
    26
	// TODO: Perhaps we should use it for all the name generators? --pasky
3f1c82502413 (svn r1951) Introduced SeedModChance() (which is like SeedChance() but uses simple modulo instead of bitshifting and multiplication), explained why does it work better, used it in MakeCzechTownName() and added a TODO note about possibly using it in the other town name generators too.
pasky
parents: 1426
diff changeset
    27
	return (seed >> shift_by) % max;
3f1c82502413 (svn r1951) Introduced SeedModChance() (which is like SeedChance() but uses simple modulo instead of bitshifting and multiplication), explained why does it work better, used it in MakeCzechTownName() and added a TODO note about possibly using it in the other town name generators too.
pasky
parents: 1426
diff changeset
    28
}
3f1c82502413 (svn r1951) Introduced SeedModChance() (which is like SeedChance() but uses simple modulo instead of bitshifting and multiplication), explained why does it work better, used it in MakeCzechTownName() and added a TODO note about possibly using it in the other town name generators too.
pasky
parents: 1426
diff changeset
    29
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
    30
static inline int32 SeedChanceBias(int shift_by, int max, uint32 seed, int bias)
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
    31
{
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
    32
	return SeedChance(shift_by, max + bias, seed) - bias;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    33
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    34
1109
1bab892228cd (svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents: 1107
diff changeset
    35
static void ReplaceWords(const char *org, const char *rep, char *buf)
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
    36
{
1107
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
    37
	if (strncmp(buf, org, 4) == 0) strncpy(buf, rep, 4);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
    38
}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    39
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
    40
static byte MakeEnglishOriginalTownName(char *buf, uint32 seed, const char *last)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    41
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    42
	int i;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    43
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
    44
	//null terminates the string for strcat
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
    45
	strecpy(buf, "", last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    46
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
    47
	// optional first segment
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
    48
	i = SeedChanceBias(0, lengthof(name_original_english_1), seed, 50);
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
    49
	if (i >= 0)
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
    50
		strecat(buf, name_original_english_1[i], last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    51
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
    52
	//mandatory middle segments
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
    53
	strecat(buf, name_original_english_2[SeedChance(4,  lengthof(name_original_english_2), seed)], last);
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
    54
	strecat(buf, name_original_english_3[SeedChance(7,  lengthof(name_original_english_3), seed)], last);
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
    55
	strecat(buf, name_original_english_4[SeedChance(10, lengthof(name_original_english_4), seed)], last);
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
    56
	strecat(buf, name_original_english_5[SeedChance(13, lengthof(name_original_english_5), seed)], last);
111
31c32d936f58 (svn r112) -Fix: converted all linebreaks to UNIX-linebreak (\n) (forgot one file)
truelight
parents: 109
diff changeset
    57
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
    58
	//optional last segment
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
    59
	i = SeedChanceBias(15, lengthof(name_original_english_6), seed, 60);
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
    60
	if (i >= 0)
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
    61
		strecat(buf, name_original_english_6[i], last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    62
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
    63
	if (buf[0] == 'C' && (buf[1] == 'e' || buf[1] == 'i'))
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
    64
		buf[0] = 'K';
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
    65
1107
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
    66
	ReplaceWords("Cunt", "East", buf);
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
    67
	ReplaceWords("Slag", "Pits", buf);
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
    68
	ReplaceWords("Slut", "Edin", buf);
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
    69
	//ReplaceWords("Fart", "Boot", buf);
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
    70
	ReplaceWords("Drar", "Quar", buf);
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
    71
	ReplaceWords("Dreh", "Bash", buf);
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
    72
	ReplaceWords("Frar", "Shor", buf);
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
    73
	ReplaceWords("Grar", "Aber", buf);
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
    74
	ReplaceWords("Brar", "Over", buf);
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
    75
	ReplaceWords("Wrar", "Inve", buf);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
    76
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
    77
	return 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    78
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    79
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    80
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
    81
static byte MakeEnglishAdditionalTownName(char *buf, uint32 seed, const char *last)
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
    82
{
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
    83
	int i;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    84
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
    85
	//null terminates the string for strcat
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
    86
	strecpy(buf, "", last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    87
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
    88
	// optional first segment
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
    89
	i = SeedChanceBias(0, lengthof(name_additional_english_prefix), seed, 50);
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
    90
	if (i >= 0)
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
    91
		strecat(buf,name_additional_english_prefix[i], last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    92
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
    93
	if (SeedChance(3, 20, seed) >= 14) {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
    94
		strecat(buf, name_additional_english_1a[SeedChance(6, lengthof(name_additional_english_1a), seed)], last);
993
5ac6f569031e (svn r1491) Fix bracing style and indentation (Jango)
tron
parents: 992
diff changeset
    95
	} else {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
    96
		strecat(buf, name_additional_english_1b1[SeedChance(6, lengthof(name_additional_english_1b1), seed)], last);
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
    97
		strecat(buf, name_additional_english_1b2[SeedChance(9, lengthof(name_additional_english_1b2), seed)], last);
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
    98
		if (SeedChance(11, 20, seed) >= 4) {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
    99
			strecat(buf, name_additional_english_1b3a[SeedChance(12, lengthof(name_additional_english_1b3a), seed)], last);
993
5ac6f569031e (svn r1491) Fix bracing style and indentation (Jango)
tron
parents: 992
diff changeset
   100
		} else {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   101
			strecat(buf, name_additional_english_1b3b[SeedChance(12, lengthof(name_additional_english_1b3b), seed)], last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   102
		}
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   103
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   104
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   105
	strecat(buf, name_additional_english_2[SeedChance(14, lengthof(name_additional_english_2), seed)], last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   106
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   107
	//optional last segment
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
   108
	i = SeedChanceBias(15, lengthof(name_additional_english_3), seed, 60);
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
   109
	if (i >= 0)
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   110
		strecat(buf, name_additional_english_3[i], last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   111
1107
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
   112
	ReplaceWords("Cunt", "East", buf);
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
   113
	ReplaceWords("Slag", "Pits", buf);
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
   114
	ReplaceWords("Slut", "Edin", buf);
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
   115
	ReplaceWords("Fart", "Boot", buf);
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
   116
	ReplaceWords("Drar", "Quar", buf);
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
   117
	ReplaceWords("Dreh", "Bash", buf);
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
   118
	ReplaceWords("Frar", "Shor", buf);
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
   119
	ReplaceWords("Grar", "Aber", buf);
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
   120
	ReplaceWords("Brar", "Over", buf);
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
   121
	ReplaceWords("Wrar", "Stan", buf);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   122
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   123
	return 0;
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   124
}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   125
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   126
static byte MakeAustrianTownName(char *buf, uint32 seed, const char *last)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   127
{
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   128
	int i, j = 0;
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   129
	strecpy(buf, "", last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   130
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   131
	// Bad, Maria, Gross, ...
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
   132
	i = SeedChanceBias(0, lengthof(name_austrian_a1), seed, 15);
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   133
	if (i >= 0) strecat(buf, name_austrian_a1[i], last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   134
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
   135
	i = SeedChance(4, 6, seed);
993
5ac6f569031e (svn r1491) Fix bracing style and indentation (Jango)
tron
parents: 992
diff changeset
   136
	if (i >= 4) {
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   137
		// Kaisers-kirchen
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   138
		strecat(buf, name_austrian_a2[SeedChance( 7, lengthof(name_austrian_a2), seed)], last);
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   139
		strecat(buf, name_austrian_a3[SeedChance(13, lengthof(name_austrian_a3), seed)], last);
993
5ac6f569031e (svn r1491) Fix bracing style and indentation (Jango)
tron
parents: 992
diff changeset
   140
	} else if (i >= 2) {
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   141
		// St. Johann
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   142
		strecat(buf, name_austrian_a5[SeedChance( 7, lengthof(name_austrian_a5), seed)], last);
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   143
		strecat(buf, name_austrian_a6[SeedChance( 9, lengthof(name_austrian_a6), seed)], last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   144
		j = 1; // More likely to have a " an der " or " am "
993
5ac6f569031e (svn r1491) Fix bracing style and indentation (Jango)
tron
parents: 992
diff changeset
   145
	} else {
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   146
		// Zell
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   147
		strecat(buf, name_austrian_a4[SeedChance( 7, lengthof(name_austrian_a4), seed)], last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   148
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   149
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
   150
	i = SeedChance(1, 6, seed);
993
5ac6f569031e (svn r1491) Fix bracing style and indentation (Jango)
tron
parents: 992
diff changeset
   151
	if (i >= 4 - j) {
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   152
		// an der Donau (rivers)
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   153
		strecat(buf, name_austrian_f1[SeedChance(4, lengthof(name_austrian_f1), seed)], last);
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   154
		strecat(buf, name_austrian_f2[SeedChance(5, lengthof(name_austrian_f2), seed)], last);
993
5ac6f569031e (svn r1491) Fix bracing style and indentation (Jango)
tron
parents: 992
diff changeset
   155
	} else if (i >= 2 - j) {
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   156
		// am Dachstein (mountains)
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   157
		strecat(buf, name_austrian_b1[SeedChance(4, lengthof(name_austrian_b1), seed)], last);
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   158
		strecat(buf, name_austrian_b2[SeedChance(5, lengthof(name_austrian_b2), seed)], last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   159
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   160
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   161
	return 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   162
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   163
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   164
static byte MakeGermanTownName(char *buf, uint32 seed, const char *last)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   165
{
992
7ddeb6074c06 (svn r1490) Restore original town name generation behavior for german and hungarian (Jango)
tron
parents: 959
diff changeset
   166
	uint i;
7ddeb6074c06 (svn r1490) Restore original town name generation behavior for german and hungarian (Jango)
tron
parents: 959
diff changeset
   167
	uint seed_derivative;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   168
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   169
	//null terminates the string for strcat
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   170
	strecpy(buf, "", last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   171
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
   172
	seed_derivative = SeedChance(7, 28, seed);
992
7ddeb6074c06 (svn r1490) Restore original town name generation behavior for german and hungarian (Jango)
tron
parents: 959
diff changeset
   173
7ddeb6074c06 (svn r1490) Restore original town name generation behavior for german and hungarian (Jango)
tron
parents: 959
diff changeset
   174
	//optional prefix
7ddeb6074c06 (svn r1490) Restore original town name generation behavior for german and hungarian (Jango)
tron
parents: 959
diff changeset
   175
	if (seed_derivative == 12 || seed_derivative == 19) {
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
   176
		i = SeedChance(2, lengthof(name_german_pre), seed);
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   177
		strecat(buf,name_german_pre[i], last);
4
cad62d5f9708 (svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents: 0
diff changeset
   178
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   179
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   180
	// mandatory middle segments including option of hardcoded name
1422
c3bc75035658 (svn r1926) Codechange: Renamed some of the predefined town names arrays for consistent naming.
pasky
parents: 1307
diff changeset
   181
	i = SeedChance(3, lengthof(name_german_real) + lengthof(name_german_1), seed);
c3bc75035658 (svn r1926) Codechange: Renamed some of the predefined town names arrays for consistent naming.
pasky
parents: 1307
diff changeset
   182
	if (i < lengthof(name_german_real)) {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   183
		strecat(buf,name_german_real[i], last);
993
5ac6f569031e (svn r1491) Fix bracing style and indentation (Jango)
tron
parents: 992
diff changeset
   184
	} else {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   185
		strecat(buf, name_german_1[i - lengthof(name_german_real)], last);
992
7ddeb6074c06 (svn r1490) Restore original town name generation behavior for german and hungarian (Jango)
tron
parents: 959
diff changeset
   186
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
   187
		i = SeedChance(5, lengthof(name_german_2), seed);
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   188
		strecat(buf, name_german_2[i], last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   189
	}
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   190
992
7ddeb6074c06 (svn r1490) Restore original town name generation behavior for german and hungarian (Jango)
tron
parents: 959
diff changeset
   191
	// optional suffix
7ddeb6074c06 (svn r1490) Restore original town name generation behavior for german and hungarian (Jango)
tron
parents: 959
diff changeset
   192
	if (seed_derivative == 24) {
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
   193
		i = SeedChance(9,
992
7ddeb6074c06 (svn r1490) Restore original town name generation behavior for german and hungarian (Jango)
tron
parents: 959
diff changeset
   194
			lengthof(name_german_4_an_der) + lengthof(name_german_4_am), seed);
7ddeb6074c06 (svn r1490) Restore original town name generation behavior for german and hungarian (Jango)
tron
parents: 959
diff changeset
   195
		if (i < lengthof(name_german_4_an_der)) {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   196
			strecat(buf, name_german_3_an_der[0], last);
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   197
			strecat(buf, name_german_4_an_der[i], last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   198
		} else {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   199
			strecat(buf, name_german_3_am[0], last);
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   200
			strecat(buf, name_german_4_am[i - lengthof(name_german_4_an_der)], last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   201
		}
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   202
	}
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   203
	return 0;
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   204
}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   205
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   206
static byte MakeSpanishTownName(char *buf, uint32 seed, const char *last)
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   207
{
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   208
	strecpy(buf, name_spanish_real[SeedChance(0, lengthof(name_spanish_real), seed)], last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   209
	return 0;
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   210
}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   211
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   212
static byte MakeFrenchTownName(char *buf, uint32 seed, const char *last)
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   213
{
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   214
	strecpy(buf, name_french_real[SeedChance(0, lengthof(name_french_real), seed)], last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   215
	return 0;
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   216
}
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   217
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   218
static byte MakeSillyTownName(char *buf, uint32 seed, const char *last)
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   219
{
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   220
	strecpy(buf, name_silly_1[SeedChance( 0, lengthof(name_silly_1), seed)], last);
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   221
	strecat(buf, name_silly_2[SeedChance(16, lengthof(name_silly_2), seed)], last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   222
	return 0;
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   223
}
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   224
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   225
static byte MakeSwedishTownName(char *buf, uint32 seed, const char *last)
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   226
{
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   227
	int i;
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   228
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   229
	//null terminates the string for strcat
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   230
	strecpy(buf, "", last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   231
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   232
	// optional first segment
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
   233
	i = SeedChanceBias(0, lengthof(name_swedish_1), seed, 50);
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
   234
	if (i >= 0)
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   235
		strecat(buf, name_swedish_1[i], last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   236
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   237
	// mandatory middle segments including option of hardcoded name
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
   238
	if (SeedChance(4, 5, seed) >= 3) {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   239
		strecat(buf, name_swedish_2[SeedChance( 7, lengthof(name_swedish_2), seed)], last);
993
5ac6f569031e (svn r1491) Fix bracing style and indentation (Jango)
tron
parents: 992
diff changeset
   240
	} else {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   241
		strecat(buf, name_swedish_2a[SeedChance( 7, lengthof(name_swedish_2a), seed)], last);
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   242
		strecat(buf, name_swedish_2b[SeedChance(10, lengthof(name_swedish_2b), seed)], last);
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   243
		strecat(buf, name_swedish_2c[SeedChance(13, lengthof(name_swedish_2c), seed)], last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   244
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   245
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   246
	strecat(buf, name_swedish_3[SeedChance(16, lengthof(name_swedish_3), seed)], last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   247
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   248
	return 0;
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   249
}
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   250
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   251
static byte MakeDutchTownName(char *buf, uint32 seed, const char *last)
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   252
{
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   253
	int i;
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   254
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   255
	//null terminates the string for strcat
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   256
	strecpy(buf, "", last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   257
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   258
	// optional first segment
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
   259
	i = SeedChanceBias(0, lengthof(name_dutch_1), seed, 50);
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
   260
	if (i >= 0)
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   261
		strecat(buf, name_dutch_1[i], last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   262
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   263
	// mandatory middle segments including option of hardcoded name
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
   264
	if (SeedChance(6, 9, seed) > 4) {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   265
		strecat(buf, name_dutch_2[SeedChance( 9, lengthof(name_dutch_2), seed)], last);
993
5ac6f569031e (svn r1491) Fix bracing style and indentation (Jango)
tron
parents: 992
diff changeset
   266
	} else {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   267
		strecat(buf, name_dutch_3[SeedChance( 9, lengthof(name_dutch_3), seed)], last);
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   268
		strecat(buf, name_dutch_4[SeedChance(12, lengthof(name_dutch_4), seed)], last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   269
	}
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   270
	strecat(buf, name_dutch_5[SeedChance(15, lengthof(name_dutch_5), seed)], last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   271
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   272
	return 0;
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   273
}
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   274
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   275
static byte MakeFinnishTownName(char *buf, uint32 seed, const char *last)
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   276
{
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   277
	//null terminates the string for strcat
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   278
	strecpy(buf, "", last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   279
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   280
	// Select randomly if town name should consists of one or two parts.
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
   281
	if (SeedChance(0, 15, seed) >= 10) {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   282
		strecat(buf, name_finnish_real[SeedChance(2, lengthof(name_finnish_real), seed)], last);
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3698
diff changeset
   283
	} else if (SeedChance(0, 15, seed) >= 5) {
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3698
diff changeset
   284
		// A two-part name by combining one of name_finnish_1 + "la"/"lä"
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3698
diff changeset
   285
		// The reason for not having the contents of name_finnish_{1,2} in the same table is
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3698
diff changeset
   286
		// that the ones in name_finnish_2 are not good for this purpose.
3106
ac231bc8e06a (svn r3707) -Fix: made the generated Finnish town names sound more Finnish (ln-)
bjarni
parents: 2549
diff changeset
   287
		uint sel = SeedChance( 0, lengthof(name_finnish_1), seed);
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   288
		char *end;
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   289
		strecat(buf, name_finnish_1[sel], last);
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   290
		end = &buf[strlen(buf)-1];
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   291
		if (*end == 'i')
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   292
			*end = 'e';
3106
ac231bc8e06a (svn r3707) -Fix: made the generated Finnish town names sound more Finnish (ln-)
bjarni
parents: 2549
diff changeset
   293
		if (strstr(buf, "a") || strstr(buf, "o") || strstr(buf, "u") ||
ac231bc8e06a (svn r3707) -Fix: made the generated Finnish town names sound more Finnish (ln-)
bjarni
parents: 2549
diff changeset
   294
			strstr(buf, "A") || strstr(buf, "O") || strstr(buf, "U"))
ac231bc8e06a (svn r3707) -Fix: made the generated Finnish town names sound more Finnish (ln-)
bjarni
parents: 2549
diff changeset
   295
		{
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   296
			strecat(buf, "la", last);
3106
ac231bc8e06a (svn r3707) -Fix: made the generated Finnish town names sound more Finnish (ln-)
bjarni
parents: 2549
diff changeset
   297
		} else {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   298
			strecat(buf, "lä", last);
3106
ac231bc8e06a (svn r3707) -Fix: made the generated Finnish town names sound more Finnish (ln-)
bjarni
parents: 2549
diff changeset
   299
		}
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3698
diff changeset
   300
	} else {
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3698
diff changeset
   301
		// A two-part name by combining one of name_finnish_{1,2} + name_finnish_3.
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3698
diff changeset
   302
		// Why aren't name_finnish_{1,2} just one table? See above.
3106
ac231bc8e06a (svn r3707) -Fix: made the generated Finnish town names sound more Finnish (ln-)
bjarni
parents: 2549
diff changeset
   303
		uint sel = SeedChance(2,
ac231bc8e06a (svn r3707) -Fix: made the generated Finnish town names sound more Finnish (ln-)
bjarni
parents: 2549
diff changeset
   304
			lengthof(name_finnish_1) + lengthof(name_finnish_2), seed);
ac231bc8e06a (svn r3707) -Fix: made the generated Finnish town names sound more Finnish (ln-)
bjarni
parents: 2549
diff changeset
   305
		if (sel >= lengthof(name_finnish_1)) {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   306
			strecat(buf, name_finnish_2[sel-lengthof(name_finnish_1)], last);
3106
ac231bc8e06a (svn r3707) -Fix: made the generated Finnish town names sound more Finnish (ln-)
bjarni
parents: 2549
diff changeset
   307
		} else {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   308
			strecat(buf, name_finnish_1[sel], last);
3106
ac231bc8e06a (svn r3707) -Fix: made the generated Finnish town names sound more Finnish (ln-)
bjarni
parents: 2549
diff changeset
   309
		}
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   310
		strecat(buf, name_finnish_3[SeedChance(10, lengthof(name_finnish_3), seed)], last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   311
	}
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   312
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   313
	return 0;
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   314
}
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   315
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   316
static byte MakePolishTownName(char *buf, uint32 seed, const char *last)
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   317
{
959
b031d88c76f3 (svn r1451) Fix some of the signed/unsigned comparison warnings
tron
parents: 958
diff changeset
   318
	uint i;
b031d88c76f3 (svn r1451) Fix some of the signed/unsigned comparison warnings
tron
parents: 958
diff changeset
   319
	uint j;
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   320
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   321
	//null terminates the string for strcat
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   322
	strecpy(buf, "", last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   323
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   324
	// optional first segment
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
   325
	i = SeedChance(0,
993
5ac6f569031e (svn r1491) Fix bracing style and indentation (Jango)
tron
parents: 992
diff changeset
   326
		lengthof(name_polish_2_o) + lengthof(name_polish_2_m) +
5ac6f569031e (svn r1491) Fix bracing style and indentation (Jango)
tron
parents: 992
diff changeset
   327
		lengthof(name_polish_2_f) + lengthof(name_polish_2_n),
5ac6f569031e (svn r1491) Fix bracing style and indentation (Jango)
tron
parents: 992
diff changeset
   328
		seed);
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
   329
	j = SeedChance(2, 20, seed);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   330
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   331
993
5ac6f569031e (svn r1491) Fix bracing style and indentation (Jango)
tron
parents: 992
diff changeset
   332
	if (i < lengthof(name_polish_2_o)) {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   333
		strecat(buf, name_polish_2_o[SeedChance(3, lengthof(name_polish_2_o), seed)], last);
993
5ac6f569031e (svn r1491) Fix bracing style and indentation (Jango)
tron
parents: 992
diff changeset
   334
	} else if (i < lengthof(name_polish_2_m) + lengthof(name_polish_2_o)) {
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   335
		if (j < 4)
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   336
			strecat(buf, name_polish_1_m[SeedChance(5, lengthof(name_polish_1_m), seed)], last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   337
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   338
		strecat(buf, name_polish_2_m[SeedChance(7, lengthof(name_polish_2_m), seed)], last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   339
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   340
		if (j >= 4 && j < 16)
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   341
			strecat(buf, name_polish_3_m[SeedChance(10, lengthof(name_polish_3_m), seed)], last);
993
5ac6f569031e (svn r1491) Fix bracing style and indentation (Jango)
tron
parents: 992
diff changeset
   342
	} else if (i < lengthof(name_polish_2_f) + lengthof(name_polish_2_m) + lengthof(name_polish_2_o)) {
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   343
		if (j < 4)
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   344
			strecat(buf, name_polish_1_f[SeedChance(5, lengthof(name_polish_1_f), seed)], last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   345
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   346
		strecat(buf, name_polish_2_f[SeedChance(7, lengthof(name_polish_2_f), seed)], last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   347
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   348
		if (j >= 4 && j < 16)
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   349
			strecat(buf, name_polish_3_f[SeedChance(10, lengthof(name_polish_3_f), seed)], last);
993
5ac6f569031e (svn r1491) Fix bracing style and indentation (Jango)
tron
parents: 992
diff changeset
   350
	} else {
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   351
		if (j < 4)
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   352
			strecat(buf, name_polish_1_n[SeedChance(5, lengthof(name_polish_1_n), seed)], last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   353
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   354
		strecat(buf, name_polish_2_n[SeedChance(7, lengthof(name_polish_2_n), seed)], last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   355
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   356
		if (j >= 4 && j < 16)
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   357
			strecat(buf, name_polish_3_n[SeedChance(10, lengthof(name_polish_3_n), seed)], last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   358
	}
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   359
	return 0;
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   360
}
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   361
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   362
static byte MakeCzechTownName(char *buf, uint32 seed, const char *last)
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   363
{
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   364
	/* Probability of prefixes/suffixes */
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   365
	/* 0..11 prefix, 12..13 prefix+suffix, 14..17 suffix, 18..31 nothing */
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   366
	int prob_tails;
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   367
	bool do_prefix, do_suffix, dynamic_subst;
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   368
	/* IDs of the respective parts */
1473
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   369
	int prefix = 0, ending = 0, suffix = 0;
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   370
	uint postfix = 0;
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   371
	uint stem;
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   372
	/* The select criteria. */
1473
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   373
	CzechGender gender;
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   374
	CzechChoose choose;
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   375
	CzechAllow allow;
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   376
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   377
	// 1:3 chance to use a real name.
1447
3f1c82502413 (svn r1951) Introduced SeedModChance() (which is like SeedChance() but uses simple modulo instead of bitshifting and multiplication), explained why does it work better, used it in MakeCzechTownName() and added a TODO note about possibly using it in the other town name generators too.
pasky
parents: 1426
diff changeset
   378
	if (SeedModChance(0, 4, seed) == 0) {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   379
		strecpy(buf, name_czech_real[SeedModChance(4, lengthof(name_czech_real), seed)], last);
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   380
		return 0;
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   381
	}
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   382
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   383
	// NUL terminates the string for strcat()
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   384
	strecpy(buf, "", last);
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   385
1447
3f1c82502413 (svn r1951) Introduced SeedModChance() (which is like SeedChance() but uses simple modulo instead of bitshifting and multiplication), explained why does it work better, used it in MakeCzechTownName() and added a TODO note about possibly using it in the other town name generators too.
pasky
parents: 1426
diff changeset
   386
	prob_tails = SeedModChance(2, 32, seed);
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   387
	do_prefix = prob_tails < 12;
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   388
	do_suffix = prob_tails > 11 && prob_tails < 17;
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   389
1447
3f1c82502413 (svn r1951) Introduced SeedModChance() (which is like SeedChance() but uses simple modulo instead of bitshifting and multiplication), explained why does it work better, used it in MakeCzechTownName() and added a TODO note about possibly using it in the other town name generators too.
pasky
parents: 1426
diff changeset
   390
	if (do_prefix) prefix = SeedModChance(5, lengthof(name_czech_adj) * 12, seed) / 12;
3f1c82502413 (svn r1951) Introduced SeedModChance() (which is like SeedChance() but uses simple modulo instead of bitshifting and multiplication), explained why does it work better, used it in MakeCzechTownName() and added a TODO note about possibly using it in the other town name generators too.
pasky
parents: 1426
diff changeset
   391
	if (do_suffix) suffix = SeedModChance(7, lengthof(name_czech_suffix), seed);
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   392
	// 3:1 chance 3:1 to use dynamic substantive
1473
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   393
	stem = SeedModChance(9,
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   394
		lengthof(name_czech_subst_full) + 3 * lengthof(name_czech_subst_stem),
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   395
		seed);
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   396
	if (stem < lengthof(name_czech_subst_full)) {
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   397
		// That was easy!
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   398
		dynamic_subst = false;
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   399
		gender = name_czech_subst_full[stem].gender;
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   400
		choose = name_czech_subst_full[stem].choose;
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   401
		allow = name_czech_subst_full[stem].allow;
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   402
	} else {
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   403
		unsigned int map[lengthof(name_czech_subst_ending)];
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   404
		int ending_start = -1, ending_stop = -1;
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   405
		int i;
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   406
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   407
		// Load the substantive
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   408
		dynamic_subst = true;
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   409
		stem -= lengthof(name_czech_subst_full);
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   410
		stem %= lengthof(name_czech_subst_stem);
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   411
		gender = name_czech_subst_stem[stem].gender;
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   412
		choose = name_czech_subst_stem[stem].choose;
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   413
		allow = name_czech_subst_stem[stem].allow;
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   414
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   415
		// Load the postfix (1:1 chance that a postfix will be inserted)
1447
3f1c82502413 (svn r1951) Introduced SeedModChance() (which is like SeedChance() but uses simple modulo instead of bitshifting and multiplication), explained why does it work better, used it in MakeCzechTownName() and added a TODO note about possibly using it in the other town name generators too.
pasky
parents: 1426
diff changeset
   416
		postfix = SeedModChance(14, lengthof(name_czech_subst_postfix) * 2, seed);
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   417
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   418
		if (choose & CZC_POSTFIX) {
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   419
			// Always get a real postfix.
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   420
			postfix %= lengthof(name_czech_subst_postfix);
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   421
		}
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   422
		if (choose & CZC_NOPOSTFIX) {
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   423
			// Always drop a postfix.
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   424
			postfix += lengthof(name_czech_subst_postfix);
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   425
		}
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3698
diff changeset
   426
		if (postfix < lengthof(name_czech_subst_postfix)) {
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   427
			choose |= CZC_POSTFIX;
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3698
diff changeset
   428
		} else {
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   429
			choose |= CZC_NOPOSTFIX;
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3698
diff changeset
   430
		}
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   431
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   432
		// Localize the array segment containing a good gender
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   433
		for (ending = 0; ending < (int) lengthof(name_czech_subst_ending); ending++) {
1473
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   434
			const CzechNameSubst *e = &name_czech_subst_ending[ending];
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   435
1473
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   436
			if (gender == CZG_FREE ||
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   437
					(gender == CZG_NFREE && e->gender != CZG_SNEUT && e->gender != CZG_PNEUT) ||
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   438
					gender == e->gender) {
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   439
				if (ending_start < 0)
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   440
					ending_start = ending;
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   441
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   442
			} else if (ending_start >= 0) {
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   443
				ending_stop = ending - 1;
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   444
				break;
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   445
			}
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   446
		}
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   447
		if (ending_stop < 0) {
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   448
			// Whoa. All the endings matched.
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   449
			ending_stop = ending - 1;
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   450
		}
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   451
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   452
		// Make a sequential map of the items with good mask
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   453
		i = 0;
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   454
		for (ending = ending_start; ending <= ending_stop; ending++) {
1473
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   455
			const CzechNameSubst *e = &name_czech_subst_ending[ending];
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   456
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   457
			if ((e->choose & choose) == choose && (e->allow & allow) != 0)
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   458
				map[i++] = ending;
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   459
		}
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   460
		assert(i > 0);
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   461
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   462
		// Load the ending
1447
3f1c82502413 (svn r1951) Introduced SeedModChance() (which is like SeedChance() but uses simple modulo instead of bitshifting and multiplication), explained why does it work better, used it in MakeCzechTownName() and added a TODO note about possibly using it in the other town name generators too.
pasky
parents: 1426
diff changeset
   463
		ending = map[SeedModChance(16, i, seed)];
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   464
		// Override possible CZG_*FREE; this must be a real gender,
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   465
		// otherwise we get overflow when modifying the adjectivum.
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   466
		gender = name_czech_subst_ending[ending].gender;
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   467
		assert(gender != CZG_FREE && gender != CZG_NFREE);
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   468
	}
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   469
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   470
	if (do_prefix && (name_czech_adj[prefix].choose & choose) != choose) {
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   471
		// Throw away non-matching prefix.
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   472
		do_prefix = false;
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   473
	}
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   474
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   475
	// Now finally construct the name
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   476
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   477
	if (do_prefix) {
1473
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   478
		CzechPattern pattern = name_czech_adj[prefix].pattern;
4321
b763b7007162 (svn r5974) -Codechange: added casts all around the place to make Windows 64bit happy (michi_cc)
truelight
parents: 4312
diff changeset
   479
		size_t endpos;
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   480
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   481
		strecat(buf, name_czech_adj[prefix].name, last);
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   482
		endpos = strlen(buf) - 1;
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   483
		if (gender == CZG_SMASC && pattern == CZP_PRIVL) {
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   484
			/* -ovX -> -uv */
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   485
			buf[endpos - 2] = 'u';
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   486
			assert(buf[endpos - 1] == 'v');
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   487
			buf[endpos] = '\0';
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   488
		} else {
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   489
			buf[endpos] = name_czech_patmod[gender][pattern];
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   490
		}
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   491
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   492
		strecat(buf, " ", last);
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   493
	}
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   494
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   495
	if (dynamic_subst) {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   496
		strecat(buf, name_czech_subst_stem[stem].name, last);
1473
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   497
		if (postfix < lengthof(name_czech_subst_postfix)) {
1426
0a215fc32f96 (svn r1930) Cleaned up the postfix-ending connecting code and introduced some simple postfix-last-letter transformations when the ending first letter is 'i'.
pasky
parents: 1425
diff changeset
   498
			const char *poststr = name_czech_subst_postfix[postfix];
0a215fc32f96 (svn r1930) Cleaned up the postfix-ending connecting code and introduced some simple postfix-last-letter transformations when the ending first letter is 'i'.
pasky
parents: 1425
diff changeset
   499
			const char *endstr = name_czech_subst_ending[ending].name;
4321
b763b7007162 (svn r5974) -Codechange: added casts all around the place to make Windows 64bit happy (michi_cc)
truelight
parents: 4312
diff changeset
   500
			size_t postlen, endlen;
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   501
1426
0a215fc32f96 (svn r1930) Cleaned up the postfix-ending connecting code and introduced some simple postfix-last-letter transformations when the ending first letter is 'i'.
pasky
parents: 1425
diff changeset
   502
			postlen = strlen(poststr);
0a215fc32f96 (svn r1930) Cleaned up the postfix-ending connecting code and introduced some simple postfix-last-letter transformations when the ending first letter is 'i'.
pasky
parents: 1425
diff changeset
   503
			endlen = strlen(endstr);
0a215fc32f96 (svn r1930) Cleaned up the postfix-ending connecting code and introduced some simple postfix-last-letter transformations when the ending first letter is 'i'.
pasky
parents: 1425
diff changeset
   504
			assert(postlen > 0 && endlen > 0);
0a215fc32f96 (svn r1930) Cleaned up the postfix-ending connecting code and introduced some simple postfix-last-letter transformations when the ending first letter is 'i'.
pasky
parents: 1425
diff changeset
   505
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   506
			// Kill the "avava" and "Jananna"-like cases
1473
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   507
			if (postlen < 2 || postlen > endlen || (
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   508
						(poststr[1] != 'v' || poststr[1] != endstr[1]) &&
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   509
						poststr[2] != endstr[1])
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   510
					) {
4321
b763b7007162 (svn r5974) -Codechange: added casts all around the place to make Windows 64bit happy (michi_cc)
truelight
parents: 4312
diff changeset
   511
				size_t buflen;
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   512
				strecat(buf, poststr, last);
1426
0a215fc32f96 (svn r1930) Cleaned up the postfix-ending connecting code and introduced some simple postfix-last-letter transformations when the ending first letter is 'i'.
pasky
parents: 1425
diff changeset
   513
				buflen = strlen(buf);
0a215fc32f96 (svn r1930) Cleaned up the postfix-ending connecting code and introduced some simple postfix-last-letter transformations when the ending first letter is 'i'.
pasky
parents: 1425
diff changeset
   514
0a215fc32f96 (svn r1930) Cleaned up the postfix-ending connecting code and introduced some simple postfix-last-letter transformations when the ending first letter is 'i'.
pasky
parents: 1425
diff changeset
   515
				// k-i -> c-i, h-i -> z-i
0a215fc32f96 (svn r1930) Cleaned up the postfix-ending connecting code and introduced some simple postfix-last-letter transformations when the ending first letter is 'i'.
pasky
parents: 1425
diff changeset
   516
				if (endstr[0] == 'i') {
1473
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   517
					switch (buf[buflen - 1]) {
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   518
						case 'k': buf[buflen - 1] = 'c'; break;
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   519
						case 'h': buf[buflen - 1] = 'z'; break;
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   520
						default: break;
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   521
					}
1426
0a215fc32f96 (svn r1930) Cleaned up the postfix-ending connecting code and introduced some simple postfix-last-letter transformations when the ending first letter is 'i'.
pasky
parents: 1425
diff changeset
   522
				}
0a215fc32f96 (svn r1930) Cleaned up the postfix-ending connecting code and introduced some simple postfix-last-letter transformations when the ending first letter is 'i'.
pasky
parents: 1425
diff changeset
   523
			}
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   524
		}
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   525
		strecat(buf, name_czech_subst_ending[ending].name, last);
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   526
	} else {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   527
		strecat(buf, name_czech_subst_full[stem].name, last);
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   528
	}
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   529
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   530
	if (do_suffix) {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   531
		strecat(buf, " ", last);
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   532
		strecat(buf, name_czech_suffix[suffix], last);
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   533
	}
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   534
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   535
	return 0;
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   536
}
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   537
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   538
static byte MakeRomanianTownName(char *buf, uint32 seed, const char *last)
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   539
{
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   540
	strecpy(buf, name_romanian_real[SeedChance(0, lengthof(name_romanian_real), seed)], last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   541
	return 0;
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   542
}
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   543
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   544
static byte MakeSlovakTownName(char *buf, uint32 seed, const char *last)
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   545
{
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   546
	strecpy(buf, name_slovak_real[SeedChance(0, lengthof(name_slovak_real), seed)], last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   547
	return 0;
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   548
}
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   549
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   550
static byte MakeNorwegianTownName(char *buf, uint32 seed, const char *last)
948
4b3f777634ab (svn r1438) Added norwegian townnames
miham
parents: 852
diff changeset
   551
{
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   552
	strecpy(buf, "", last);
958
f5ccffdadd48 (svn r1450) Updated norwegian townname generation (Simen Graaten)
miham
parents: 948
diff changeset
   553
f5ccffdadd48 (svn r1450) Updated norwegian townname generation (Simen Graaten)
miham
parents: 948
diff changeset
   554
	// Use first 4 bit from seed to decide whether or not this town should
f5ccffdadd48 (svn r1450) Updated norwegian townname generation (Simen Graaten)
miham
parents: 948
diff changeset
   555
	// have a real name 3/16 chance.  Bit 0-3
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
   556
	if (SeedChance(0, 15, seed) < 3) {
958
f5ccffdadd48 (svn r1450) Updated norwegian townname generation (Simen Graaten)
miham
parents: 948
diff changeset
   557
		// Use 7bit for the realname table index.  Bit 4-10
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   558
		strecat(buf, name_norwegian_real[SeedChance(4, lengthof(name_norwegian_real), seed)], last);
993
5ac6f569031e (svn r1491) Fix bracing style and indentation (Jango)
tron
parents: 992
diff changeset
   559
	} else {
958
f5ccffdadd48 (svn r1450) Updated norwegian townname generation (Simen Graaten)
miham
parents: 948
diff changeset
   560
		// Use 7bit for the first fake part.  Bit 4-10
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   561
		strecat(buf, name_norwegian_1[SeedChance(4, lengthof(name_norwegian_1), seed)], last);
958
f5ccffdadd48 (svn r1450) Updated norwegian townname generation (Simen Graaten)
miham
parents: 948
diff changeset
   562
		// Use 7bit for the last fake part.  Bit 11-17
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   563
		strecat(buf, name_norwegian_2[SeedChance(11, lengthof(name_norwegian_2), seed)], last);
958
f5ccffdadd48 (svn r1450) Updated norwegian townname generation (Simen Graaten)
miham
parents: 948
diff changeset
   564
	}
f5ccffdadd48 (svn r1450) Updated norwegian townname generation (Simen Graaten)
miham
parents: 948
diff changeset
   565
948
4b3f777634ab (svn r1438) Added norwegian townnames
miham
parents: 852
diff changeset
   566
	return 0;
4b3f777634ab (svn r1438) Added norwegian townnames
miham
parents: 852
diff changeset
   567
}
4b3f777634ab (svn r1438) Added norwegian townnames
miham
parents: 852
diff changeset
   568
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   569
static byte MakeHungarianTownName(char *buf, uint32 seed, const char *last)
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   570
{
959
b031d88c76f3 (svn r1451) Fix some of the signed/unsigned comparison warnings
tron
parents: 958
diff changeset
   571
	uint i;
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   572
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   573
	//null terminates the string for strcat
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   574
	strecpy(buf, "", last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   575
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
   576
	if (SeedChance(12, 15, seed) < 3) {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   577
		strecat(buf, name_hungarian_real[SeedChance(0, lengthof(name_hungarian_real), seed)], last);
993
5ac6f569031e (svn r1491) Fix bracing style and indentation (Jango)
tron
parents: 992
diff changeset
   578
	} else {
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   579
		// optional first segment
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
   580
		i = SeedChance(3, lengthof(name_hungarian_1) * 3, seed);
992
7ddeb6074c06 (svn r1490) Restore original town name generation behavior for german and hungarian (Jango)
tron
parents: 959
diff changeset
   581
		if (i < lengthof(name_hungarian_1))
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   582
			strecat(buf, name_hungarian_1[i], last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   583
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   584
		// mandatory middle segments
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   585
		strecat(buf, name_hungarian_2[SeedChance(3, lengthof(name_hungarian_2), seed)], last);
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   586
		strecat(buf, name_hungarian_3[SeedChance(6, lengthof(name_hungarian_3), seed)], last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   587
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   588
		// optional last segment
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
   589
		i = SeedChance(10, lengthof(name_hungarian_4) * 3, seed);
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
   590
		if (i < lengthof(name_hungarian_4)) {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   591
			strecat(buf, name_hungarian_4[i], last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   592
		}
4
cad62d5f9708 (svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents: 0
diff changeset
   593
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   594
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   595
	return 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   596
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   597
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   598
static byte MakeSwissTownName(char *buf, uint32 seed, const char *last)
1030
a5e4705a738c (svn r1531) -Feature: [1039061] Swiss town-names (vulvulune)
darkvater
parents: 996
diff changeset
   599
{
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   600
	strecpy(buf, name_swiss_real[SeedChance(0, lengthof(name_swiss_real), seed)], last);
1030
a5e4705a738c (svn r1531) -Feature: [1039061] Swiss town-names (vulvulune)
darkvater
parents: 996
diff changeset
   601
	return 0;
a5e4705a738c (svn r1531) -Feature: [1039061] Swiss town-names (vulvulune)
darkvater
parents: 996
diff changeset
   602
}
a5e4705a738c (svn r1531) -Feature: [1039061] Swiss town-names (vulvulune)
darkvater
parents: 996
diff changeset
   603
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   604
static byte MakeDanishTownName(char *buf, uint32 seed, const char *last)
2431
c720f620253e (svn r2957) - Feature: [ 1263280 ] Danish town names (fey_dk)
Darkvater
parents: 2186
diff changeset
   605
{
c720f620253e (svn r2957) - Feature: [ 1263280 ] Danish town names (fey_dk)
Darkvater
parents: 2186
diff changeset
   606
	int i;
c720f620253e (svn r2957) - Feature: [ 1263280 ] Danish town names (fey_dk)
Darkvater
parents: 2186
diff changeset
   607
c720f620253e (svn r2957) - Feature: [ 1263280 ] Danish town names (fey_dk)
Darkvater
parents: 2186
diff changeset
   608
	// null terminates the string for strcat
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   609
	strecpy(buf, "", last);
2431
c720f620253e (svn r2957) - Feature: [ 1263280 ] Danish town names (fey_dk)
Darkvater
parents: 2186
diff changeset
   610
c720f620253e (svn r2957) - Feature: [ 1263280 ] Danish town names (fey_dk)
Darkvater
parents: 2186
diff changeset
   611
	// optional first segment
c720f620253e (svn r2957) - Feature: [ 1263280 ] Danish town names (fey_dk)
Darkvater
parents: 2186
diff changeset
   612
	i = SeedChanceBias(0, lengthof(name_danish_1), seed, 50);
c720f620253e (svn r2957) - Feature: [ 1263280 ] Danish town names (fey_dk)
Darkvater
parents: 2186
diff changeset
   613
	if (i >= 0)
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   614
		strecat(buf, name_danish_1[i], last);
2431
c720f620253e (svn r2957) - Feature: [ 1263280 ] Danish town names (fey_dk)
Darkvater
parents: 2186
diff changeset
   615
c720f620253e (svn r2957) - Feature: [ 1263280 ] Danish town names (fey_dk)
Darkvater
parents: 2186
diff changeset
   616
	// middle segments removed as this algorithm seems to create much more realistic names
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   617
	strecat(buf, name_danish_2[SeedChance( 7, lengthof(name_danish_2), seed)], last);
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   618
	strecat(buf, name_danish_3[SeedChance(16, lengthof(name_danish_3), seed)], last);
2431
c720f620253e (svn r2957) - Feature: [ 1263280 ] Danish town names (fey_dk)
Darkvater
parents: 2186
diff changeset
   619
c720f620253e (svn r2957) - Feature: [ 1263280 ] Danish town names (fey_dk)
Darkvater
parents: 2186
diff changeset
   620
	return 0;
c720f620253e (svn r2957) - Feature: [ 1263280 ] Danish town names (fey_dk)
Darkvater
parents: 2186
diff changeset
   621
}
c720f620253e (svn r2957) - Feature: [ 1263280 ] Danish town names (fey_dk)
Darkvater
parents: 2186
diff changeset
   622
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   623
static byte MakeTurkishTownName(char *buf, uint32 seed, const char *last)
3698
3c584402327e (svn r4639) -Feature: Turkish town names (jnmbk)
celestar
parents: 3106
diff changeset
   624
{
3c584402327e (svn r4639) -Feature: Turkish town names (jnmbk)
celestar
parents: 3106
diff changeset
   625
	uint i;
3c584402327e (svn r4639) -Feature: Turkish town names (jnmbk)
celestar
parents: 3106
diff changeset
   626
3c584402327e (svn r4639) -Feature: Turkish town names (jnmbk)
celestar
parents: 3106
diff changeset
   627
	// null terminates the string for strcat
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   628
	strecpy(buf, "", last);
3698
3c584402327e (svn r4639) -Feature: Turkish town names (jnmbk)
celestar
parents: 3106
diff changeset
   629
3c584402327e (svn r4639) -Feature: Turkish town names (jnmbk)
celestar
parents: 3106
diff changeset
   630
	if ((i = SeedModChance(0, 5, seed)) == 0) {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   631
		strecat(buf, name_turkish_prefix[SeedModChance( 2, lengthof(name_turkish_prefix), seed)], last);
3698
3c584402327e (svn r4639) -Feature: Turkish town names (jnmbk)
celestar
parents: 3106
diff changeset
   632
3c584402327e (svn r4639) -Feature: Turkish town names (jnmbk)
celestar
parents: 3106
diff changeset
   633
		// middle segment
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   634
		strecat(buf, name_turkish_middle[SeedModChance( 4, lengthof(name_turkish_middle), seed)], last);
3698
3c584402327e (svn r4639) -Feature: Turkish town names (jnmbk)
celestar
parents: 3106
diff changeset
   635
3c584402327e (svn r4639) -Feature: Turkish town names (jnmbk)
celestar
parents: 3106
diff changeset
   636
		// optional suffix
3c584402327e (svn r4639) -Feature: Turkish town names (jnmbk)
celestar
parents: 3106
diff changeset
   637
		if (SeedModChance(0, 7, seed) == 0) {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   638
			strecat(buf, name_turkish_suffix[SeedModChance( 10, lengthof(name_turkish_suffix), seed)], last);
3698
3c584402327e (svn r4639) -Feature: Turkish town names (jnmbk)
celestar
parents: 3106
diff changeset
   639
		}
3c584402327e (svn r4639) -Feature: Turkish town names (jnmbk)
celestar
parents: 3106
diff changeset
   640
	} else {
3c584402327e (svn r4639) -Feature: Turkish town names (jnmbk)
celestar
parents: 3106
diff changeset
   641
		if (i == 1 || i == 2) {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   642
			strecat(buf, name_turkish_prefix[SeedModChance( 2, lengthof(name_turkish_prefix), seed)], last);
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   643
			strecat(buf, name_turkish_suffix[SeedModChance( 4, lengthof(name_turkish_suffix), seed)], last);
3698
3c584402327e (svn r4639) -Feature: Turkish town names (jnmbk)
celestar
parents: 3106
diff changeset
   644
		} else {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   645
			strecat(buf, name_turkish_real[SeedModChance( 4, lengthof(name_turkish_real), seed)], last);
3698
3c584402327e (svn r4639) -Feature: Turkish town names (jnmbk)
celestar
parents: 3106
diff changeset
   646
		}
3c584402327e (svn r4639) -Feature: Turkish town names (jnmbk)
celestar
parents: 3106
diff changeset
   647
	}
3c584402327e (svn r4639) -Feature: Turkish town names (jnmbk)
celestar
parents: 3106
diff changeset
   648
	return 0;
3c584402327e (svn r4639) -Feature: Turkish town names (jnmbk)
celestar
parents: 3106
diff changeset
   649
}
3c584402327e (svn r4639) -Feature: Turkish town names (jnmbk)
celestar
parents: 3106
diff changeset
   650
4148
7ea2ef7a6424 (svn r5512) Fix : Remove a warning on MakeItalianTownName.
belugas
parents: 4143
diff changeset
   651
static const char *mascul_femin_italian[] = {
7ea2ef7a6424 (svn r5512) Fix : Remove a warning on MakeItalianTownName.
belugas
parents: 4143
diff changeset
   652
	"o",
7ea2ef7a6424 (svn r5512) Fix : Remove a warning on MakeItalianTownName.
belugas
parents: 4143
diff changeset
   653
	"a",
7ea2ef7a6424 (svn r5512) Fix : Remove a warning on MakeItalianTownName.
belugas
parents: 4143
diff changeset
   654
};
7ea2ef7a6424 (svn r5512) Fix : Remove a warning on MakeItalianTownName.
belugas
parents: 4143
diff changeset
   655
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   656
static byte MakeItalianTownName(char *buf, uint32 seed, const char *last)
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   657
{
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   658
	strecpy(buf, "", last);
4143
5e6c2cfa6baa (svn r5504) Feature : Added Italian town name generator. (sidew)
belugas
parents: 4077
diff changeset
   659
4148
7ea2ef7a6424 (svn r5512) Fix : Remove a warning on MakeItalianTownName.
belugas
parents: 4143
diff changeset
   660
	if (SeedModChance(0, 6, seed) == 0) { // real city names
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   661
		strecat(buf, name_italian_real[SeedModChance(4, lengthof(name_italian_real), seed)], last);
4143
5e6c2cfa6baa (svn r5504) Feature : Added Italian town name generator. (sidew)
belugas
parents: 4077
diff changeset
   662
	} else {
4148
7ea2ef7a6424 (svn r5512) Fix : Remove a warning on MakeItalianTownName.
belugas
parents: 4143
diff changeset
   663
		uint i;
7ea2ef7a6424 (svn r5512) Fix : Remove a warning on MakeItalianTownName.
belugas
parents: 4143
diff changeset
   664
7ea2ef7a6424 (svn r5512) Fix : Remove a warning on MakeItalianTownName.
belugas
parents: 4143
diff changeset
   665
		if (SeedModChance(0, 8, seed) == 0) { // prefix
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   666
			strecat(buf, name_italian_pref[SeedModChance(11, lengthof(name_italian_pref), seed)], last);
4143
5e6c2cfa6baa (svn r5504) Feature : Added Italian town name generator. (sidew)
belugas
parents: 4077
diff changeset
   667
		}
5e6c2cfa6baa (svn r5504) Feature : Added Italian town name generator. (sidew)
belugas
parents: 4077
diff changeset
   668
4148
7ea2ef7a6424 (svn r5512) Fix : Remove a warning on MakeItalianTownName.
belugas
parents: 4143
diff changeset
   669
		i = SeedChance(0, 2, seed);
4143
5e6c2cfa6baa (svn r5504) Feature : Added Italian town name generator. (sidew)
belugas
parents: 4077
diff changeset
   670
		if (i == 0) { // masculine form
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   671
			strecat(buf, name_italian_1m[SeedModChance(4, lengthof(name_italian_1m), seed)], last);
4148
7ea2ef7a6424 (svn r5512) Fix : Remove a warning on MakeItalianTownName.
belugas
parents: 4143
diff changeset
   672
		} else { // feminine form
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   673
			strecat(buf, name_italian_1f[SeedModChance(4, lengthof(name_italian_1f), seed)], last);
4143
5e6c2cfa6baa (svn r5504) Feature : Added Italian town name generator. (sidew)
belugas
parents: 4077
diff changeset
   674
		}
5e6c2cfa6baa (svn r5504) Feature : Added Italian town name generator. (sidew)
belugas
parents: 4077
diff changeset
   675
4148
7ea2ef7a6424 (svn r5512) Fix : Remove a warning on MakeItalianTownName.
belugas
parents: 4143
diff changeset
   676
		if (SeedModChance(3, 3, seed) == 0) {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   677
			strecat(buf, name_italian_2[SeedModChance(11, lengthof(name_italian_2), seed)], last);
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   678
			strecat(buf,mascul_femin_italian[i], last);
4143
5e6c2cfa6baa (svn r5504) Feature : Added Italian town name generator. (sidew)
belugas
parents: 4077
diff changeset
   679
		} else {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   680
			strecat(buf, name_italian_2i[SeedModChance(16, lengthof(name_italian_2i), seed)], last);
4143
5e6c2cfa6baa (svn r5504) Feature : Added Italian town name generator. (sidew)
belugas
parents: 4077
diff changeset
   681
		}
5e6c2cfa6baa (svn r5504) Feature : Added Italian town name generator. (sidew)
belugas
parents: 4077
diff changeset
   682
5e6c2cfa6baa (svn r5504) Feature : Added Italian town name generator. (sidew)
belugas
parents: 4077
diff changeset
   683
		if (SeedModChance(15, 4, seed) == 0) {
4148
7ea2ef7a6424 (svn r5512) Fix : Remove a warning on MakeItalianTownName.
belugas
parents: 4143
diff changeset
   684
			if (SeedModChance(5, 2, seed) == 0) { // generic suffix
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   685
				strecat(buf, name_italian_3[SeedModChance(4, lengthof(name_italian_3), seed)], last);
4148
7ea2ef7a6424 (svn r5512) Fix : Remove a warning on MakeItalianTownName.
belugas
parents: 4143
diff changeset
   686
			} else { // river name suffix
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   687
				strecat(buf, name_italian_river1[SeedModChance(4, lengthof(name_italian_river1), seed)], last);
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   688
				strecat(buf, name_italian_river2[SeedModChance(16, lengthof(name_italian_river2), seed)], last);
4143
5e6c2cfa6baa (svn r5504) Feature : Added Italian town name generator. (sidew)
belugas
parents: 4077
diff changeset
   689
			}
5e6c2cfa6baa (svn r5504) Feature : Added Italian town name generator. (sidew)
belugas
parents: 4077
diff changeset
   690
		}
5e6c2cfa6baa (svn r5504) Feature : Added Italian town name generator. (sidew)
belugas
parents: 4077
diff changeset
   691
	}
5e6c2cfa6baa (svn r5504) Feature : Added Italian town name generator. (sidew)
belugas
parents: 4077
diff changeset
   692
5e6c2cfa6baa (svn r5504) Feature : Added Italian town name generator. (sidew)
belugas
parents: 4077
diff changeset
   693
	return 0;
5e6c2cfa6baa (svn r5504) Feature : Added Italian town name generator. (sidew)
belugas
parents: 4077
diff changeset
   694
}
5e6c2cfa6baa (svn r5504) Feature : Added Italian town name generator. (sidew)
belugas
parents: 4077
diff changeset
   695
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   696
static byte MakeCatalanTownName(char *buf, uint32 seed, const char *last)
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   697
{
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   698
	strecpy(buf, "", last);
4312
b5867bca34c1 (svn r5965) -Feature: FS#261 Catalan Town Names generator (arnau)
bjarni
parents: 4148
diff changeset
   699
b5867bca34c1 (svn r5965) -Feature: FS#261 Catalan Town Names generator (arnau)
bjarni
parents: 4148
diff changeset
   700
	if (SeedModChance(0, 3, seed) == 0) { // real city names
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   701
		strecat(buf, name_catalan_real[SeedModChance(4, lengthof(name_catalan_real), seed)], last);
4312
b5867bca34c1 (svn r5965) -Feature: FS#261 Catalan Town Names generator (arnau)
bjarni
parents: 4148
diff changeset
   702
	} else {
b5867bca34c1 (svn r5965) -Feature: FS#261 Catalan Town Names generator (arnau)
bjarni
parents: 4148
diff changeset
   703
		uint i;
4441
0365a1fc2116 (svn r6213) -Fix: Calatan town names was only prefix OR the rest of the string, never both (nars)
bjarni
parents: 4434
diff changeset
   704
4312
b5867bca34c1 (svn r5965) -Feature: FS#261 Catalan Town Names generator (arnau)
bjarni
parents: 4148
diff changeset
   705
		if (SeedModChance(0, 2, seed) == 0) { // prefix
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   706
			strecat(buf, name_catalan_pref[SeedModChance(11, lengthof(name_catalan_pref), seed)], last);
4312
b5867bca34c1 (svn r5965) -Feature: FS#261 Catalan Town Names generator (arnau)
bjarni
parents: 4148
diff changeset
   707
		}
4441
0365a1fc2116 (svn r6213) -Fix: Calatan town names was only prefix OR the rest of the string, never both (nars)
bjarni
parents: 4434
diff changeset
   708
0365a1fc2116 (svn r6213) -Fix: Calatan town names was only prefix OR the rest of the string, never both (nars)
bjarni
parents: 4434
diff changeset
   709
		i = SeedChance(0, 2, seed);
0365a1fc2116 (svn r6213) -Fix: Calatan town names was only prefix OR the rest of the string, never both (nars)
bjarni
parents: 4434
diff changeset
   710
		if (i == 0) { // masculine form
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   711
			strecat(buf, name_catalan_1m[SeedModChance(4, lengthof(name_catalan_1m), seed)], last);
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   712
			strecat(buf, name_catalan_2m[SeedModChance(11, lengthof(name_catalan_2m), seed)], last);
4441
0365a1fc2116 (svn r6213) -Fix: Calatan town names was only prefix OR the rest of the string, never both (nars)
bjarni
parents: 4434
diff changeset
   713
		} else { // feminine form
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   714
			strecat(buf, name_catalan_1f[SeedModChance(4, lengthof(name_catalan_1f), seed)], last);
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   715
			strecat(buf, name_catalan_2f[SeedModChance(11, lengthof(name_catalan_2f), seed)], last);
4441
0365a1fc2116 (svn r6213) -Fix: Calatan town names was only prefix OR the rest of the string, never both (nars)
bjarni
parents: 4434
diff changeset
   716
		}
4312
b5867bca34c1 (svn r5965) -Feature: FS#261 Catalan Town Names generator (arnau)
bjarni
parents: 4148
diff changeset
   717
b5867bca34c1 (svn r5965) -Feature: FS#261 Catalan Town Names generator (arnau)
bjarni
parents: 4148
diff changeset
   718
4441
0365a1fc2116 (svn r6213) -Fix: Calatan town names was only prefix OR the rest of the string, never both (nars)
bjarni
parents: 4434
diff changeset
   719
		if (SeedModChance(15, 5, seed) == 0) {
0365a1fc2116 (svn r6213) -Fix: Calatan town names was only prefix OR the rest of the string, never both (nars)
bjarni
parents: 4434
diff changeset
   720
			if (SeedModChance(5, 2, seed) == 0) { // generic suffix
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   721
				strecat(buf, name_catalan_3[SeedModChance(4, lengthof(name_catalan_3), seed)], last);
4441
0365a1fc2116 (svn r6213) -Fix: Calatan town names was only prefix OR the rest of the string, never both (nars)
bjarni
parents: 4434
diff changeset
   722
			} else { // river name suffix
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   723
				strecat(buf, name_catalan_river1[SeedModChance(4, lengthof(name_catalan_river1), seed)], last);
4312
b5867bca34c1 (svn r5965) -Feature: FS#261 Catalan Town Names generator (arnau)
bjarni
parents: 4148
diff changeset
   724
			}
b5867bca34c1 (svn r5965) -Feature: FS#261 Catalan Town Names generator (arnau)
bjarni
parents: 4148
diff changeset
   725
		}
b5867bca34c1 (svn r5965) -Feature: FS#261 Catalan Town Names generator (arnau)
bjarni
parents: 4148
diff changeset
   726
	}
b5867bca34c1 (svn r5965) -Feature: FS#261 Catalan Town Names generator (arnau)
bjarni
parents: 4148
diff changeset
   727
b5867bca34c1 (svn r5965) -Feature: FS#261 Catalan Town Names generator (arnau)
bjarni
parents: 4148
diff changeset
   728
	return 0;
b5867bca34c1 (svn r5965) -Feature: FS#261 Catalan Town Names generator (arnau)
bjarni
parents: 4148
diff changeset
   729
}
b5867bca34c1 (svn r5965) -Feature: FS#261 Catalan Town Names generator (arnau)
bjarni
parents: 4148
diff changeset
   730
b5867bca34c1 (svn r5965) -Feature: FS#261 Catalan Town Names generator (arnau)
bjarni
parents: 4148
diff changeset
   731
b5867bca34c1 (svn r5965) -Feature: FS#261 Catalan Town Names generator (arnau)
bjarni
parents: 4148
diff changeset
   732
993
5ac6f569031e (svn r1491) Fix bracing style and indentation (Jango)
tron
parents: 992
diff changeset
   733
TownNameGenerator * const _town_name_generators[] =
5ac6f569031e (svn r1491) Fix bracing style and indentation (Jango)
tron
parents: 992
diff changeset
   734
{
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   735
	MakeEnglishOriginalTownName,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   736
	MakeFrenchTownName,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   737
	MakeGermanTownName,
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   738
	MakeEnglishAdditionalTownName,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   739
	MakeSpanishTownName,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   740
	MakeSillyTownName,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   741
	MakeSwedishTownName,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   742
	MakeDutchTownName,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   743
	MakeFinnishTownName,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   744
	MakePolishTownName,
428
532ec9578634 (svn r627) Merge r439 to trunk:
tron
parents: 264
diff changeset
   745
	MakeSlovakTownName,
948
4b3f777634ab (svn r1438) Added norwegian townnames
miham
parents: 852
diff changeset
   746
	MakeNorwegianTownName,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   747
	MakeHungarianTownName,
233
dd177a8c9f19 (svn r234) -Fix: added missing romanian.txt to VC6, VS.NET and Jamfile project file
darkvater
parents: 193
diff changeset
   748
	MakeAustrianTownName,
264
38396861c501 (svn r270) Fix: [ 1028851 ] automatic and unwanted city renaming
dominik
parents: 240
diff changeset
   749
	MakeRomanianTownName,
38396861c501 (svn r270) Fix: [ 1028851 ] automatic and unwanted city renaming
dominik
parents: 240
diff changeset
   750
	MakeCzechTownName,
1030
a5e4705a738c (svn r1531) -Feature: [1039061] Swiss town-names (vulvulune)
darkvater
parents: 996
diff changeset
   751
	MakeSwissTownName,
2431
c720f620253e (svn r2957) - Feature: [ 1263280 ] Danish town names (fey_dk)
Darkvater
parents: 2186
diff changeset
   752
	MakeDanishTownName,
3698
3c584402327e (svn r4639) -Feature: Turkish town names (jnmbk)
celestar
parents: 3106
diff changeset
   753
	MakeTurkishTownName,
4143
5e6c2cfa6baa (svn r5504) Feature : Added Italian town name generator. (sidew)
belugas
parents: 4077
diff changeset
   754
	MakeItalianTownName,
4312
b5867bca34c1 (svn r5965) -Feature: FS#261 Catalan Town Names generator (arnau)
bjarni
parents: 4148
diff changeset
   755
	MakeCatalanTownName,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   756
};
4
cad62d5f9708 (svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents: 0
diff changeset
   757
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   758
// DO WE NEED THIS ANY MORE?
4
cad62d5f9708 (svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents: 0
diff changeset
   759
#define FIXNUM(x, y, z) (((((x) << 16) / (y)) + 1) << z)
cad62d5f9708 (svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents: 0
diff changeset
   760
cad62d5f9708 (svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents: 0
diff changeset
   761
uint32 GetOldTownName(uint32 townnameparts, byte old_town_name_type)
cad62d5f9708 (svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents: 0
diff changeset
   762
{
cad62d5f9708 (svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents: 0
diff changeset
   763
	switch (old_town_name_type) {
cad62d5f9708 (svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents: 0
diff changeset
   764
		case 0: case 3: /* English, American */
4434
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4321
diff changeset
   765
			/* Already OK */
4
cad62d5f9708 (svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents: 0
diff changeset
   766
			return townnameparts;
993
5ac6f569031e (svn r1491) Fix bracing style and indentation (Jango)
tron
parents: 992
diff changeset
   767
4
cad62d5f9708 (svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents: 0
diff changeset
   768
		case 1: /* French */
4434
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4321
diff changeset
   769
			/* For some reason 86 needs to be subtracted from townnameparts
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4321
diff changeset
   770
			 * 0000 0000 0000 0000 0000 0000 1111 1111 */
1422
c3bc75035658 (svn r1926) Codechange: Renamed some of the predefined town names arrays for consistent naming.
pasky
parents: 1307
diff changeset
   771
			return FIXNUM(townnameparts - 86, lengthof(name_french_real), 0);
993
5ac6f569031e (svn r1491) Fix bracing style and indentation (Jango)
tron
parents: 992
diff changeset
   772
4
cad62d5f9708 (svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents: 0
diff changeset
   773
		case 2: /* German */
65
f9f866bc609c (svn r66) -Fix Station list updated on station deletion/station rename
darkvater
parents: 8
diff changeset
   774
			DEBUG(misc, 0) ("German Townnames are buggy... (%d)", townnameparts);
4
cad62d5f9708 (svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents: 0
diff changeset
   775
			return townnameparts;
993
5ac6f569031e (svn r1491) Fix bracing style and indentation (Jango)
tron
parents: 992
diff changeset
   776
4
cad62d5f9708 (svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents: 0
diff changeset
   777
		case 4: /* Latin-American */
4434
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4321
diff changeset
   778
			/* 0000 0000 0000 0000 0000 0000 1111 1111 */
1422
c3bc75035658 (svn r1926) Codechange: Renamed some of the predefined town names arrays for consistent naming.
pasky
parents: 1307
diff changeset
   779
			return FIXNUM(townnameparts, lengthof(name_spanish_real), 0);
993
5ac6f569031e (svn r1491) Fix bracing style and indentation (Jango)
tron
parents: 992
diff changeset
   780
4
cad62d5f9708 (svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents: 0
diff changeset
   781
		case 5: /* Silly */
4434
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4321
diff changeset
   782
			/* NUM_SILLY_1 - lower 16 bits
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4321
diff changeset
   783
			 * NUM_SILLY_2 - upper 16 bits without leading 1 (first 8 bytes)
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4321
diff changeset
   784
			 * 1000 0000 2222 2222 0000 0000 1111 1111 */
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2484
diff changeset
   785
			return FIXNUM(townnameparts, lengthof(name_silly_1), 0) | FIXNUM(GB(townnameparts, 16, 8), lengthof(name_silly_2), 16);
4
cad62d5f9708 (svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents: 0
diff changeset
   786
	}
cad62d5f9708 (svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents: 0
diff changeset
   787
	return 0;
cad62d5f9708 (svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents: 0
diff changeset
   788
}