OpenTTD Source
20241125-master-g5b02f51e17
|
Town name generators. More...
#include "stdafx.h"
#include "string_func.h"
#include "townname_type.h"
#include "town.h"
#include "strings_func.h"
#include "core/random_func.hpp"
#include "genworld.h"
#include "gfx_layout.h"
#include "strings_internal.h"
#include "table/townname.h"
#include "safeguards.h"
Go to the source code of this file.
Typedefs | |
typedef void | TownNameGenerator(StringBuilder &builder, uint32_t seed) |
Type for all town name generator functions. More... | |
Functions | |
static void | GetTownName (StringBuilder &builder, const TownNameParams *par, uint32_t townnameparts) |
Fills builder with specified town name. More... | |
std::string | GetTownName (const TownNameParams *par, uint32_t townnameparts) |
Get the town name for the given parameters and parts. More... | |
void | GetTownName (StringBuilder &builder, const Town *t) |
Fills builder with town's name. More... | |
std::string | GetTownName (const Town *t) |
Get the name of the given town. More... | |
bool | VerifyTownName (uint32_t r, const TownNameParams *par, TownNames *town_names) |
Verifies the town name is valid and unique. More... | |
bool | GenerateTownName (Randomizer &randomizer, uint32_t *townnameparts, TownNames *town_names) |
Generates valid town name. More... | |
static uint32_t | SeedChance (uint8_t shift_by, size_t max, uint32_t seed) |
Generates a number from given seed. More... | |
static uint32_t | SeedModChance (uint8_t shift_by, size_t max, uint32_t seed) |
Generates a number from given seed. More... | |
static int32_t | SeedChanceBias (uint8_t shift_by, size_t max, uint32_t seed, int bias) |
Generates a number from given seed. More... | |
static void | ReplaceWords (const char *org, const char *rep, StringBuilder &builder, size_t start) |
Replaces a string beginning in 'org' with 'rep'. More... | |
static void | ReplaceEnglishWords (StringBuilder &builder, size_t start, bool original) |
Replaces english curses and ugly letter combinations by nicer ones. More... | |
static void | MakeEnglishOriginalTownName (StringBuilder &builder, uint32_t seed) |
Generates English (Original) town name from given seed. More... | |
static void | MakeEnglishAdditionalTownName (StringBuilder &builder, uint32_t seed) |
Generates English (Additional) town name from given seed. More... | |
static void | MakeAustrianTownName (StringBuilder &builder, uint32_t seed) |
Generates Austrian town name from given seed. More... | |
static void | MakeGermanTownName (StringBuilder &builder, uint32_t seed) |
Generates German town name from given seed. More... | |
static void | MakeSpanishTownName (StringBuilder &builder, uint32_t seed) |
Generates Latin-American town name from given seed. More... | |
static void | MakeFrenchTownName (StringBuilder &builder, uint32_t seed) |
Generates French town name from given seed. More... | |
static void | MakeSillyTownName (StringBuilder &builder, uint32_t seed) |
Generates Silly town name from given seed. More... | |
static void | MakeSwedishTownName (StringBuilder &builder, uint32_t seed) |
Generates Swedish town name from given seed. More... | |
static void | MakeDutchTownName (StringBuilder &builder, uint32_t seed) |
Generates Dutch town name from given seed. More... | |
static void | MakeFinnishTownName (StringBuilder &builder, uint32_t seed) |
Generates Finnish town name from given seed. More... | |
static void | MakePolishTownName (StringBuilder &builder, uint32_t seed) |
Generates Polish town name from given seed. More... | |
static void | MakeCzechTownName (StringBuilder &builder, uint32_t seed) |
Generates Czech town name from given seed. More... | |
static void | MakeRomanianTownName (StringBuilder &builder, uint32_t seed) |
Generates Romanian town name from given seed. More... | |
static void | MakeSlovakTownName (StringBuilder &builder, uint32_t seed) |
Generates Slovak town name from given seed. More... | |
static void | MakeNorwegianTownName (StringBuilder &builder, uint32_t seed) |
Generates Norwegian town name from given seed. More... | |
static void | MakeHungarianTownName (StringBuilder &builder, uint32_t seed) |
Generates Hungarian town name from given seed. More... | |
static void | MakeSwissTownName (StringBuilder &builder, uint32_t seed) |
Generates Swiss town name from given seed. More... | |
static void | MakeDanishTownName (StringBuilder &builder, uint32_t seed) |
Generates Danish town name from given seed. More... | |
static void | MakeTurkishTownName (StringBuilder &builder, uint32_t seed) |
Generates Turkish town name from given seed. More... | |
static void | MakeItalianTownName (StringBuilder &builder, uint32_t seed) |
Generates Italian town name from given seed. More... | |
static void | MakeCatalanTownName (StringBuilder &builder, uint32_t seed) |
Generates Catalan town name from given seed. More... | |
void | GenerateTownNameString (StringBuilder &builder, size_t lang, uint32_t seed) |
Generates town name from given seed. More... | |
Variables | |
static TownNameGenerator * | _town_name_generators [] |
Town name generators. More... | |
Town name generators.
Definition in file townname.cpp.
typedef void TownNameGenerator(StringBuilder &builder, uint32_t seed) |
Type for all town name generator functions.
builder | The builder to write the name to. |
seed | The seed of the town name. |
Definition at line 979 of file townname.cpp.
bool GenerateTownName | ( | Randomizer & | randomizer, |
uint32_t * | townnameparts, | ||
TownNames * | town_names | ||
) |
Generates valid town name.
randomizer | the source of random data for generating the name |
townnameparts | if a name is generated, it's stored there |
town_names | if a name is generated, check its uniqueness with the set |
Definition at line 136 of file townname.cpp.
References _settings_game, GameSettings::game_creation, Randomizer::Next(), Layouter::ReduceLineCache(), GameCreationSettings::town_name, and VerifyTownName().
void GenerateTownNameString | ( | StringBuilder & | builder, |
size_t | lang, | ||
uint32_t | seed | ||
) |
Generates town name from given seed.
builder | string builder to write to |
lang | town name language |
seed | generation seed |
Definition at line 1013 of file townname.cpp.
References _town_name_generators.
std::string GetTownName | ( | const Town * | t | ) |
Get the name of the given town.
t | The town to get the name for. |
Definition at line 89 of file townname.cpp.
References GetTownName().
std::string GetTownName | ( | const TownNameParams * | par, |
uint32_t | townnameparts | ||
) |
Get the town name for the given parameters and parts.
par | Town name parameters. |
townnameparts | 'Encoded' town name. |
Definition at line 65 of file townname.cpp.
void GetTownName | ( | StringBuilder & | builder, |
const Town * | t | ||
) |
Fills builder with town's name.
builder | String builder. |
t | The town to get the name from. |
Definition at line 78 of file townname.cpp.
References GetTownName().
|
static |
Fills builder with specified town name.
builder | The string builder. |
par | Town name parameters. |
townnameparts | 'Encoded' town name. |
Definition at line 48 of file townname.cpp.
References GetStringWithArgs(), TownNameParams::grfid, and TownNameParams::type.
Referenced by GetTownName(), and VerifyTownName().
|
static |
Generates Austrian town name from given seed.
builder | string builder |
seed | town name seed |
Definition at line 319 of file townname.cpp.
References SeedChanceBias().
|
static |
Generates Catalan town name from given seed.
builder | string builder |
seed | town name seed |
Definition at line 944 of file townname.cpp.
References SeedModChance().
|
static |
Generates Czech town name from given seed.
builder | string builder |
seed | town name seed |
Definition at line 589 of file townname.cpp.
References SeedModChance().
|
static |
Generates Danish town name from given seed.
builder | string builder |
seed | town name seed |
Definition at line 847 of file townname.cpp.
References SeedChanceBias().
|
static |
Generates Dutch town name from given seed.
builder | string builder |
seed | town name seed |
Definition at line 458 of file townname.cpp.
References SeedChanceBias().
|
static |
Generates English (Additional) town name from given seed.
builder | string builder |
seed | town name seed |
Definition at line 283 of file townname.cpp.
References StringBuilder::CurrentIndex(), and SeedChanceBias().
|
static |
Generates English (Original) town name from given seed.
builder | string builder |
seed | town name seed |
Definition at line 250 of file townname.cpp.
References StringBuilder::CurrentIndex(), and SeedChanceBias().
|
static |
Generates Finnish town name from given seed.
builder | string builder |
seed | town name seed |
Definition at line 481 of file townname.cpp.
References StringBuilder::CurrentIndex(), and SeedChance().
|
static |
Generates French town name from given seed.
builder | string builder |
seed | town name seed |
Definition at line 411 of file townname.cpp.
|
static |
Generates German town name from given seed.
builder | string builder |
seed | town name seed |
Definition at line 360 of file townname.cpp.
References SeedChance().
|
static |
Generates Hungarian town name from given seed.
builder | string builder |
seed | town name seed |
Definition at line 808 of file townname.cpp.
References SeedChance().
|
static |
Generates Italian town name from given seed.
builder | string builder |
seed | town name seed |
Definition at line 898 of file townname.cpp.
References SeedModChance().
|
static |
Generates Norwegian town name from given seed.
builder | string builder |
seed | town name seed |
Definition at line 786 of file townname.cpp.
References SeedChance().
|
static |
Generates Polish town name from given seed.
builder | string builder |
seed | town name seed |
Definition at line 527 of file townname.cpp.
References SeedChance().
|
static |
Generates Romanian town name from given seed.
builder | string builder |
seed | town name seed |
Definition at line 764 of file townname.cpp.
|
static |
Generates Silly town name from given seed.
builder | string builder |
seed | town name seed |
Definition at line 422 of file townname.cpp.
|
static |
Generates Slovak town name from given seed.
builder | string builder |
seed | town name seed |
Definition at line 775 of file townname.cpp.
|
static |
Generates Latin-American town name from given seed.
builder | string builder |
seed | town name seed |
Definition at line 400 of file townname.cpp.
|
static |
Generates Swedish town name from given seed.
builder | string builder |
seed | town name seed |
Definition at line 434 of file townname.cpp.
References SeedChanceBias().
|
static |
Generates Swiss town name from given seed.
builder | string builder |
seed | town name seed |
Definition at line 836 of file townname.cpp.
|
static |
Generates Turkish town name from given seed.
builder | string builder |
seed | town name seed |
Definition at line 864 of file townname.cpp.
References SeedModChance().
|
static |
Replaces english curses and ugly letter combinations by nicer ones.
builder | The builder with the town name |
start | The start index into the builder for the first town name |
original | English (Original) generator was used |
Definition at line 231 of file townname.cpp.
References ReplaceWords().
|
static |
Replaces a string beginning in 'org' with 'rep'.
org | string to replace, has to be 4 characters long |
rep | string to be replaced with, has to be 4 characters long |
builder | string builder of the town name |
start | the start index within the builder for the town name |
Definition at line 218 of file townname.cpp.
References StringBuilder::CurrentIndex().
Referenced by ReplaceEnglishWords().
|
inlinestatic |
Generates a number from given seed.
shift_by | number of bits seed is shifted to the right |
max | generated number is in interval 0...max-1 |
seed | seed |
Definition at line 169 of file townname.cpp.
References GB().
Referenced by MakeFinnishTownName(), MakeGermanTownName(), MakeHungarianTownName(), MakeNorwegianTownName(), MakePolishTownName(), and SeedChanceBias().
|
inlinestatic |
Generates a number from given seed.
shift_by | number of bits seed is shifted to the right |
max | generated number is in interval -bias...max-1 |
seed | seed |
bias | minimum value that can be returned |
Definition at line 205 of file townname.cpp.
References SeedChance().
Referenced by MakeAustrianTownName(), MakeDanishTownName(), MakeDutchTownName(), MakeEnglishAdditionalTownName(), MakeEnglishOriginalTownName(), and MakeSwedishTownName().
|
inlinestatic |
Generates a number from given seed.
Uses different algorithm than SeedChance().
shift_by | number of bits seed is shifted to the right |
max | generated number is in interval 0...max-1 |
seed | seed |
Definition at line 182 of file townname.cpp.
Referenced by MakeCatalanTownName(), MakeCzechTownName(), MakeItalianTownName(), and MakeTurkishTownName().
bool VerifyTownName | ( | uint32_t | r, |
const TownNameParams * | par, | ||
TownNames * | town_names | ||
) |
Verifies the town name is valid and unique.
r | random bits |
par | town name parameters |
town_names | if a name is generated, check its uniqueness with the set |
Definition at line 103 of file townname.cpp.
References GetTownName(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::Iterate(), MAX_LENGTH_TOWN_NAME_CHARS, and Utf8StringLength().
Referenced by GenerateTownName().
|
static |
Town name generators.
Definition at line 982 of file townname.cpp.
Referenced by GenerateTownNameString().