OpenTTD Source 20260208-master-g43af8e94d0
townname_func.h File Reference

Town name generator stuff. More...

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

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, Randomizer::Next(), and VerifyTownName().

Referenced by GenerateTowns().

◆ 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.

References GetTownName().

◆ 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(), MAX_LENGTH_TOWN_NAME_CHARS, and Utf8StringLength().

Referenced by CmdFoundTown(), and GenerateTownName().