src/namegen.cpp
author KUDr
Sat, 21 Apr 2007 08:23:57 +0000
branchcpp_gui
changeset 6308 646711c5feaa
parent 6303 84c215fc8eb8
child 6872 1c4a4a609f85
child 9723 eee46cb39750
permissions -rw-r--r--
(svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
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
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
     3
/** @file namegen.cpp */
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "stdafx.h"
1891
92a3b0aa0946 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1473
diff changeset
     6
#include "openttd.h"
1299
0a6510cc889b (svn r1803) Move debugging stuff into files of it's own
tron
parents: 1109
diff changeset
     7
#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
     8
#include "macros.h"
1306
40038dfdf3ba (svn r1810) Move town name generation declarations into a header of their own
tron
parents: 1299
diff changeset
     9
#include "namegen.h"
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
    10
#include "table/namegen.h"
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
    11
#include "string.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    12
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
    13
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
    14
{
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
    15
	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
    16
}
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
    17
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
    18
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
    19
{
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
	/* 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
    21
	 * 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
    22
	 * 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
    23
	 * 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
    24
	 * 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
    25
	 * 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
    26
	 * 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
    27
	 * --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
    28
	// 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
    29
	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
    30
}
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
    31
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
    32
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
    33
{
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
    34
	return SeedChance(shift_by, max + bias, seed) - bias;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    35
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    36
1109
1bab892228cd (svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents: 1107
diff changeset
    37
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
    38
{
1107
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
    39
	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
    40
}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    41
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
    42
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
    43
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    44
	int i;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    45
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
    46
	/* 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
    47
	strecpy(buf, "", last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    48
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
    49
	/* optional first segment */
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
    50
	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
    51
	if (i >= 0)
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
    52
		strecat(buf, name_original_english_1[i], last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    53
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
    54
	/* mandatory middle segments */
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
    55
	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
    56
	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
    57
	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
    58
	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
    59
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
    60
	/* optional last segment */
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
    61
	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
    62
	if (i >= 0)
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
    63
		strecat(buf, name_original_english_6[i], last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    64
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
    65
	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
    66
		buf[0] = 'K';
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
    67
1107
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
    68
	ReplaceWords("Cunt", "East", buf);
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
    69
	ReplaceWords("Slag", "Pits", buf);
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
    70
	ReplaceWords("Slut", "Edin", buf);
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
    71
	//ReplaceWords("Fart", "Boot", buf);
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
    72
	ReplaceWords("Drar", "Quar", buf);
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
    73
	ReplaceWords("Dreh", "Bash", buf);
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
    74
	ReplaceWords("Frar", "Shor", buf);
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
    75
	ReplaceWords("Grar", "Aber", buf);
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
    76
	ReplaceWords("Brar", "Over", buf);
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
    77
	ReplaceWords("Wrar", "Inve", buf);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
    78
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
    79
	return 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    80
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    81
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    82
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
    83
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
    84
{
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
    85
	int i;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    86
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
    87
	/* 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
    88
	strecpy(buf, "", last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    89
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
    90
	/* optional first segment */
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
    91
	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
    92
	if (i >= 0)
6308
646711c5feaa (svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
KUDr
parents: 6303
diff changeset
    93
		strecat(buf, name_additional_english_prefix[i], last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    94
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
    95
	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
    96
		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
    97
	} else {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
    98
		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
    99
		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
   100
		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
   101
			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
   102
		} else {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   103
			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
   104
		}
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   105
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   106
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   107
	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
   108
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   109
	/* optional last segment */
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
   110
	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
   111
	if (i >= 0)
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   112
		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
   113
1107
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
   114
	ReplaceWords("Cunt", "East", buf);
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
   115
	ReplaceWords("Slag", "Pits", buf);
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
   116
	ReplaceWords("Slut", "Edin", buf);
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
   117
	ReplaceWords("Fart", "Boot", buf);
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
   118
	ReplaceWords("Drar", "Quar", buf);
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
   119
	ReplaceWords("Dreh", "Bash", buf);
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
   120
	ReplaceWords("Frar", "Shor", buf);
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
   121
	ReplaceWords("Grar", "Aber", buf);
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
   122
	ReplaceWords("Brar", "Over", buf);
29c55f462a18 (svn r1608) Make ReplaceWords() comprehensible
tron
parents: 1030
diff changeset
   123
	ReplaceWords("Wrar", "Stan", buf);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   124
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   125
	return 0;
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   126
}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   127
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   128
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
   129
{
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   130
	int i, j = 0;
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   131
	strecpy(buf, "", last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   132
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   133
	/* Bad, Maria, Gross, ... */
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
   134
	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
   135
	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
   136
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
   137
	i = SeedChance(4, 6, seed);
993
5ac6f569031e (svn r1491) Fix bracing style and indentation (Jango)
tron
parents: 992
diff changeset
   138
	if (i >= 4) {
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   139
		/* Kaisers-kirchen */
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   140
		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
   141
		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
   142
	} else if (i >= 2) {
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   143
		/* St. Johann */
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   144
		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
   145
		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
   146
		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
   147
	} else {
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   148
		/* Zell */
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   149
		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
   150
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   151
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
   152
	i = SeedChance(1, 6, seed);
993
5ac6f569031e (svn r1491) Fix bracing style and indentation (Jango)
tron
parents: 992
diff changeset
   153
	if (i >= 4 - j) {
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   154
		/* an der Donau (rivers) */
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   155
		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
   156
		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
   157
	} else if (i >= 2 - j) {
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   158
		/* am Dachstein (mountains) */
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   159
		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
   160
		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
   161
	}
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
	return 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   164
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   165
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   166
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
   167
{
992
7ddeb6074c06 (svn r1490) Restore original town name generation behavior for german and hungarian (Jango)
tron
parents: 959
diff changeset
   168
	uint i;
7ddeb6074c06 (svn r1490) Restore original town name generation behavior for german and hungarian (Jango)
tron
parents: 959
diff changeset
   169
	uint seed_derivative;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   170
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   171
	/* 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
   172
	strecpy(buf, "", last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   173
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
   174
	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
   175
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   176
	/* optional prefix */
992
7ddeb6074c06 (svn r1490) Restore original town name generation behavior for german and hungarian (Jango)
tron
parents: 959
diff changeset
   177
	if (seed_derivative == 12 || seed_derivative == 19) {
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
   178
		i = SeedChance(2, lengthof(name_german_pre), seed);
6308
646711c5feaa (svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
KUDr
parents: 6303
diff changeset
   179
		strecat(buf, name_german_pre[i], last);
4
cad62d5f9708 (svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents: 0
diff changeset
   180
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   181
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   182
	/* 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
   183
	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
   184
	if (i < lengthof(name_german_real)) {
6308
646711c5feaa (svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
KUDr
parents: 6303
diff changeset
   185
		strecat(buf, name_german_real[i], last);
993
5ac6f569031e (svn r1491) Fix bracing style and indentation (Jango)
tron
parents: 992
diff changeset
   186
	} else {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   187
		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
   188
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
   189
		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
   190
		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
   191
	}
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   192
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   193
	/* optional suffix */
992
7ddeb6074c06 (svn r1490) Restore original town name generation behavior for german and hungarian (Jango)
tron
parents: 959
diff changeset
   194
	if (seed_derivative == 24) {
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
   195
		i = SeedChance(9,
992
7ddeb6074c06 (svn r1490) Restore original town name generation behavior for german and hungarian (Jango)
tron
parents: 959
diff changeset
   196
			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
   197
		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
   198
			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
   199
			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
   200
		} else {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   201
			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
   202
			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
   203
		}
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   204
	}
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   205
	return 0;
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   206
}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   207
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   208
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
   209
{
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   210
	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
   211
	return 0;
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   212
}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   213
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   214
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
   215
{
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   216
	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
   217
	return 0;
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   218
}
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
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
   221
{
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   222
	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
   223
	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
   224
	return 0;
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   225
}
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   226
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   227
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
   228
{
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   229
	int i;
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   230
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   231
	/* 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
   232
	strecpy(buf, "", last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   233
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   234
	/* optional first segment */
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
   235
	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
   236
	if (i >= 0)
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   237
		strecat(buf, name_swedish_1[i], last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   238
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   239
	/* 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
   240
	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
   241
		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
   242
	} else {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   243
		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
   244
		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
   245
		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
   246
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   247
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   248
	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
   249
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   250
	return 0;
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   251
}
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   252
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   253
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
   254
{
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   255
	int i;
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   256
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   257
	/* 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
   258
	strecpy(buf, "", last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   259
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   260
	/* optional first segment */
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
   261
	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
   262
	if (i >= 0)
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   263
		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
   264
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   265
	/* 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
   266
	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
   267
		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
   268
	} else {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   269
		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
   270
		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
   271
	}
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   272
	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
   273
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   274
	return 0;
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   275
}
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   276
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   277
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
   278
{
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   279
	/* 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
   280
	strecpy(buf, "", last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   281
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   282
	/* 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
   283
	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
   284
		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
   285
	} else if (SeedChance(0, 15, seed) >= 5) {
6308
646711c5feaa (svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
KUDr
parents: 6303
diff changeset
   286
		/* A two-part name by combining one of name_finnish_1 + "la"/"lä"
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   287
		 * The reason for not having the contents of name_finnish_{1,2} in the same table is
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   288
		 * 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
   289
		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
   290
		char *end;
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   291
		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
   292
		end = &buf[strlen(buf)-1];
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   293
		if (*end == 'i')
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   294
			*end = 'e';
3106
ac231bc8e06a (svn r3707) -Fix: made the generated Finnish town names sound more Finnish (ln-)
bjarni
parents: 2549
diff changeset
   295
		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
   296
			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
   297
		{
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   298
			strecat(buf, "la", last);
3106
ac231bc8e06a (svn r3707) -Fix: made the generated Finnish town names sound more Finnish (ln-)
bjarni
parents: 2549
diff changeset
   299
		} else {
6308
646711c5feaa (svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
KUDr
parents: 6303
diff changeset
   300
			strecat(buf, "lä", last);
3106
ac231bc8e06a (svn r3707) -Fix: made the generated Finnish town names sound more Finnish (ln-)
bjarni
parents: 2549
diff changeset
   301
		}
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3698
diff changeset
   302
	} else {
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   303
		/* A two-part name by combining one of name_finnish_{1,2} + name_finnish_3.
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   304
		 * 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
   305
		uint sel = SeedChance(2,
ac231bc8e06a (svn r3707) -Fix: made the generated Finnish town names sound more Finnish (ln-)
bjarni
parents: 2549
diff changeset
   306
			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
   307
		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
   308
			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
   309
		} else {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   310
			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
   311
		}
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   312
		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
   313
	}
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
	return 0;
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   316
}
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   317
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   318
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
   319
{
959
b031d88c76f3 (svn r1451) Fix some of the signed/unsigned comparison warnings
tron
parents: 958
diff changeset
   320
	uint i;
b031d88c76f3 (svn r1451) Fix some of the signed/unsigned comparison warnings
tron
parents: 958
diff changeset
   321
	uint j;
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   322
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   323
	/* 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
   324
	strecpy(buf, "", last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   325
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   326
	/* optional first segment */
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
   327
	i = SeedChance(0,
993
5ac6f569031e (svn r1491) Fix bracing style and indentation (Jango)
tron
parents: 992
diff changeset
   328
		lengthof(name_polish_2_o) + lengthof(name_polish_2_m) +
5ac6f569031e (svn r1491) Fix bracing style and indentation (Jango)
tron
parents: 992
diff changeset
   329
		lengthof(name_polish_2_f) + lengthof(name_polish_2_n),
5ac6f569031e (svn r1491) Fix bracing style and indentation (Jango)
tron
parents: 992
diff changeset
   330
		seed);
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
   331
	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
   332
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   333
993
5ac6f569031e (svn r1491) Fix bracing style and indentation (Jango)
tron
parents: 992
diff changeset
   334
	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
   335
		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
   336
	} 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
   337
		if (j < 4)
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   338
			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
   339
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   340
		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
   341
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   342
		if (j >= 4 && j < 16)
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   343
			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
   344
	} 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
   345
		if (j < 4)
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   346
			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
   347
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   348
		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
   349
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   350
		if (j >= 4 && j < 16)
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   351
			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
   352
	} else {
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   353
		if (j < 4)
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   354
			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
   355
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   356
		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
   357
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   358
		if (j >= 4 && j < 16)
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   359
			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
   360
	}
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   361
	return 0;
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   362
}
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   363
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   364
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
   365
{
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   366
	/* Probability of prefixes/suffixes */
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   367
	/* 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
   368
	int prob_tails;
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   369
	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
   370
	/* IDs of the respective parts */
1473
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   371
	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
   372
	uint postfix = 0;
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   373
	uint stem;
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   374
	/* The select criteria. */
1473
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   375
	CzechGender gender;
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   376
	CzechChoose choose;
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   377
	CzechAllow allow;
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   378
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   379
	/* 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
   380
	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
   381
		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
   382
		return 0;
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   383
	}
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   384
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   385
	/* 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
   386
	strecpy(buf, "", last);
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   387
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
   388
	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
   389
	do_prefix = prob_tails < 12;
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   390
	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
   391
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
   392
	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
   393
	if (do_suffix) suffix = SeedModChance(7, lengthof(name_czech_suffix), seed);
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   394
	/* 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
   395
	stem = SeedModChance(9,
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   396
		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
   397
		seed);
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   398
	if (stem < lengthof(name_czech_subst_full)) {
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   399
		/* That was easy! */
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   400
		dynamic_subst = false;
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   401
		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
   402
		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
   403
		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
   404
	} else {
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   405
		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
   406
		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
   407
		int i;
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   408
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   409
		/* Load the substantive */
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   410
		dynamic_subst = true;
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   411
		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
   412
		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
   413
		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
   414
		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
   415
		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
   416
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   417
		/* 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
   418
		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
   419
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   420
		if (choose & CZC_POSTFIX) {
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   421
			/* Always get a real postfix. */
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   422
			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
   423
		}
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   424
		if (choose & CZC_NOPOSTFIX) {
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   425
			/* Always drop a postfix. */
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   426
			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
   427
		}
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3698
diff changeset
   428
		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
   429
			choose |= CZC_POSTFIX;
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3698
diff changeset
   430
		} else {
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   431
			choose |= CZC_NOPOSTFIX;
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 3698
diff changeset
   432
		}
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   433
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   434
		/* Localize the array segment containing a good gender */
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   435
		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
   436
			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
   437
1473
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   438
			if (gender == CZG_FREE ||
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   439
					(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
   440
					gender == e->gender) {
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   441
				if (ending_start < 0)
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   442
					ending_start = ending;
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   443
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   444
			} else if (ending_start >= 0) {
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   445
				ending_stop = ending - 1;
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   446
				break;
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   447
			}
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   448
		}
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   449
		if (ending_stop < 0) {
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   450
			/* Whoa. All the endings matched. */
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   451
			ending_stop = ending - 1;
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   452
		}
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   453
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   454
		/* Make a sequential map of the items with good mask */
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   455
		i = 0;
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   456
		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
   457
			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
   458
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   459
			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
   460
				map[i++] = ending;
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
		assert(i > 0);
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   463
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   464
		/* 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
   465
		ending = map[SeedModChance(16, i, seed)];
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   466
		/* Override possible CZG_*FREE; this must be a real gender,
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   467
		 * otherwise we get overflow when modifying the adjectivum. */
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   468
		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
   469
		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
   470
	}
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   471
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   472
	if (do_prefix && (name_czech_adj[prefix].choose & choose) != choose) {
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   473
		/* Throw away non-matching prefix. */
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   474
		do_prefix = false;
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   475
	}
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   476
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   477
	/* Now finally construct the name */
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   478
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   479
	if (do_prefix) {
1473
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   480
		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
   481
		size_t endpos;
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   482
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   483
		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
   484
		endpos = strlen(buf) - 1;
5108
dc67d70b5a45 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 4919
diff changeset
   485
		/* Find the first character in a UTF-8 sequence */
dc67d70b5a45 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 4919
diff changeset
   486
		while (GB(buf[endpos], 6, 2) == 2) endpos--;
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   487
		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
   488
			/* -ovX -> -uv */
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   489
			buf[endpos - 2] = 'u';
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   490
			assert(buf[endpos - 1] == 'v');
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   491
			buf[endpos] = '\0';
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   492
		} else {
5108
dc67d70b5a45 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 4919
diff changeset
   493
			strecpy(buf + endpos, name_czech_patmod[gender][pattern], last);
1425
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
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   496
		strecat(buf, " ", last);
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   497
	}
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   498
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   499
	if (dynamic_subst) {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   500
		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
   501
		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
   502
			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
   503
			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
   504
			size_t postlen, endlen;
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   505
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
   506
			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
   507
			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
   508
			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
   509
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   510
			/* 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
   511
			if (postlen < 2 || postlen > endlen || (
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   512
						(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
   513
						poststr[2] != endstr[1])
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   514
					) {
4321
b763b7007162 (svn r5974) -Codechange: added casts all around the place to make Windows 64bit happy (michi_cc)
truelight
parents: 4312
diff changeset
   515
				size_t buflen;
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   516
				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
   517
				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
   518
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   519
				/* k-i -> c-i, h-i -> z-i */
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
   520
				if (endstr[0] == 'i') {
1473
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   521
					switch (buf[buflen - 1]) {
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   522
						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
   523
						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
   524
						default: break;
4be673c6c994 (svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents: 1447
diff changeset
   525
					}
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
   526
				}
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
   527
			}
1425
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   528
		}
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   529
		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
   530
	} else {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   531
		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
   532
	}
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
	if (do_suffix) {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   535
		strecat(buf, " ", last);
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   536
		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
   537
	}
d566470aa3ca (svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents: 1422
diff changeset
   538
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   539
	return 0;
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   540
}
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   541
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   542
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
   543
{
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   544
	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
   545
	return 0;
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   546
}
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   547
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   548
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
   549
{
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   550
	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
   551
	return 0;
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   552
}
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   553
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   554
static byte MakeNorwegianTownName(char *buf, uint32 seed, const char *last)
948
4b3f777634ab (svn r1438) Added norwegian townnames
miham
parents: 852
diff changeset
   555
{
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   556
	strecpy(buf, "", last);
958
f5ccffdadd48 (svn r1450) Updated norwegian townname generation (Simen Graaten)
miham
parents: 948
diff changeset
   557
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   558
	/* Use first 4 bit from seed to decide whether or not this town should
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   559
	 * 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
   560
	if (SeedChance(0, 15, seed) < 3) {
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   561
		/* 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
   562
		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
   563
	} else {
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   564
		/* 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
   565
		strecat(buf, name_norwegian_1[SeedChance(4, lengthof(name_norwegian_1), seed)], last);
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   566
		/* 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
   567
		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
   568
	}
f5ccffdadd48 (svn r1450) Updated norwegian townname generation (Simen Graaten)
miham
parents: 948
diff changeset
   569
948
4b3f777634ab (svn r1438) Added norwegian townnames
miham
parents: 852
diff changeset
   570
	return 0;
4b3f777634ab (svn r1438) Added norwegian townnames
miham
parents: 852
diff changeset
   571
}
4b3f777634ab (svn r1438) Added norwegian townnames
miham
parents: 852
diff changeset
   572
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   573
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
   574
{
959
b031d88c76f3 (svn r1451) Fix some of the signed/unsigned comparison warnings
tron
parents: 958
diff changeset
   575
	uint i;
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   576
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   577
	/* 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
   578
	strecpy(buf, "", last);
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   579
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
   580
	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
   581
		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
   582
	} else {
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   583
		/* optional first segment */
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
   584
		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
   585
		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
   586
			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
   587
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   588
		/* mandatory middle segments */
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   589
		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
   590
		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
   591
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   592
		/* optional last segment */
996
3cdb8dbb5c2f (svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents: 994
diff changeset
   593
		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
   594
		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
   595
			strecat(buf, name_hungarian_4[i], last);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   596
		}
4
cad62d5f9708 (svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents: 0
diff changeset
   597
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   598
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   599
	return 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   600
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   601
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   602
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
   603
{
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   604
	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
   605
	return 0;
a5e4705a738c (svn r1531) -Feature: [1039061] Swiss town-names (vulvulune)
darkvater
parents: 996
diff changeset
   606
}
a5e4705a738c (svn r1531) -Feature: [1039061] Swiss town-names (vulvulune)
darkvater
parents: 996
diff changeset
   607
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   608
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
   609
{
c720f620253e (svn r2957) - Feature: [ 1263280 ] Danish town names (fey_dk)
Darkvater
parents: 2186
diff changeset
   610
	int i;
c720f620253e (svn r2957) - Feature: [ 1263280 ] Danish town names (fey_dk)
Darkvater
parents: 2186
diff changeset
   611
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   612
	/* 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
   613
	strecpy(buf, "", last);
2431
c720f620253e (svn r2957) - Feature: [ 1263280 ] Danish town names (fey_dk)
Darkvater
parents: 2186
diff changeset
   614
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   615
	/* optional first segment */
2431
c720f620253e (svn r2957) - Feature: [ 1263280 ] Danish town names (fey_dk)
Darkvater
parents: 2186
diff changeset
   616
	i = SeedChanceBias(0, lengthof(name_danish_1), seed, 50);
c720f620253e (svn r2957) - Feature: [ 1263280 ] Danish town names (fey_dk)
Darkvater
parents: 2186
diff changeset
   617
	if (i >= 0)
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   618
		strecat(buf, name_danish_1[i], last);
2431
c720f620253e (svn r2957) - Feature: [ 1263280 ] Danish town names (fey_dk)
Darkvater
parents: 2186
diff changeset
   619
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   620
	/* 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
   621
	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
   622
	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
   623
c720f620253e (svn r2957) - Feature: [ 1263280 ] Danish town names (fey_dk)
Darkvater
parents: 2186
diff changeset
   624
	return 0;
c720f620253e (svn r2957) - Feature: [ 1263280 ] Danish town names (fey_dk)
Darkvater
parents: 2186
diff changeset
   625
}
c720f620253e (svn r2957) - Feature: [ 1263280 ] Danish town names (fey_dk)
Darkvater
parents: 2186
diff changeset
   626
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   627
static byte MakeTurkishTownName(char *buf, uint32 seed, const char *last)
3698
3c584402327e (svn r4639) -Feature: Turkish town names (jnmbk)
celestar
parents: 3106
diff changeset
   628
{
3c584402327e (svn r4639) -Feature: Turkish town names (jnmbk)
celestar
parents: 3106
diff changeset
   629
	uint i;
3c584402327e (svn r4639) -Feature: Turkish town names (jnmbk)
celestar
parents: 3106
diff changeset
   630
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   631
	/* 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
   632
	strecpy(buf, "", last);
3698
3c584402327e (svn r4639) -Feature: Turkish town names (jnmbk)
celestar
parents: 3106
diff changeset
   633
3c584402327e (svn r4639) -Feature: Turkish town names (jnmbk)
celestar
parents: 3106
diff changeset
   634
	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
   635
		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
   636
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   637
		/* middle segment */
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   638
		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
   639
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   640
		/* optional suffix */
3698
3c584402327e (svn r4639) -Feature: Turkish town names (jnmbk)
celestar
parents: 3106
diff changeset
   641
		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
   642
			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
   643
		}
3c584402327e (svn r4639) -Feature: Turkish town names (jnmbk)
celestar
parents: 3106
diff changeset
   644
	} else {
3c584402327e (svn r4639) -Feature: Turkish town names (jnmbk)
celestar
parents: 3106
diff changeset
   645
		if (i == 1 || i == 2) {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   646
			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
   647
			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
   648
		} else {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   649
			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
   650
		}
3c584402327e (svn r4639) -Feature: Turkish town names (jnmbk)
celestar
parents: 3106
diff changeset
   651
	}
3c584402327e (svn r4639) -Feature: Turkish town names (jnmbk)
celestar
parents: 3106
diff changeset
   652
	return 0;
3c584402327e (svn r4639) -Feature: Turkish town names (jnmbk)
celestar
parents: 3106
diff changeset
   653
}
3c584402327e (svn r4639) -Feature: Turkish town names (jnmbk)
celestar
parents: 3106
diff changeset
   654
4148
7ea2ef7a6424 (svn r5512) Fix : Remove a warning on MakeItalianTownName.
belugas
parents: 4143
diff changeset
   655
static const char *mascul_femin_italian[] = {
7ea2ef7a6424 (svn r5512) Fix : Remove a warning on MakeItalianTownName.
belugas
parents: 4143
diff changeset
   656
	"o",
7ea2ef7a6424 (svn r5512) Fix : Remove a warning on MakeItalianTownName.
belugas
parents: 4143
diff changeset
   657
	"a",
7ea2ef7a6424 (svn r5512) Fix : Remove a warning on MakeItalianTownName.
belugas
parents: 4143
diff changeset
   658
};
7ea2ef7a6424 (svn r5512) Fix : Remove a warning on MakeItalianTownName.
belugas
parents: 4143
diff changeset
   659
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   660
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
   661
{
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   662
	strecpy(buf, "", last);
4143
5e6c2cfa6baa (svn r5504) Feature : Added Italian town name generator. (sidew)
belugas
parents: 4077
diff changeset
   663
4148
7ea2ef7a6424 (svn r5512) Fix : Remove a warning on MakeItalianTownName.
belugas
parents: 4143
diff changeset
   664
	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
   665
		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
   666
	} else {
4148
7ea2ef7a6424 (svn r5512) Fix : Remove a warning on MakeItalianTownName.
belugas
parents: 4143
diff changeset
   667
		uint i;
7ea2ef7a6424 (svn r5512) Fix : Remove a warning on MakeItalianTownName.
belugas
parents: 4143
diff changeset
   668
7ea2ef7a6424 (svn r5512) Fix : Remove a warning on MakeItalianTownName.
belugas
parents: 4143
diff changeset
   669
		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
   670
			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
   671
		}
5e6c2cfa6baa (svn r5504) Feature : Added Italian town name generator. (sidew)
belugas
parents: 4077
diff changeset
   672
4148
7ea2ef7a6424 (svn r5512) Fix : Remove a warning on MakeItalianTownName.
belugas
parents: 4143
diff changeset
   673
		i = SeedChance(0, 2, seed);
4143
5e6c2cfa6baa (svn r5504) Feature : Added Italian town name generator. (sidew)
belugas
parents: 4077
diff changeset
   674
		if (i == 0) { // masculine form
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   675
			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
   676
		} else { // feminine form
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   677
			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
   678
		}
5e6c2cfa6baa (svn r5504) Feature : Added Italian town name generator. (sidew)
belugas
parents: 4077
diff changeset
   679
4148
7ea2ef7a6424 (svn r5512) Fix : Remove a warning on MakeItalianTownName.
belugas
parents: 4143
diff changeset
   680
		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
   681
			strecat(buf, name_italian_2[SeedModChance(11, lengthof(name_italian_2), seed)], last);
6308
646711c5feaa (svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
KUDr
parents: 6303
diff changeset
   682
			strecat(buf, mascul_femin_italian[i], last);
4143
5e6c2cfa6baa (svn r5504) Feature : Added Italian town name generator. (sidew)
belugas
parents: 4077
diff changeset
   683
		} else {
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   684
			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
   685
		}
5e6c2cfa6baa (svn r5504) Feature : Added Italian town name generator. (sidew)
belugas
parents: 4077
diff changeset
   686
5e6c2cfa6baa (svn r5504) Feature : Added Italian town name generator. (sidew)
belugas
parents: 4077
diff changeset
   687
		if (SeedModChance(15, 4, seed) == 0) {
4148
7ea2ef7a6424 (svn r5512) Fix : Remove a warning on MakeItalianTownName.
belugas
parents: 4143
diff changeset
   688
			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
   689
				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
   690
			} else { // river name suffix
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   691
				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
   692
				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
   693
			}
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
	}
5e6c2cfa6baa (svn r5504) Feature : Added Italian town name generator. (sidew)
belugas
parents: 4077
diff changeset
   696
5e6c2cfa6baa (svn r5504) Feature : Added Italian town name generator. (sidew)
belugas
parents: 4077
diff changeset
   697
	return 0;
5e6c2cfa6baa (svn r5504) Feature : Added Italian town name generator. (sidew)
belugas
parents: 4077
diff changeset
   698
}
5e6c2cfa6baa (svn r5504) Feature : Added Italian town name generator. (sidew)
belugas
parents: 4077
diff changeset
   699
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   700
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
   701
{
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   702
	strecpy(buf, "", last);
4312
b5867bca34c1 (svn r5965) -Feature: FS#261 Catalan Town Names generator (arnau)
bjarni
parents: 4148
diff changeset
   703
b5867bca34c1 (svn r5965) -Feature: FS#261 Catalan Town Names generator (arnau)
bjarni
parents: 4148
diff changeset
   704
	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
   705
		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
   706
	} else {
b5867bca34c1 (svn r5965) -Feature: FS#261 Catalan Town Names generator (arnau)
bjarni
parents: 4148
diff changeset
   707
		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
   708
4312
b5867bca34c1 (svn r5965) -Feature: FS#261 Catalan Town Names generator (arnau)
bjarni
parents: 4148
diff changeset
   709
		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
   710
			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
   711
		}
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
   712
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
		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
   714
		if (i == 0) { // masculine form
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   715
			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
   716
			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
   717
		} else { // feminine form
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   718
			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
   719
			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
   720
		}
4312
b5867bca34c1 (svn r5965) -Feature: FS#261 Catalan Town Names generator (arnau)
bjarni
parents: 4148
diff changeset
   721
b5867bca34c1 (svn r5965) -Feature: FS#261 Catalan Town Names generator (arnau)
bjarni
parents: 4148
diff changeset
   722
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
   723
		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
   724
			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
   725
				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
   726
			} else { // river name suffix
4919
8ac0256c6009 (svn r6895) - Fix (r6884): Add 'last' parameter to the town name generators.
peter1138
parents: 4441
diff changeset
   727
				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
   728
			}
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
	return 0;
b5867bca34c1 (svn r5965) -Feature: FS#261 Catalan Town Names generator (arnau)
bjarni
parents: 4148
diff changeset
   733
}
b5867bca34c1 (svn r5965) -Feature: FS#261 Catalan Town Names generator (arnau)
bjarni
parents: 4148
diff changeset
   734
b5867bca34c1 (svn r5965) -Feature: FS#261 Catalan Town Names generator (arnau)
bjarni
parents: 4148
diff changeset
   735
b5867bca34c1 (svn r5965) -Feature: FS#261 Catalan Town Names generator (arnau)
bjarni
parents: 4148
diff changeset
   736
993
5ac6f569031e (svn r1491) Fix bracing style and indentation (Jango)
tron
parents: 992
diff changeset
   737
TownNameGenerator * const _town_name_generators[] =
5ac6f569031e (svn r1491) Fix bracing style and indentation (Jango)
tron
parents: 992
diff changeset
   738
{
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   739
	MakeEnglishOriginalTownName,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   740
	MakeFrenchTownName,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   741
	MakeGermanTownName,
833
9d4d77ff2cce (svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents: 428
diff changeset
   742
	MakeEnglishAdditionalTownName,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   743
	MakeSpanishTownName,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   744
	MakeSillyTownName,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   745
	MakeSwedishTownName,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   746
	MakeDutchTownName,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   747
	MakeFinnishTownName,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   748
	MakePolishTownName,
428
532ec9578634 (svn r627) Merge r439 to trunk:
tron
parents: 264
diff changeset
   749
	MakeSlovakTownName,
948
4b3f777634ab (svn r1438) Added norwegian townnames
miham
parents: 852
diff changeset
   750
	MakeNorwegianTownName,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   751
	MakeHungarianTownName,
233
dd177a8c9f19 (svn r234) -Fix: added missing romanian.txt to VC6, VS.NET and Jamfile project file
darkvater
parents: 193
diff changeset
   752
	MakeAustrianTownName,
264
38396861c501 (svn r270) Fix: [ 1028851 ] automatic and unwanted city renaming
dominik
parents: 240
diff changeset
   753
	MakeRomanianTownName,
38396861c501 (svn r270) Fix: [ 1028851 ] automatic and unwanted city renaming
dominik
parents: 240
diff changeset
   754
	MakeCzechTownName,
1030
a5e4705a738c (svn r1531) -Feature: [1039061] Swiss town-names (vulvulune)
darkvater
parents: 996
diff changeset
   755
	MakeSwissTownName,
2431
c720f620253e (svn r2957) - Feature: [ 1263280 ] Danish town names (fey_dk)
Darkvater
parents: 2186
diff changeset
   756
	MakeDanishTownName,
3698
3c584402327e (svn r4639) -Feature: Turkish town names (jnmbk)
celestar
parents: 3106
diff changeset
   757
	MakeTurkishTownName,
4143
5e6c2cfa6baa (svn r5504) Feature : Added Italian town name generator. (sidew)
belugas
parents: 4077
diff changeset
   758
	MakeItalianTownName,
4312
b5867bca34c1 (svn r5965) -Feature: FS#261 Catalan Town Names generator (arnau)
bjarni
parents: 4148
diff changeset
   759
	MakeCatalanTownName,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   760
};
4
cad62d5f9708 (svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents: 0
diff changeset
   761
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   762
/* DO WE NEED THIS ANY MORE? */
4
cad62d5f9708 (svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents: 0
diff changeset
   763
#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
   764
cad62d5f9708 (svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents: 0
diff changeset
   765
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
   766
{
cad62d5f9708 (svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents: 0
diff changeset
   767
	switch (old_town_name_type) {
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   768
		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
   769
			/* Already OK */
4
cad62d5f9708 (svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents: 0
diff changeset
   770
			return townnameparts;
993
5ac6f569031e (svn r1491) Fix bracing style and indentation (Jango)
tron
parents: 992
diff changeset
   771
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   772
		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
   773
			/* 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
   774
			 * 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
   775
			return FIXNUM(townnameparts - 86, lengthof(name_french_real), 0);
993
5ac6f569031e (svn r1491) Fix bracing style and indentation (Jango)
tron
parents: 992
diff changeset
   776
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   777
		case 2: // German
5568
75f13d7bfaed (svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents: 5108
diff changeset
   778
			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
   779
			return townnameparts;
993
5ac6f569031e (svn r1491) Fix bracing style and indentation (Jango)
tron
parents: 992
diff changeset
   780
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   781
		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
   782
			/* 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
   783
			return FIXNUM(townnameparts, lengthof(name_spanish_real), 0);
993
5ac6f569031e (svn r1491) Fix bracing style and indentation (Jango)
tron
parents: 992
diff changeset
   784
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 5835
diff changeset
   785
		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
   786
			/* 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
   787
			 * 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
   788
			 * 1000 0000 2222 2222 0000 0000 1111 1111 */
2549
f1d3b383d557 (svn r3078) Some more stuff, which piled up:
tron
parents: 2484
diff changeset
   789
			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
   790
	}
cad62d5f9708 (svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents: 0
diff changeset
   791
	return 0;
cad62d5f9708 (svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents: 0
diff changeset
   792
}