29 grfid(t->townnamegrfid),
32 if (t->townnamegrfid != 0 && GetGRFTownName(t->townnamegrfid) ==
nullptr) {
35 this->
type = SPECSTR_TOWNNAME_ENGLISH;
51 if (par->
grfid == 0) {
52 int64 args_array[1] = { townnameparts };
57 return GRFTownNameGenerate(buff, par->
grfid, par->
type, townnameparts, last);
71 return GetTownName(buff, &par, t->townnameparts, last);
93 if (town_names !=
nullptr) {
94 if (town_names->find(buf1) != town_names->end())
return false;
95 town_names->insert(buf1);
100 const char *buf = t->name.empty() ? nullptr : t->name.c_str();
101 if (buf ==
nullptr) {
105 if (strcmp(buf1, buf) == 0)
return false;
132 for (
int i = 1000; i != 0; i--) {
152 static inline uint32
SeedChance(
byte shift_by,
int max, uint32 seed)
154 return (
GB(seed, shift_by, 16) * max) >> 16;
176 return (seed >> shift_by) % max;
188 static inline int32
SeedChanceBias(
byte shift_by,
int max, uint32 seed,
int bias)
190 return SeedChance(shift_by, max + bias, seed) - bias;
202 assert(strlen(org) == 4 && strlen(rep) == 4 && strlen(buf) >= 4);
203 if (strncmp(buf, org, 4) == 0) memcpy(buf, rep, 4);
238 if (i >= 0) buf =
strecpy(buf, _name_original_english_1[i], last);
248 if (i >= 0) buf =
strecpy(buf, _name_original_english_6[i], last);
251 if (orig[0] ==
'C' && (orig[1] ==
'e' || orig[1] ==
'i')) {
255 assert(buf - orig >= 4);
274 if (i >= 0) buf =
strecpy(buf, _name_additional_english_prefix[i], last);
292 if (i >= 0) buf =
strecpy(buf, _name_additional_english_3[i], last);
294 assert(buf - orig >= 4);
311 if (i >= 0) buf =
strecpy(buf, _name_austrian_a1[i], last);
335 }
else if (i >= 2 - j) {
353 uint seed_derivative =
SeedChance(7, 28, seed);
356 if (seed_derivative == 12 || seed_derivative == 19) {
358 buf =
strecpy(buf, _name_german_pre[i], last);
363 if (i <
lengthof(_name_german_real)) {
364 buf =
strecpy(buf, _name_german_real[i], last);
366 buf =
strecpy(buf, _name_german_1[i -
lengthof(_name_german_real)], last);
369 buf =
strecpy(buf, _name_german_2[i], last);
373 if (seed_derivative == 24) {
375 if (i <
lengthof(_name_german_4_an_der)) {
376 buf =
strecpy(buf, _name_german_3_an_der[0], last);
377 buf =
strecpy(buf, _name_german_4_an_der[i], last);
379 buf =
strecpy(buf, _name_german_3_am[0], last);
380 buf =
strecpy(buf, _name_german_4_am[i -
lengthof(_name_german_4_an_der)], last);
437 if (i >= 0) buf =
strecpy(buf, _name_swedish_1[i], last);
464 if (i >= 0) buf =
strecpy(buf, _name_dutch_1[i], last);
500 buf =
strecpy(buf, _name_finnish_1[sel], last);
503 if (*end ==
'i') *end =
'e';
504 if (strstr(orig,
"a") !=
nullptr || strstr(orig,
"o") !=
nullptr || strstr(orig,
"u") !=
nullptr ||
505 strstr(orig,
"A") !=
nullptr || strstr(orig,
"O") !=
nullptr || strstr(orig,
"U") !=
nullptr) {
506 buf =
strecpy(buf,
"la", last);
508 buf =
strecpy(buf, u8
"l\u00e4", last);
516 if (sel >=
lengthof(_name_finnish_1)) {
517 buf =
strecpy(buf, _name_finnish_2[sel -
lengthof(_name_finnish_1)], last);
519 buf =
strecpy(buf, _name_finnish_1[sel], last);
544 if (i <
lengthof(_name_polish_2_o)) {
555 if (j >= 4 && j < 16) {
569 if (j >= 4 && j < 16) {
582 if (j >= 4 && j < 16) {
603 const char *orig = buf;
608 bool do_prefix = prob_tails < 12;
609 bool do_suffix = prob_tails > 11 && prob_tails < 17;
613 int prefix = 0, ending = 0, suffix = 0;
628 if (stem <
lengthof(_name_czech_subst_full)) {
630 dynamic_subst =
false;
631 gender = _name_czech_subst_full[stem].gender;
632 choose = _name_czech_subst_full[stem].choose;
633 allow = _name_czech_subst_full[stem].allow;
635 uint map[
lengthof(_name_czech_subst_ending)];
636 int ending_start = -1, ending_stop = -1;
639 dynamic_subst =
true;
640 stem -=
lengthof(_name_czech_subst_full);
641 stem %=
lengthof(_name_czech_subst_stem);
642 gender = _name_czech_subst_stem[stem].gender;
643 choose = _name_czech_subst_stem[stem].choose;
644 allow = _name_czech_subst_stem[stem].allow;
649 if (choose & CZC_POSTFIX) {
651 postfix %=
lengthof(_name_czech_subst_postfix);
653 if (choose & CZC_NOPOSTFIX) {
655 postfix +=
lengthof(_name_czech_subst_postfix);
657 if (postfix <
lengthof(_name_czech_subst_postfix)) {
658 choose |= CZC_POSTFIX;
660 choose |= CZC_NOPOSTFIX;
664 for (ending = 0; ending < (int)
lengthof(_name_czech_subst_ending); ending++) {
667 if (gender == CZG_FREE ||
668 (gender == CZG_NFREE && e->gender != CZG_SNEUT && e->gender != CZG_PNEUT) ||
669 gender == e->gender) {
670 if (ending_start < 0) {
671 ending_start = ending;
673 }
else if (ending_start >= 0) {
674 ending_stop = ending - 1;
678 if (ending_stop < 0) {
680 ending_stop = ending - 1;
685 for (ending = ending_start; ending <= ending_stop; ending++) {
688 if ((e->choose & choose) == choose && (e->allow & allow) != 0) {
698 gender = _name_czech_subst_ending[ending].gender;
699 assert(gender != CZG_FREE && gender != CZG_NFREE);
702 if (do_prefix && (_name_czech_adj[prefix].choose & choose) != choose) {
709 CzechPattern pattern = _name_czech_adj[prefix].pattern;
711 buf =
strecpy(buf, _name_czech_adj[prefix].name, last);
713 char *endpos = buf - 1;
715 while (
GB(*endpos, 6, 2) == 2) endpos--;
717 if (gender == CZG_SMASC && pattern == CZP_PRIVL) {
718 assert(endpos >= orig + 2);
721 assert(*(endpos - 1) ==
'v');
724 assert(endpos >= orig);
725 endpos =
strecpy(endpos, _name_czech_patmod[gender][pattern], last);
728 buf =
strecpy(endpos,
" ", last);
732 buf =
strecpy(buf, _name_czech_subst_stem[stem].name, last);
733 if (postfix <
lengthof(_name_czech_subst_postfix)) {
734 const char *poststr = _name_czech_subst_postfix[postfix];
735 const char *endstr = _name_czech_subst_ending[ending].name;
737 size_t postlen = strlen(poststr);
738 size_t endlen = strlen(endstr);
739 assert(postlen > 0 && endlen > 0);
742 if (postlen < 2 || postlen > endlen ||
743 ((poststr[1] !=
'v' || poststr[1] != endstr[1]) &&
744 poststr[2] != endstr[1])) {
745 buf =
strecpy(buf, poststr, last);
748 if (endstr[0] ==
'i') {
749 switch (*(buf - 1)) {
750 case 'k': *(buf - 1) =
'c';
break;
751 case 'h': *(buf - 1) =
'z';
break;
757 buf =
strecpy(buf, _name_czech_subst_ending[ending].name, last);
759 buf =
strecpy(buf, _name_czech_subst_full[stem].name, last);
764 buf =
strecpy(buf, _name_czech_suffix[suffix], last);
833 if (i <
lengthof(_name_hungarian_1)) buf =
strecpy(buf, _name_hungarian_1[i], last);
841 if (i <
lengthof(_name_hungarian_4)) {
842 buf =
strecpy(buf, _name_hungarian_4[i], last);
871 if (i >= 0) buf =
strecpy(buf, _name_danish_1[i], last);
930 static const char *
const mascul_femin_italian[] = {
948 buf =
strecpy(buf, mascul_femin_italian[i], last);
1063 if (last >= buf + par->
min)
return par->
proc(buf, last, seed);
1066 par->
proc(buffer, buffer + par->
min, seed);
1068 return strecpy(buf, buffer, last);