OpenTTD Source  20240919-master-gdf0233f4c2
townname_func.h File Reference
#include "core/random_func.hpp"
#include "townname_type.h"

Go to the source code of this file.

Functions

std::string GetTownName (const TownNameParams *par, uint32_t townnameparts)
 Get the town name for the given parameters and parts. 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=nullptr)
 Verifies the town name is valid and unique. More...
 
bool GenerateTownName (Randomizer &randomizer, uint32_t *townnameparts, TownNames *town_names=nullptr)
 Generates valid town name. More...
 

Detailed Description

Town name generator stuff.

Definition in file townname_func.h.

Function Documentation

◆ GenerateTownName()

bool GenerateTownName ( Randomizer randomizer,
uint32_t *  townnameparts,
TownNames *  town_names 
)

Generates valid town name.

Parameters
randomizerthe source of random data for generating the name
townnamepartsif a name is generated, it's stored there
town_namesif a name is generated, check its uniqueness with the set
Returns
true iff a name was generated

Definition at line 136 of file townname.cpp.

References _settings_game, GameSettings::game_creation, Randomizer::Next(), Layouter::ReduceLineCache(), GameCreationSettings::town_name, and VerifyTownName().

◆ GetTownName() [1/2]

std::string GetTownName ( const Town t)

Get the name of the given town.

Parameters
tThe town to get the name for.
Returns
The town name.

Definition at line 89 of file townname.cpp.

References GetTownName().

◆ GetTownName() [2/2]

std::string GetTownName ( const TownNameParams par,
uint32_t  townnameparts 
)

Get the town name for the given parameters and parts.

Parameters
parTown name parameters.
townnameparts'Encoded' town name.
Returns
The town name.

Definition at line 65 of file townname.cpp.

◆ VerifyTownName()

bool VerifyTownName ( uint32_t  r,
const TownNameParams par,
TownNames *  town_names 
)

Verifies the town name is valid and unique.

Parameters
rrandom bits
partown name parameters
town_namesif a name is generated, check its uniqueness with the set
Returns
true iff name is valid and unique

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().