OpenTTD Source 20260711-master-g3fb3006dff
newgrf_townname.cpp File Reference

Implementation of Action 0F "universal holder" structure and functions. More...

#include "stdafx.h"
#include "newgrf_townname.h"
#include "string_func.h"
#include "strings_internal.h"
#include "table/strings.h"
#include "safeguards.h"

Go to the source code of this file.

Functions

GRFTownNameGetGRFTownName (GrfID grfid)
 Get the GRFTownName for the given GRFID.
GRFTownNameAddGRFTownName (GrfID grfid)
 Get the GRFTownName for the given GRFID or allocate one if it does not exist.
void DelGRFTownName (GrfID grfid)
 Remove the GRFTownName mapping for the given GRFID.
static void RandomPart (StringBuilder &builder, const GRFTownName *t, uint32_t seed, uint8_t id)
void GRFTownNameGenerate (StringBuilder &builder, GrfID grfid, uint16_t gen, uint32_t seed)
 Construct a NewGRF town name into the builder.
void InitGRFTownGeneratorNames ()
 Allocate memory for the NewGRF town names.
const std::vector< StringID > & GetGRFTownNameList ()
StringID GetGRFTownNameName (uint16_t gen)
void CleanUpGRFTownNames ()
GrfID GetGRFTownNameId (uint16_t gen)
uint16_t GetGRFTownNameType (uint16_t gen)

Variables

static std::vector< GRFTownName_grf_townnames
static std::vector< StringID_grf_townname_names

Detailed Description

Implementation of Action 0F "universal holder" structure and functions.

This file implements a linked-lists of townname generators, holding everything that the newgrf action 0F will send over to OpenTTD.

Definition in file newgrf_townname.cpp.

Function Documentation

◆ AddGRFTownName()

GRFTownName * AddGRFTownName ( GrfID grfid)

Get the GRFTownName for the given GRFID or allocate one if it does not exist.

Parameters
grfidThe GRFID of the town name.
Returns
The GRFTownName.

Definition at line 44 of file newgrf_townname.cpp.

References GetGRFTownName(), and GRFTownName::grfid.

Referenced by FeatureTownName().

◆ CleanUpGRFTownNames()

void CleanUpGRFTownNames ( )

Definition at line 121 of file newgrf_townname.cpp.

◆ DelGRFTownName()

void DelGRFTownName ( GrfID grfid)

Remove the GRFTownName mapping for the given GRFID.

Parameters
grfidThe NewGRF to remove for.

Definition at line 58 of file newgrf_townname.cpp.

References GRFTownName::grfid.

Referenced by FeatureTownName().

◆ GetGRFTownName()

GRFTownName * GetGRFTownName ( GrfID grfid)

Get the GRFTownName for the given GRFID.

Parameters
grfidThe GRFID of the town name.
Returns
The GRFTownName or nullptr if it does not exist.

Definition at line 32 of file newgrf_townname.cpp.

References GRFTownName::grfid.

Referenced by AddGRFTownName(), GRFTownNameGenerate(), and TownNameParams::TownNameParams().

◆ GetGRFTownNameId()

GrfID GetGRFTownNameId ( uint16_t gen)

Definition at line 126 of file newgrf_townname.cpp.

◆ GetGRFTownNameList()

const std::vector< StringID > & GetGRFTownNameList ( )

Definition at line 111 of file newgrf_townname.cpp.

◆ GetGRFTownNameName()

StringID GetGRFTownNameName ( uint16_t gen)

Definition at line 116 of file newgrf_townname.cpp.

◆ GetGRFTownNameType()

uint16_t GetGRFTownNameType ( uint16_t gen)

Definition at line 136 of file newgrf_townname.cpp.

◆ GRFTownNameGenerate()

void GRFTownNameGenerate ( StringBuilder & builder,
GrfID grfid,
uint16_t gen,
uint32_t seed )

Construct a NewGRF town name into the builder.

Parameters
builderThe string builder to write to.
grfidThe NewGRF providing the information/logic.
genThe town name style to get from the NewGRF.
seedThe random 32 bit number to generate the town name for.

Definition at line 90 of file newgrf_townname.cpp.

References GetGRFTownName(), and GRFTownName::styles.

Referenced by GetTownName().

◆ InitGRFTownGeneratorNames()

void InitGRFTownGeneratorNames ( )

Allocate memory for the NewGRF town names.

Definition at line 101 of file newgrf_townname.cpp.

References GRFTownName::styles.

Referenced by AfterLoadGRFs().

◆ RandomPart()

void RandomPart ( StringBuilder & builder,
const GRFTownName * t,
uint32_t seed,
uint8_t id )
static

Definition at line 63 of file newgrf_townname.cpp.

Variable Documentation

◆ _grf_townname_names

std::vector<StringID> _grf_townname_names
static

Definition at line 25 of file newgrf_townname.cpp.

◆ _grf_townnames

std::vector<GRFTownName> _grf_townnames
static

Definition at line 24 of file newgrf_townname.cpp.