author | Darkvater |
Thu, 02 Jun 2005 19:30:21 +0000 | |
changeset 1891 | 92a3b0aa0946 |
parent 1473 | 4be673c6c994 |
child 2186 | 461a2aff3486 |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1473
diff
changeset
|
2 |
#include "openttd.h" |
1299
0a6510cc889b
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1109
diff
changeset
|
3 |
#include "debug.h" |
1306
40038dfdf3ba
(svn r1810) Move town name generation declarations into a header of their own
tron
parents:
1299
diff
changeset
|
4 |
#include "namegen.h" |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
5 |
#include "table/namegen.h" |
0 | 6 |
|
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
7 |
static inline uint32 SeedChance(int shift_by, int max, uint32 seed) |
0 | 8 |
{ |
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
9 |
return ((uint16)(seed >> shift_by) * max) >> 16; |
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
10 |
} |
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
11 |
|
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
|
12 |
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
|
13 |
{ |
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
|
14 |
/* 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
|
15 |
* 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
|
16 |
* 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
|
17 |
* 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
|
18 |
* 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
|
19 |
* 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
|
20 |
* 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
|
21 |
* --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
|
22 |
// 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
|
23 |
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
|
24 |
} |
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 |
|
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
26 |
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
|
27 |
{ |
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
28 |
return SeedChance(shift_by, max + bias, seed) - bias; |
0 | 29 |
} |
30 |
||
1109
1bab892228cd
(svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents:
1107
diff
changeset
|
31 |
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
|
32 |
{ |
1107 | 33 |
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
|
34 |
} |
0 | 35 |
|
1307
e009b42d00b4
(svn r1811) Use char for string handling in namegen.[ch]
tron
parents:
1306
diff
changeset
|
36 |
static byte MakeEnglishOriginalTownName(char *buf, uint32 seed) |
0 | 37 |
{ |
38 |
int i; |
|
39 |
||
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
40 |
//null terminates the string for strcat |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
41 |
strcpy(buf, ""); |
0 | 42 |
|
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
43 |
// optional first segment |
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
44 |
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
|
45 |
if (i >= 0) |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
46 |
strcat(buf,name_original_english_1[i]); |
0 | 47 |
|
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
48 |
//mandatory middle segments |
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
49 |
strcat(buf, name_original_english_2[SeedChance(4, lengthof(name_original_english_2), seed)]); |
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
50 |
strcat(buf, name_original_english_3[SeedChance(7, lengthof(name_original_english_3), seed)]); |
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
51 |
strcat(buf, name_original_english_4[SeedChance(10, lengthof(name_original_english_4), seed)]); |
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
52 |
strcat(buf, name_original_english_5[SeedChance(13, lengthof(name_original_english_5), seed)]); |
111
31c32d936f58
(svn r112) -Fix: converted all linebreaks to UNIX-linebreak (\n) (forgot one file)
truelight
parents:
109
diff
changeset
|
53 |
|
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
54 |
//optional last segment |
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
55 |
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
|
56 |
if (i >= 0) |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
57 |
strcat(buf, name_original_english_6[i]); |
0 | 58 |
|
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
59 |
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
|
60 |
buf[0] = 'K'; |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
61 |
|
1107 | 62 |
ReplaceWords("Cunt", "East", buf); |
63 |
ReplaceWords("Slag", "Pits", buf); |
|
64 |
ReplaceWords("Slut", "Edin", buf); |
|
65 |
//ReplaceWords("Fart", "Boot", buf); |
|
66 |
ReplaceWords("Drar", "Quar", buf); |
|
67 |
ReplaceWords("Dreh", "Bash", buf); |
|
68 |
ReplaceWords("Frar", "Shor", buf); |
|
69 |
ReplaceWords("Grar", "Aber", buf); |
|
70 |
ReplaceWords("Brar", "Over", buf); |
|
71 |
ReplaceWords("Wrar", "Inve", buf); |
|
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
72 |
|
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
73 |
return 0; |
0 | 74 |
} |
75 |
||
76 |
||
1307
e009b42d00b4
(svn r1811) Use char for string handling in namegen.[ch]
tron
parents:
1306
diff
changeset
|
77 |
static byte MakeEnglishAdditionalTownName(char *buf, uint32 seed) |
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 |
int i; |
0 | 80 |
|
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
81 |
//null terminates the string for strcat |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
82 |
strcpy(buf, ""); |
0 | 83 |
|
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
84 |
// optional first segment |
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
85 |
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
|
86 |
if (i >= 0) |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
87 |
strcat(buf,name_additional_english_prefix[i]); |
0 | 88 |
|
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
89 |
if (SeedChance(3, 20, seed) >= 14) { |
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
90 |
strcat(buf, name_additional_english_1a[SeedChance(6, lengthof(name_additional_english_1a), seed)]); |
993 | 91 |
} else { |
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
92 |
strcat(buf, name_additional_english_1b1[SeedChance(6, lengthof(name_additional_english_1b1), seed)]); |
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
93 |
strcat(buf, name_additional_english_1b2[SeedChance(9, lengthof(name_additional_english_1b2), seed)]); |
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
94 |
if (SeedChance(11, 20, seed) >= 4) { |
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
95 |
strcat(buf, name_additional_english_1b3a[SeedChance(12, lengthof(name_additional_english_1b3a), seed)]); |
993 | 96 |
} else { |
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
97 |
strcat(buf, name_additional_english_1b3b[SeedChance(12, lengthof(name_additional_english_1b3b), seed)]); |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
98 |
} |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
99 |
} |
0 | 100 |
|
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
101 |
strcat(buf, name_additional_english_2[SeedChance(14, lengthof(name_additional_english_2), seed)]); |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
102 |
|
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
103 |
//optional last segment |
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
104 |
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
|
105 |
if (i >= 0) |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
106 |
strcat(buf, name_additional_english_3[i]); |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
107 |
|
1107 | 108 |
ReplaceWords("Cunt", "East", buf); |
109 |
ReplaceWords("Slag", "Pits", buf); |
|
110 |
ReplaceWords("Slut", "Edin", buf); |
|
111 |
ReplaceWords("Fart", "Boot", buf); |
|
112 |
ReplaceWords("Drar", "Quar", buf); |
|
113 |
ReplaceWords("Dreh", "Bash", buf); |
|
114 |
ReplaceWords("Frar", "Shor", buf); |
|
115 |
ReplaceWords("Grar", "Aber", buf); |
|
116 |
ReplaceWords("Brar", "Over", buf); |
|
117 |
ReplaceWords("Wrar", "Stan", buf); |
|
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
118 |
|
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
119 |
return 0; |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
120 |
} |
0 | 121 |
|
1307
e009b42d00b4
(svn r1811) Use char for string handling in namegen.[ch]
tron
parents:
1306
diff
changeset
|
122 |
static byte MakeAustrianTownName(char *buf, uint32 seed) |
0 | 123 |
{ |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
124 |
int i, j = 0; |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
125 |
strcpy(buf, ""); |
0 | 126 |
|
127 |
// Bad, Maria, Gross, ... |
|
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
128 |
i = SeedChanceBias(0, lengthof(name_austrian_a1), seed, 15); |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
129 |
if (i >= 0) strcat(buf, name_austrian_a1[i]); |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
130 |
|
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
131 |
i = SeedChance(4, 6, seed); |
993 | 132 |
if (i >= 4) { |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
133 |
// Kaisers-kirchen |
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
134 |
strcat(buf, name_austrian_a2[SeedChance( 7, lengthof(name_austrian_a2), seed)]); |
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
135 |
strcat(buf, name_austrian_a3[SeedChance(13, lengthof(name_austrian_a3), seed)]); |
993 | 136 |
} else if (i >= 2) { |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
137 |
// St. Johann |
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
138 |
strcat(buf, name_austrian_a5[SeedChance( 7, lengthof(name_austrian_a5), seed)]); |
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
139 |
strcat(buf, name_austrian_a6[SeedChance( 9, lengthof(name_austrian_a6), seed)]); |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
140 |
j = 1; // More likely to have a " an der " or " am " |
993 | 141 |
} else { |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
142 |
// Zell |
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
143 |
strcat(buf, name_austrian_a4[SeedChance( 7, lengthof(name_austrian_a4), seed)]); |
0 | 144 |
} |
145 |
||
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
146 |
i = SeedChance(1, 6, seed); |
993 | 147 |
if (i >= 4 - j) { |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
148 |
// an der Donau (rivers) |
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
149 |
strcat(buf, name_austrian_f1[SeedChance(4, lengthof(name_austrian_f1), seed)]); |
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
150 |
strcat(buf, name_austrian_f2[SeedChance(5, lengthof(name_austrian_f2), seed)]); |
993 | 151 |
} else if (i >= 2 - j) { |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
152 |
// am Dachstein (mountains) |
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
153 |
strcat(buf, name_austrian_b1[SeedChance(4, lengthof(name_austrian_b1), seed)]); |
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
154 |
strcat(buf, name_austrian_b2[SeedChance(5, lengthof(name_austrian_b2), seed)]); |
0 | 155 |
} |
156 |
||
157 |
return 0; |
|
158 |
} |
|
159 |
||
1307
e009b42d00b4
(svn r1811) Use char for string handling in namegen.[ch]
tron
parents:
1306
diff
changeset
|
160 |
static byte MakeGermanTownName(char *buf, uint32 seed) |
0 | 161 |
{ |
992
7ddeb6074c06
(svn r1490) Restore original town name generation behavior for german and hungarian (Jango)
tron
parents:
959
diff
changeset
|
162 |
uint i; |
7ddeb6074c06
(svn r1490) Restore original town name generation behavior for german and hungarian (Jango)
tron
parents:
959
diff
changeset
|
163 |
uint seed_derivative; |
0 | 164 |
|
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
165 |
//null terminates the string for strcat |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
166 |
strcpy(buf, ""); |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
167 |
|
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
168 |
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
|
169 |
|
7ddeb6074c06
(svn r1490) Restore original town name generation behavior for german and hungarian (Jango)
tron
parents:
959
diff
changeset
|
170 |
//optional prefix |
7ddeb6074c06
(svn r1490) Restore original town name generation behavior for german and hungarian (Jango)
tron
parents:
959
diff
changeset
|
171 |
if (seed_derivative == 12 || seed_derivative == 19) { |
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
172 |
i = SeedChance(2, lengthof(name_german_pre), seed); |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
173 |
strcat(buf,name_german_pre[i]); |
4
cad62d5f9708
(svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents:
0
diff
changeset
|
174 |
} |
0 | 175 |
|
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
176 |
// 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
|
177 |
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
|
178 |
if (i < lengthof(name_german_real)) { |
c3bc75035658
(svn r1926) Codechange: Renamed some of the predefined town names arrays for consistent naming.
pasky
parents:
1307
diff
changeset
|
179 |
strcat(buf,name_german_real[i]); |
993 | 180 |
} else { |
1422
c3bc75035658
(svn r1926) Codechange: Renamed some of the predefined town names arrays for consistent naming.
pasky
parents:
1307
diff
changeset
|
181 |
strcat(buf, name_german_1[i - lengthof(name_german_real)]); |
992
7ddeb6074c06
(svn r1490) Restore original town name generation behavior for german and hungarian (Jango)
tron
parents:
959
diff
changeset
|
182 |
|
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
183 |
i = SeedChance(5, lengthof(name_german_2), seed); |
992
7ddeb6074c06
(svn r1490) Restore original town name generation behavior for german and hungarian (Jango)
tron
parents:
959
diff
changeset
|
184 |
strcat(buf, name_german_2[i]); |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
185 |
} |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
186 |
|
992
7ddeb6074c06
(svn r1490) Restore original town name generation behavior for german and hungarian (Jango)
tron
parents:
959
diff
changeset
|
187 |
// optional suffix |
7ddeb6074c06
(svn r1490) Restore original town name generation behavior for german and hungarian (Jango)
tron
parents:
959
diff
changeset
|
188 |
if (seed_derivative == 24) { |
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
189 |
i = SeedChance(9, |
992
7ddeb6074c06
(svn r1490) Restore original town name generation behavior for german and hungarian (Jango)
tron
parents:
959
diff
changeset
|
190 |
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
|
191 |
if (i < lengthof(name_german_4_an_der)) { |
7ddeb6074c06
(svn r1490) Restore original town name generation behavior for german and hungarian (Jango)
tron
parents:
959
diff
changeset
|
192 |
strcat(buf, name_german_3_an_der[0]); |
7ddeb6074c06
(svn r1490) Restore original town name generation behavior for german and hungarian (Jango)
tron
parents:
959
diff
changeset
|
193 |
strcat(buf, name_german_4_an_der[i]); |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
194 |
} else { |
992
7ddeb6074c06
(svn r1490) Restore original town name generation behavior for german and hungarian (Jango)
tron
parents:
959
diff
changeset
|
195 |
strcat(buf, name_german_3_am[0]); |
7ddeb6074c06
(svn r1490) Restore original town name generation behavior for german and hungarian (Jango)
tron
parents:
959
diff
changeset
|
196 |
strcat(buf, name_german_4_am[i - lengthof(name_german_4_an_der)]); |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
197 |
} |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
198 |
} |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
199 |
return 0; |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
200 |
} |
0 | 201 |
|
1307
e009b42d00b4
(svn r1811) Use char for string handling in namegen.[ch]
tron
parents:
1306
diff
changeset
|
202 |
static byte MakeSpanishTownName(char *buf, uint32 seed) |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
203 |
{ |
1422
c3bc75035658
(svn r1926) Codechange: Renamed some of the predefined town names arrays for consistent naming.
pasky
parents:
1307
diff
changeset
|
204 |
strcpy(buf, name_spanish_real[SeedChance(0, lengthof(name_spanish_real), seed)]); |
833
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 | 207 |
|
1307
e009b42d00b4
(svn r1811) Use char for string handling in namegen.[ch]
tron
parents:
1306
diff
changeset
|
208 |
static byte MakeFrenchTownName(char *buf, uint32 seed) |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
209 |
{ |
1422
c3bc75035658
(svn r1926) Codechange: Renamed some of the predefined town names arrays for consistent naming.
pasky
parents:
1307
diff
changeset
|
210 |
strcpy(buf, name_french_real[SeedChance(0, lengthof(name_french_real), seed)]); |
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 |
} |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
213 |
|
1307
e009b42d00b4
(svn r1811) Use char for string handling in namegen.[ch]
tron
parents:
1306
diff
changeset
|
214 |
static byte MakeSillyTownName(char *buf, uint32 seed) |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
215 |
{ |
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
216 |
strcpy(buf, name_silly_1[SeedChance( 0, lengthof(name_silly_1), seed)]); |
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
217 |
strcat(buf, name_silly_2[SeedChance(16, lengthof(name_silly_2), seed)]); |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
218 |
return 0; |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
219 |
} |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
220 |
|
1307
e009b42d00b4
(svn r1811) Use char for string handling in namegen.[ch]
tron
parents:
1306
diff
changeset
|
221 |
static byte MakeSwedishTownName(char *buf, uint32 seed) |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
222 |
{ |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
223 |
int i; |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
224 |
|
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
225 |
//null terminates the string for strcat |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
226 |
strcpy(buf, ""); |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
227 |
|
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
228 |
// optional first segment |
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
229 |
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
|
230 |
if (i >= 0) |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
231 |
strcat(buf, name_swedish_1[i]); |
0 | 232 |
|
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
233 |
// 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
|
234 |
if (SeedChance(4, 5, seed) >= 3) { |
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
235 |
strcat(buf, name_swedish_2[SeedChance( 7, lengthof(name_swedish_2), seed)]); |
993 | 236 |
} else { |
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
237 |
strcat(buf, name_swedish_2a[SeedChance( 7, lengthof(name_swedish_2a), seed)]); |
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
238 |
strcat(buf, name_swedish_2b[SeedChance(10, lengthof(name_swedish_2b), seed)]); |
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
239 |
strcat(buf, name_swedish_2c[SeedChance(13, lengthof(name_swedish_2c), seed)]); |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
240 |
} |
0 | 241 |
|
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
242 |
strcat(buf, name_swedish_3[SeedChance(16, lengthof(name_swedish_3), seed)]); |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
243 |
|
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
244 |
return 0; |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
245 |
} |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
246 |
|
1307
e009b42d00b4
(svn r1811) Use char for string handling in namegen.[ch]
tron
parents:
1306
diff
changeset
|
247 |
static byte MakeDutchTownName(char *buf, uint32 seed) |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
248 |
{ |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
249 |
int i; |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
250 |
|
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
251 |
//null terminates the string for strcat |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
252 |
strcpy(buf, ""); |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
253 |
|
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
254 |
// optional first segment |
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
255 |
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
|
256 |
if (i >= 0) |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
257 |
strcat(buf, name_dutch_1[i]); |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
258 |
|
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
259 |
// 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
|
260 |
if (SeedChance(6, 9, seed) > 4) { |
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
261 |
strcat(buf, name_dutch_2[SeedChance( 9, lengthof(name_dutch_2), seed)]); |
993 | 262 |
} else { |
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
263 |
strcat(buf, name_dutch_3[SeedChance( 9, lengthof(name_dutch_3), seed)]); |
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
264 |
strcat(buf, name_dutch_4[SeedChance(12, lengthof(name_dutch_4), seed)]); |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
265 |
} |
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
266 |
strcat(buf, name_dutch_5[SeedChance(15, lengthof(name_dutch_5), seed)]); |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
267 |
|
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
268 |
return 0; |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
269 |
} |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
270 |
|
1307
e009b42d00b4
(svn r1811) Use char for string handling in namegen.[ch]
tron
parents:
1306
diff
changeset
|
271 |
static byte MakeFinnishTownName(char *buf, uint32 seed) |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
272 |
{ |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
273 |
//null terminates the string for strcat |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
274 |
strcpy(buf, ""); |
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 |
// 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
|
277 |
if (SeedChance(0, 15, seed) >= 10) { |
1422
c3bc75035658
(svn r1926) Codechange: Renamed some of the predefined town names arrays for consistent naming.
pasky
parents:
1307
diff
changeset
|
278 |
strcat(buf, name_finnish_real[SeedChance( 2, lengthof(name_finnish_real), seed)]); |
993 | 279 |
} else { |
1422
c3bc75035658
(svn r1926) Codechange: Renamed some of the predefined town names arrays for consistent naming.
pasky
parents:
1307
diff
changeset
|
280 |
strcat(buf, name_finnish_1[SeedChance( 2, lengthof(name_finnish_1), seed)]); |
c3bc75035658
(svn r1926) Codechange: Renamed some of the predefined town names arrays for consistent naming.
pasky
parents:
1307
diff
changeset
|
281 |
strcat(buf, name_finnish_2[SeedChance(10, lengthof(name_finnish_2), seed)]); |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
282 |
} |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
283 |
|
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
284 |
return 0; |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
285 |
} |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
286 |
|
1307
e009b42d00b4
(svn r1811) Use char for string handling in namegen.[ch]
tron
parents:
1306
diff
changeset
|
287 |
static byte MakePolishTownName(char *buf, uint32 seed) |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
288 |
{ |
959
b031d88c76f3
(svn r1451) Fix some of the signed/unsigned comparison warnings
tron
parents:
958
diff
changeset
|
289 |
uint i; |
b031d88c76f3
(svn r1451) Fix some of the signed/unsigned comparison warnings
tron
parents:
958
diff
changeset
|
290 |
uint j; |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
291 |
|
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
292 |
//null terminates the string for strcat |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
293 |
strcpy(buf, ""); |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
294 |
|
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
295 |
// optional first segment |
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
296 |
i = SeedChance(0, |
993 | 297 |
lengthof(name_polish_2_o) + lengthof(name_polish_2_m) + |
298 |
lengthof(name_polish_2_f) + lengthof(name_polish_2_n), |
|
299 |
seed); |
|
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
300 |
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
|
301 |
|
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
302 |
|
993 | 303 |
if (i < lengthof(name_polish_2_o)) { |
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
304 |
strcat(buf, name_polish_2_o[SeedChance(3, lengthof(name_polish_2_o), seed)]); |
993 | 305 |
} 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
|
306 |
if (j < 4) |
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
307 |
strcat(buf, name_polish_1_m[SeedChance(5, lengthof(name_polish_1_m), seed)]); |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
308 |
|
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
309 |
strcat(buf, name_polish_2_m[SeedChance(7, lengthof(name_polish_2_m), seed)]); |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
310 |
|
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
311 |
if (j >= 4 && j < 16) |
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
312 |
strcat(buf, name_polish_3_m[SeedChance(10, lengthof(name_polish_3_m), seed)]); |
993 | 313 |
} 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
|
314 |
if (j < 4) |
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
315 |
strcat(buf, name_polish_1_f[SeedChance(5, lengthof(name_polish_1_f), seed)]); |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
316 |
|
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
317 |
strcat(buf, name_polish_2_f[SeedChance(7, lengthof(name_polish_2_f), seed)]); |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
318 |
|
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
319 |
if (j >= 4 && j < 16) |
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
320 |
strcat(buf, name_polish_3_f[SeedChance(10, lengthof(name_polish_3_f), seed)]); |
993 | 321 |
} else { |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
322 |
if (j < 4) |
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
323 |
strcat(buf, name_polish_1_n[SeedChance(5, lengthof(name_polish_1_n), seed)]); |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
324 |
|
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
325 |
strcat(buf, name_polish_2_n[SeedChance(7, lengthof(name_polish_2_n), seed)]); |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
326 |
|
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
327 |
if (j >= 4 && j < 16) |
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
328 |
strcat(buf, name_polish_3_n[SeedChance(10, lengthof(name_polish_3_n), seed)]); |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
329 |
} |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
330 |
return 0; |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
331 |
} |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
332 |
|
1307
e009b42d00b4
(svn r1811) Use char for string handling in namegen.[ch]
tron
parents:
1306
diff
changeset
|
333 |
static byte MakeCzechTownName(char *buf, uint32 seed) |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
334 |
{ |
1425
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
335 |
/* Probability of prefixes/suffixes */ |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
336 |
/* 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
|
337 |
int prob_tails; |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
338 |
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
|
339 |
/* IDs of the respective parts */ |
1473
4be673c6c994
(svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents:
1447
diff
changeset
|
340 |
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
|
341 |
uint postfix = 0; |
4be673c6c994
(svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents:
1447
diff
changeset
|
342 |
uint stem; |
1425
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
343 |
/* The select criteria. */ |
1473
4be673c6c994
(svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents:
1447
diff
changeset
|
344 |
CzechGender gender; |
4be673c6c994
(svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents:
1447
diff
changeset
|
345 |
CzechChoose choose; |
4be673c6c994
(svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents:
1447
diff
changeset
|
346 |
CzechAllow allow; |
1425
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
347 |
|
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
348 |
// 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
|
349 |
if (SeedModChance(0, 4, seed) == 0) { |
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
|
350 |
strcpy(buf, name_czech_real[SeedModChance(4, lengthof(name_czech_real), seed)]); |
1425
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
351 |
return 0; |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
352 |
} |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
353 |
|
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
354 |
// NUL terminates the string for strcat() |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
355 |
strcpy(buf, ""); |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
356 |
|
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
|
357 |
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
|
358 |
do_prefix = prob_tails < 12; |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
359 |
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
|
360 |
|
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
|
361 |
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
|
362 |
if (do_suffix) suffix = SeedModChance(7, lengthof(name_czech_suffix), seed); |
1425
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
363 |
// 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
|
364 |
stem = SeedModChance(9, |
4be673c6c994
(svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents:
1447
diff
changeset
|
365 |
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
|
366 |
seed); |
4be673c6c994
(svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents:
1447
diff
changeset
|
367 |
if (stem < lengthof(name_czech_subst_full)) { |
1425
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
368 |
// That was easy! |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
369 |
dynamic_subst = false; |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
370 |
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
|
371 |
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
|
372 |
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
|
373 |
} else { |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
374 |
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
|
375 |
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
|
376 |
int i; |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
377 |
|
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
378 |
// Load the substantive |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
379 |
dynamic_subst = true; |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
380 |
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
|
381 |
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
|
382 |
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
|
383 |
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
|
384 |
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
|
385 |
|
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
386 |
// 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
|
387 |
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
|
388 |
|
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
389 |
if (choose & CZC_POSTFIX) { |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
390 |
// Always get a real postfix. |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
391 |
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
|
392 |
} |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
393 |
if (choose & CZC_NOPOSTFIX) { |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
394 |
// Always drop a postfix. |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
395 |
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
|
396 |
} |
1473
4be673c6c994
(svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents:
1447
diff
changeset
|
397 |
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
|
398 |
choose |= CZC_POSTFIX; |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
399 |
else |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
400 |
choose |= CZC_NOPOSTFIX; |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
401 |
|
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
402 |
// Localize the array segment containing a good gender |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
403 |
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
|
404 |
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
|
405 |
|
1473
4be673c6c994
(svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents:
1447
diff
changeset
|
406 |
if (gender == CZG_FREE || |
4be673c6c994
(svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents:
1447
diff
changeset
|
407 |
(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
|
408 |
gender == e->gender) { |
1425
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
409 |
if (ending_start < 0) |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
410 |
ending_start = ending; |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
411 |
|
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
412 |
} else if (ending_start >= 0) { |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
413 |
ending_stop = ending - 1; |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
414 |
break; |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
415 |
} |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
416 |
} |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
417 |
if (ending_stop < 0) { |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
418 |
// Whoa. All the endings matched. |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
419 |
ending_stop = ending - 1; |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
420 |
} |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
421 |
|
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
422 |
// Make a sequential map of the items with good mask |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
423 |
i = 0; |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
424 |
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
|
425 |
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
|
426 |
|
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
427 |
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
|
428 |
map[i++] = ending; |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
429 |
} |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
430 |
assert(i > 0); |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
431 |
|
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
432 |
// 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
|
433 |
ending = map[SeedModChance(16, i, seed)]; |
1425
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
434 |
// Override possible CZG_*FREE; this must be a real gender, |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
435 |
// otherwise we get overflow when modifying the adjectivum. |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
436 |
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
|
437 |
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
|
438 |
} |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
439 |
|
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
440 |
if (do_prefix && (name_czech_adj[prefix].choose & choose) != choose) { |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
441 |
// Throw away non-matching prefix. |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
442 |
do_prefix = false; |
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 |
|
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
445 |
// Now finally construct the name |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
446 |
|
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
447 |
if (do_prefix) { |
1473
4be673c6c994
(svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents:
1447
diff
changeset
|
448 |
CzechPattern pattern = name_czech_adj[prefix].pattern; |
1425
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
449 |
int endpos; |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
450 |
|
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
451 |
strcat(buf, name_czech_adj[prefix].name); |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
452 |
endpos = strlen(buf) - 1; |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
453 |
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
|
454 |
/* -ovX -> -uv */ |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
455 |
buf[endpos - 2] = 'u'; |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
456 |
assert(buf[endpos - 1] == 'v'); |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
457 |
buf[endpos] = '\0'; |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
458 |
} else { |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
459 |
buf[endpos] = name_czech_patmod[gender][pattern]; |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
460 |
} |
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 |
strcat(buf, " "); |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
463 |
} |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
464 |
|
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
465 |
if (dynamic_subst) { |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
466 |
strcat(buf, name_czech_subst_stem[stem].name); |
1473
4be673c6c994
(svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents:
1447
diff
changeset
|
467 |
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
|
468 |
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
|
469 |
const char *endstr = name_czech_subst_ending[ending].name; |
1425
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
470 |
int postlen, endlen; |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
471 |
|
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
|
472 |
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
|
473 |
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
|
474 |
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
|
475 |
|
1425
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
476 |
// 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
|
477 |
if (postlen < 2 || postlen > endlen || ( |
4be673c6c994
(svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents:
1447
diff
changeset
|
478 |
(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
|
479 |
poststr[2] != endstr[1]) |
4be673c6c994
(svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents:
1447
diff
changeset
|
480 |
) { |
4be673c6c994
(svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents:
1447
diff
changeset
|
481 |
uint buflen; |
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
|
482 |
strcat(buf, 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
|
483 |
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
|
484 |
|
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
|
485 |
// k-i -> c-i, h-i -> z-i |
0a215fc32f96
(svn r1930) Cleaned up the postfix-ending connecting code and introduced some simple postfix-last-letter transformations when the ending first letter is 'i'.
pasky
parents:
1425
diff
changeset
|
486 |
if (endstr[0] == 'i') { |
1473
4be673c6c994
(svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents:
1447
diff
changeset
|
487 |
switch (buf[buflen - 1]) { |
4be673c6c994
(svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents:
1447
diff
changeset
|
488 |
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
|
489 |
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
|
490 |
default: break; |
4be673c6c994
(svn r1977) Typedef some enums and struct plus some minor style changes
tron
parents:
1447
diff
changeset
|
491 |
} |
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
|
492 |
} |
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
|
493 |
} |
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 |
strcat(buf, name_czech_subst_ending[ending].name); |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
496 |
} else { |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
497 |
strcat(buf, name_czech_subst_full[stem].name); |
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 |
|
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
500 |
if (do_suffix) { |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
501 |
strcat(buf, " "); |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
502 |
strcat(buf, name_czech_suffix[suffix]); |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
503 |
} |
d566470aa3ca
(svn r1929) Feature: [namegen] Support for dynamic generation of the Czech town names.
pasky
parents:
1422
diff
changeset
|
504 |
|
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
505 |
return 0; |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
506 |
} |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
507 |
|
1307
e009b42d00b4
(svn r1811) Use char for string handling in namegen.[ch]
tron
parents:
1306
diff
changeset
|
508 |
static byte MakeRomanianTownName(char *buf, uint32 seed) |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
509 |
{ |
1422
c3bc75035658
(svn r1926) Codechange: Renamed some of the predefined town names arrays for consistent naming.
pasky
parents:
1307
diff
changeset
|
510 |
strcpy(buf, name_romanian_real[SeedChance(0, lengthof(name_romanian_real), seed)]); |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
511 |
return 0; |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
512 |
} |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
513 |
|
1307
e009b42d00b4
(svn r1811) Use char for string handling in namegen.[ch]
tron
parents:
1306
diff
changeset
|
514 |
static byte MakeSlovakTownName(char *buf, uint32 seed) |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
515 |
{ |
1422
c3bc75035658
(svn r1926) Codechange: Renamed some of the predefined town names arrays for consistent naming.
pasky
parents:
1307
diff
changeset
|
516 |
strcpy(buf, name_slovak_real[SeedChance(0, lengthof(name_slovak_real), seed)]); |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
517 |
return 0; |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
518 |
} |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
519 |
|
1307
e009b42d00b4
(svn r1811) Use char for string handling in namegen.[ch]
tron
parents:
1306
diff
changeset
|
520 |
static byte MakeNorwegianTownName(char *buf, uint32 seed) |
948 | 521 |
{ |
522 |
strcpy(buf, ""); |
|
958
f5ccffdadd48
(svn r1450) Updated norwegian townname generation (Simen Graaten)
miham
parents:
948
diff
changeset
|
523 |
|
f5ccffdadd48
(svn r1450) Updated norwegian townname generation (Simen Graaten)
miham
parents:
948
diff
changeset
|
524 |
// Use first 4 bit from seed to decide whether or not this town should |
f5ccffdadd48
(svn r1450) Updated norwegian townname generation (Simen Graaten)
miham
parents:
948
diff
changeset
|
525 |
// 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
|
526 |
if (SeedChance(0, 15, seed) < 3) { |
958
f5ccffdadd48
(svn r1450) Updated norwegian townname generation (Simen Graaten)
miham
parents:
948
diff
changeset
|
527 |
// Use 7bit for the realname table index. Bit 4-10 |
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
528 |
strcat(buf, name_norwegian_real[SeedChance(4, lengthof(name_norwegian_real), seed)]); |
993 | 529 |
} else { |
958
f5ccffdadd48
(svn r1450) Updated norwegian townname generation (Simen Graaten)
miham
parents:
948
diff
changeset
|
530 |
// Use 7bit for the first fake part. Bit 4-10 |
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
531 |
strcat(buf, name_norwegian_1[SeedChance(4, lengthof(name_norwegian_1), seed)]); |
958
f5ccffdadd48
(svn r1450) Updated norwegian townname generation (Simen Graaten)
miham
parents:
948
diff
changeset
|
532 |
// Use 7bit for the last fake part. Bit 11-17 |
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
533 |
strcat(buf, name_norwegian_2[SeedChance(11, lengthof(name_norwegian_2), seed)]); |
958
f5ccffdadd48
(svn r1450) Updated norwegian townname generation (Simen Graaten)
miham
parents:
948
diff
changeset
|
534 |
} |
f5ccffdadd48
(svn r1450) Updated norwegian townname generation (Simen Graaten)
miham
parents:
948
diff
changeset
|
535 |
|
948 | 536 |
return 0; |
537 |
} |
|
538 |
||
1307
e009b42d00b4
(svn r1811) Use char for string handling in namegen.[ch]
tron
parents:
1306
diff
changeset
|
539 |
static byte MakeHungarianTownName(char *buf, uint32 seed) |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
540 |
{ |
959
b031d88c76f3
(svn r1451) Fix some of the signed/unsigned comparison warnings
tron
parents:
958
diff
changeset
|
541 |
uint i; |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
542 |
|
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
543 |
//null terminates the string for strcat |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
544 |
strcpy(buf, ""); |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
545 |
|
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
546 |
if (SeedChance(12, 15, seed) < 3) { |
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
547 |
strcat(buf, name_hungarian_real[SeedChance(0, lengthof(name_hungarian_real), seed)]); |
993 | 548 |
} else { |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
549 |
// optional first segment |
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
550 |
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
|
551 |
if (i < lengthof(name_hungarian_1)) |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
552 |
strcat(buf, name_hungarian_1[i]); |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
553 |
|
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
554 |
// mandatory middle segments |
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
555 |
strcat(buf, name_hungarian_2[SeedChance(3, lengthof(name_hungarian_2), seed)]); |
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
556 |
strcat(buf, name_hungarian_3[SeedChance(6, lengthof(name_hungarian_3), seed)]); |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
557 |
|
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
558 |
// optional last segment |
996
3cdb8dbb5c2f
(svn r1494) Give GetNumberBasedOnSeed() a bit more sane name: SeedChance()
tron
parents:
994
diff
changeset
|
559 |
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
|
560 |
if (i < lengthof(name_hungarian_4)) { |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
561 |
strcat(buf, name_hungarian_4[i]); |
0 | 562 |
} |
4
cad62d5f9708
(svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents:
0
diff
changeset
|
563 |
} |
0 | 564 |
|
565 |
return 0; |
|
566 |
} |
|
567 |
||
1307
e009b42d00b4
(svn r1811) Use char for string handling in namegen.[ch]
tron
parents:
1306
diff
changeset
|
568 |
static byte MakeSwissTownName(char *buf, uint32 seed) |
1030
a5e4705a738c
(svn r1531) -Feature: [1039061] Swiss town-names (vulvulune)
darkvater
parents:
996
diff
changeset
|
569 |
{ |
a5e4705a738c
(svn r1531) -Feature: [1039061] Swiss town-names (vulvulune)
darkvater
parents:
996
diff
changeset
|
570 |
strcpy(buf, name_swiss_real[SeedChance(0, lengthof(name_swiss_real), seed)]); |
a5e4705a738c
(svn r1531) -Feature: [1039061] Swiss town-names (vulvulune)
darkvater
parents:
996
diff
changeset
|
571 |
return 0; |
a5e4705a738c
(svn r1531) -Feature: [1039061] Swiss town-names (vulvulune)
darkvater
parents:
996
diff
changeset
|
572 |
} |
a5e4705a738c
(svn r1531) -Feature: [1039061] Swiss town-names (vulvulune)
darkvater
parents:
996
diff
changeset
|
573 |
|
993 | 574 |
TownNameGenerator * const _town_name_generators[] = |
575 |
{ |
|
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
576 |
MakeEnglishOriginalTownName, |
0 | 577 |
MakeFrenchTownName, |
578 |
MakeGermanTownName, |
|
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
579 |
MakeEnglishAdditionalTownName, |
0 | 580 |
MakeSpanishTownName, |
581 |
MakeSillyTownName, |
|
582 |
MakeSwedishTownName, |
|
583 |
MakeDutchTownName, |
|
584 |
MakeFinnishTownName, |
|
585 |
MakePolishTownName, |
|
428 | 586 |
MakeSlovakTownName, |
948 | 587 |
MakeNorwegianTownName, |
0 | 588 |
MakeHungarianTownName, |
233
dd177a8c9f19
(svn r234) -Fix: added missing romanian.txt to VC6, VS.NET and Jamfile project file
darkvater
parents:
193
diff
changeset
|
589 |
MakeAustrianTownName, |
264
38396861c501
(svn r270) Fix: [ 1028851 ] automatic and unwanted city renaming
dominik
parents:
240
diff
changeset
|
590 |
MakeRomanianTownName, |
38396861c501
(svn r270) Fix: [ 1028851 ] automatic and unwanted city renaming
dominik
parents:
240
diff
changeset
|
591 |
MakeCzechTownName, |
1030
a5e4705a738c
(svn r1531) -Feature: [1039061] Swiss town-names (vulvulune)
darkvater
parents:
996
diff
changeset
|
592 |
MakeSwissTownName, |
0 | 593 |
}; |
4
cad62d5f9708
(svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents:
0
diff
changeset
|
594 |
|
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
595 |
// DO WE NEED THIS ANY MORE? |
4
cad62d5f9708
(svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents:
0
diff
changeset
|
596 |
#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
|
597 |
|
cad62d5f9708
(svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents:
0
diff
changeset
|
598 |
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
|
599 |
{ |
cad62d5f9708
(svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents:
0
diff
changeset
|
600 |
switch (old_town_name_type) { |
cad62d5f9708
(svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents:
0
diff
changeset
|
601 |
case 0: case 3: /* English, American */ |
cad62d5f9708
(svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents:
0
diff
changeset
|
602 |
/* Already OK */ |
cad62d5f9708
(svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents:
0
diff
changeset
|
603 |
return townnameparts; |
993 | 604 |
|
4
cad62d5f9708
(svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents:
0
diff
changeset
|
605 |
case 1: /* French */ |
cad62d5f9708
(svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents:
0
diff
changeset
|
606 |
/* For some reason 86 needs to be subtracted from townnameparts |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
607 |
* 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
|
608 |
return FIXNUM(townnameparts - 86, lengthof(name_french_real), 0); |
993 | 609 |
|
4
cad62d5f9708
(svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents:
0
diff
changeset
|
610 |
case 2: /* German */ |
65
f9f866bc609c
(svn r66) -Fix Station list updated on station deletion/station rename
darkvater
parents:
8
diff
changeset
|
611 |
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
|
612 |
return townnameparts; |
993 | 613 |
|
4
cad62d5f9708
(svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents:
0
diff
changeset
|
614 |
case 4: /* Latin-American */ |
cad62d5f9708
(svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents:
0
diff
changeset
|
615 |
/* 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
|
616 |
return FIXNUM(townnameparts, lengthof(name_spanish_real), 0); |
993 | 617 |
|
4
cad62d5f9708
(svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents:
0
diff
changeset
|
618 |
case 5: /* Silly */ |
cad62d5f9708
(svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents:
0
diff
changeset
|
619 |
/* NUM_SILLY_1 - lower 16 bits |
833
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
620 |
* NUM_SILLY_2 - upper 16 bits without leading 1 (first 8 bytes) |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
621 |
* 1000 0000 2222 2222 0000 0000 1111 1111 */ |
9d4d77ff2cce
(svn r1307) -Fix/feature: rewrote the townname generation code. Code is much more
truelight
parents:
428
diff
changeset
|
622 |
return FIXNUM(townnameparts, lengthof(name_silly_1), 0) | FIXNUM(((townnameparts >> 16)&0xFF), lengthof(name_silly_2), 16); |
4
cad62d5f9708
(svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents:
0
diff
changeset
|
623 |
} |
cad62d5f9708
(svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents:
0
diff
changeset
|
624 |
return 0; |
cad62d5f9708
(svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents:
0
diff
changeset
|
625 |
} |