OpenTTD Source 20260711-master-g3fb3006dff
newgrf_townname.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
9
10#ifndef NEWGRF_TOWNNAME_H
11#define NEWGRF_TOWNNAME_H
12
13#include "newgrf_type.h"
14#include "strings_type.h"
15
16struct NamePart {
17 std::string text;
18 uint8_t id;
19 uint8_t prob;
20};
21
23 uint8_t bitstart;
24 uint8_t bitcount;
25 uint16_t maxprob;
26 std::vector<NamePart> parts;
27};
28
29struct TownNameStyle {
31 uint8_t id;
32
33 TownNameStyle(StringID name, uint8_t id) : name(name), id(id) { }
34};
35
37 static const uint MAX_LISTS = 128;
38
40 std::vector<TownNameStyle> styles;
41 std::vector<NamePartList> partlists[MAX_LISTS];
42};
43
46void DelGRFTownName(GrfID grfid);
47void CleanUpGRFTownNames();
48GrfID GetGRFTownNameId(uint16_t gen);
49uint16_t GetGRFTownNameType(uint16_t gen);
50StringID GetGRFTownNameName(uint16_t gen);
51
52const std::vector<StringID> &GetGRFTownNameList();
53
54#endif /* NEWGRF_TOWNNAME_H */
GRFTownName * GetGRFTownName(GrfID grfid)
Get the GRFTownName for the given GRFID.
void DelGRFTownName(GrfID grfid)
Remove the GRFTownName mapping for the given GRFID.
GRFTownName * AddGRFTownName(GrfID grfid)
Get the GRFTownName for the given GRFID or allocate one if it does not exist.
Commonly used types for the NewGRF implementation.
uint32_t GrfID
The unique identifier of a NewGRF.
Definition newgrf_type.h:15
Types related to strings.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
std::vector< NamePartList > partlists[MAX_LISTS]
Lists of town name parts.
GrfID grfid
GRF ID of NewGRF.
static const uint MAX_LISTS
Maximum number of town name lists that can be defined per GRF.
std::vector< TownNameStyle > styles
Style names defined by the Town Name NewGRF.
uint8_t bitcount
Number of bits of random seed to use.
uint16_t maxprob
Total probability of all parts.
std::vector< NamePart > parts
List of parts to choose from.
uint8_t bitstart
Start of random seed bits to use.
uint8_t prob
The relative probability of the following name to appear in the bottom 7 bits.
uint8_t id
If probability bit 7 is set.
std::string text
If probability bit 7 is clear.
StringID name
String ID of this town name style.
uint8_t id
Index within partlist for this town name style.