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) {
604 const char *orig = buf;
610 bool do_prefix = prob_tails < 12;
611 bool do_suffix = prob_tails > 11 && prob_tails < 17;
615 int prefix = 0, ending = 0, suffix = 0;
630 if (stem <
lengthof(_name_czech_subst_full)) {
632 dynamic_subst =
false;
633 gender = _name_czech_subst_full[stem].gender;
634 choose = _name_czech_subst_full[stem].choose;
635 allow = _name_czech_subst_full[stem].allow;
637 uint map[
lengthof(_name_czech_subst_ending)];
638 int ending_start = -1, ending_stop = -1;
641 dynamic_subst =
true;
642 stem -=
lengthof(_name_czech_subst_full);
643 stem %=
lengthof(_name_czech_subst_stem);
644 gender = _name_czech_subst_stem[stem].gender;
645 choose = _name_czech_subst_stem[stem].choose;
646 allow = _name_czech_subst_stem[stem].allow;
651 if (choose & CZC_POSTFIX) {
653 postfix %=
lengthof(_name_czech_subst_postfix);
655 if (choose & CZC_NOPOSTFIX) {
657 postfix +=
lengthof(_name_czech_subst_postfix);
659 if (postfix <
lengthof(_name_czech_subst_postfix)) {
660 choose |= CZC_POSTFIX;
662 choose |= CZC_NOPOSTFIX;
666 for (ending = 0; ending < (int)
lengthof(_name_czech_subst_ending); ending++) {
669 if (gender == CZG_FREE ||
670 (gender == CZG_NFREE && e->gender != CZG_SNEUT && e->gender != CZG_PNEUT) ||
671 gender == e->gender) {
672 if (ending_start < 0) {
673 ending_start = ending;
675 }
else if (ending_start >= 0) {
676 ending_stop = ending - 1;
680 if (ending_stop < 0) {
682 ending_stop = ending - 1;
687 for (ending = ending_start; ending <= ending_stop; ending++) {
690 if ((e->choose & choose) == choose && (e->allow & allow) != 0) {
700 gender = _name_czech_subst_ending[ending].gender;
701 assert(gender != CZG_FREE && gender != CZG_NFREE);
704 if (do_prefix && (_name_czech_adj[prefix].choose & choose) != choose) {
711 CzechPattern pattern = _name_czech_adj[prefix].pattern;
713 buf =
strecpy(buf, _name_czech_adj[prefix].name, last);
715 char *endpos = buf - 1;
717 while (
GB(*endpos, 6, 2) == 2) endpos--;
719 if (gender == CZG_SMASC && pattern == CZP_PRIVL) {
720 assert(endpos >= orig + 2);
723 assert(*(endpos - 1) ==
'v');
726 assert(endpos >= orig);
727 endpos =
strecpy(endpos, _name_czech_patmod[gender][pattern], last);
730 buf =
strecpy(endpos,
" ", last);
734 buf =
strecpy(buf, _name_czech_subst_stem[stem].name, last);
735 if (postfix <
lengthof(_name_czech_subst_postfix)) {
736 const char *poststr = _name_czech_subst_postfix[postfix];
737 const char *endstr = _name_czech_subst_ending[ending].name;
739 size_t postlen = strlen(poststr);
740 size_t endlen = strlen(endstr);
741 assert(postlen > 0 && endlen > 0);
744 if (postlen < 2 || postlen > endlen ||
745 ((poststr[1] !=
'v' || poststr[1] != endstr[1]) &&
746 poststr[2] != endstr[1])) {
747 buf =
strecpy(buf, poststr, last);
750 if (endstr[0] ==
'i') {
751 switch (*(buf - 1)) {
752 case 'k': *(buf - 1) =
'c';
break;
753 case 'h': *(buf - 1) =
'z';
break;
759 buf =
strecpy(buf, _name_czech_subst_ending[ending].name, last);
761 buf =
strecpy(buf, _name_czech_subst_full[stem].name, last);
766 buf =
strecpy(buf, _name_czech_suffix[suffix], last);
835 if (i <
lengthof(_name_hungarian_1)) buf =
strecpy(buf, _name_hungarian_1[i], last);
843 if (i <
lengthof(_name_hungarian_4)) {
844 buf =
strecpy(buf, _name_hungarian_4[i], last);
873 if (i >= 0) buf =
strecpy(buf, _name_danish_1[i], last);
932 static const char *
const mascul_femin_italian[] = {
950 buf =
strecpy(buf, mascul_femin_italian[i], last);
1065 if (last >= buf + par->
min)
return par->
proc(buf, last, seed);
1068 par->
proc(buffer, buffer + par->
min, seed);
1070 return strecpy(buf, buffer, last);