OpenTTD Source: src/townname_func.h File Reference

OpenTTD Source 13.2.1

Functions
townname_func.h File Reference
`#include "townname_type.h"`

Go to the source code of this file.

## Functions
char * | GenerateTownNameString (char *buf, const char *last, size_t lang, uint32 seed)
| Generates town name from given seed. More...
char * | GetTownName (char *buff, const TownNameParams *par, uint32 townnameparts, const char *last)
| Fills buffer with specified town name. More...
char * | GetTownName (char *buff, const Town *t, const char *last)
| Fills buffer with town's name. More...
bool | VerifyTownName (uint32 r, const TownNameParams *par, TownNames *town_names=nullptr)
| Verifies the town name is valid and unique. More...
bool | GenerateTownName (uint32 *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 | ( | uint32 * | townnameparts,
|  | TownNames * | town_names
| ) |  |

Generates valid town name.

Parameters

  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 119 of file townname.cpp.

References _generating_world, _settings_game, GameSettings::game_creation, Layouter::ReduceLineCache(), and GameCreationSettings::town_name.

## ◆ GenerateTownNameString()

char* GenerateTownNameString | ( | char * | buf,
|  | const char * | last,
|  | size_t | lang,
|  | uint32 | seed
| ) |  |

Generates town name from given seed.

Parameters

  buf | output buffer
  last | end of buffer
  lang | town name language
  seed | generation seed

Returns
  last character ('/0')

Definition at line 1052 of file townname.cpp.

References _town_name_generators, AllocaM, lengthof, TownNameGeneratorParams::min, TownNameGeneratorParams::proc, and strecpy().

## ◆ GetTownName() [1/2]

char* GetTownName | ( | char * | buff,
|  | const Town * | t,
|  | const char * | last
| ) |  |

Fills buffer with town's name.

Parameters

  buff | buffer start
  t | we want to get name of this town
  last | end of buffer

Returns
  pointer to terminating '\0'

Definition at line 68 of file townname.cpp.

References GetTownName().

## ◆ GetTownName() [2/2]

char* GetTownName | ( | char * | buff,
|  | const TownNameParams * | par,
|  | uint32 | townnameparts,
|  | const char * | last
| ) |  |

Fills buffer with specified town name.

Parameters

  buff | buffer start
  par | town name parameters
  townnameparts | 'encoded' town name
  last | end of buffer

Returns
  pointer to terminating '\0'

Definition at line 49 of file townname.cpp.

References GetStringWithArgs(), TownNameParams::grfid, and TownNameParams::type.

Referenced by GetTownName(), and VerifyTownName().

## ◆ VerifyTownName()

bool VerifyTownName | ( | uint32 | 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 82 of file townname.cpp.

References GetTownName(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::Iterate(), lastof, MAX_CHAR_LENGTH, MAX_LENGTH_TOWN_NAME_CHARS, and Utf8StringLength().