OpenTTD Source  20240919-master-gdf0233f4c2
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 <http://www.gnu.org/licenses/>.
6  */
7 
13 #ifndef NEWGRF_TOWNNAME_H
14 #define NEWGRF_TOWNNAME_H
15 
16 #include "strings_type.h"
17 
18 struct NamePart {
19  std::string text;
20  uint8_t id;
21  uint8_t prob;
22 };
23 
24 struct NamePartList {
25  uint8_t bitstart;
26  uint8_t bitcount;
27  uint16_t maxprob;
28  std::vector<NamePart> parts;
29 };
30 
31 struct TownNameStyle {
33  uint8_t id;
34 
35  TownNameStyle(StringID name, uint8_t id) : name(name), id(id) { }
36 };
37 
38 struct GRFTownName {
39  static const uint MAX_LISTS = 128;
40 
41  uint32_t grfid;
42  std::vector<TownNameStyle> styles;
43  std::vector<NamePartList> partlists[MAX_LISTS];
44 };
45 
46 GRFTownName *AddGRFTownName(uint32_t grfid);
47 GRFTownName *GetGRFTownName(uint32_t grfid);
48 void DelGRFTownName(uint32_t grfid);
49 void CleanUpGRFTownNames();
50 uint32_t GetGRFTownNameId(uint16_t gen);
51 uint16_t GetGRFTownNameType(uint16_t gen);
52 StringID GetGRFTownNameName(uint16_t gen);
53 
54 const std::vector<StringID> &GetGRFTownNameList();
55 
56 #endif /* NEWGRF_TOWNNAME_H */
GRFTownName::styles
std::vector< TownNameStyle > styles
Style names defined by the Town Name NewGRF.
Definition: newgrf_townname.h:42
NamePartList::maxprob
uint16_t maxprob
Total probability of all parts.
Definition: newgrf_townname.h:27
StringID
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
TownNameStyle
Definition: newgrf_townname.h:31
NamePart::id
uint8_t id
If probability bit 7 is set.
Definition: newgrf_townname.h:20
strings_type.h
TownNameStyle::name
StringID name
String ID of this town name style.
Definition: newgrf_townname.h:32
NamePartList::bitstart
uint8_t bitstart
Start of random seed bits to use.
Definition: newgrf_townname.h:25
GRFTownName::partlists
std::vector< NamePartList > partlists[MAX_LISTS]
Lists of town name parts.
Definition: newgrf_townname.h:43
NamePart::text
std::string text
If probability bit 7 is clear.
Definition: newgrf_townname.h:19
GRFTownName::grfid
uint32_t grfid
GRF ID of NewGRF.
Definition: newgrf_townname.h:41
GRFTownName
Definition: newgrf_townname.h:38
TownNameStyle::id
uint8_t id
Index within partlist for this town name style.
Definition: newgrf_townname.h:33
NamePartList
Definition: newgrf_townname.h:24
NamePart
Definition: newgrf_townname.h:18
GRFTownName::MAX_LISTS
static const uint MAX_LISTS
Maximum number of town name lists that can be defined per GRF.
Definition: newgrf_townname.h:39
NamePartList::bitcount
uint8_t bitcount
Number of bits of random seed to use.
Definition: newgrf_townname.h:26
NamePartList::parts
std::vector< NamePart > parts
List of parts to choose from.
Definition: newgrf_townname.h:28
NamePart::prob
uint8_t prob
The relative probability of the following name to appear in the bottom 7 bits.
Definition: newgrf_townname.h:21