OpenTTD Source: src/townname_func.h File Reference

OpenTTD Source 15.0-beta1

Functions
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

  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

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

Referenced by GenerateTowns().

## ◆ GetTownName() [1/2]

std::string GetTownName | ( | const Town * | t | ) |

Get the name of the given town.

Parameters

  t | The 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

  par | Town 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

  r | random bits
  par | town name parameters
  town_names | if 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 CmdFoundTown(), and GenerateTownName().