16#include "table/strings.h"
30 uint32_t grfid = _cur_gps.grffile->grfid;
35 GrfMsg(6,
"FeatureTownName: definition 0x{:02X}",
id & 0x7F);
40 bool new_scheme = _cur_gps.grffile->grf_version >= 7;
51 GrfMsg(6,
"FeatureTownName: lang 0x{:X} -> '{}'", lang, lang_name);
57 townname->
styles.emplace_back(style,
id);
61 GrfMsg(6,
"FeatureTownName: {} parts", parts);
64 for (uint partnum = 0; partnum < parts; partnum++) {
70 GrfMsg(6,
"FeatureTownName: part {} contains {} texts and will use GB(seed, {}, {})", partnum, texts, partlist.
bitstart, partlist.
bitcount);
72 partlist.
parts.reserve(texts);
73 for (uint textnum = 0; textnum < texts; textnum++) {
80 GrfMsg(0,
"FeatureTownName: definition 0x{:02X} doesn't exist, deactivating", ref_id);
81 DelGRFTownName(grfid);
86 GrfMsg(6,
"FeatureTownName: part {}, text {}, uses intermediate definition 0x{:02X} (with probability {})", partnum, textnum, ref_id, part.
prob & 0x7F);
90 GrfMsg(6,
"FeatureTownName: part {}, text {}, '{}' (with probability {})", partnum, textnum, part.
text, part.
prob);
94 GrfMsg(6,
"FeatureTownName: part {}, total probability {}", partnum, partlist.
maxprob);
98template <>
void GrfActionHandler<0x0F>::FileScan(
ByteReader &) { }
100template <>
void GrfActionHandler<0x0F>::LabelScan(
ByteReader &) { }
102template <>
void GrfActionHandler<0x0F>::Reserve(
ByteReader &) { }
103template <>
void GrfActionHandler<0x0F>::Activation(
ByteReader &) { }
static constexpr uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
constexpr T ClrBit(T &x, const uint8_t y)
Clears a bit in a variable.
Class to read from a NewGRF file.
std::string_view ReadString()
Read a NUL-terminated string.
uint8_t ReadByte()
Read a single byte (8 bits).
Functions related to debugging.
void GRFUnsafe(ByteReader &)
Set the current NewGRF as unsafe for static use.
GRFError * DisableGrf(StringID message, GRFConfig *config)
Disable a GRF.
static void FeatureTownName(ByteReader &buf)
Action 0x0F - Define Town names.
NewGRF buffer reader definition.
NewGRF internal processing state.
std::string TranslateTTDPatchCodes(uint32_t grfid, uint8_t language_id, bool allow_newlines, std::string_view str, StringControlCode byte80)
Translate TTDPatch string codes into something OpenTTD can handle (better).
StringID AddGRFString(uint32_t grfid, GRFStringID stringid, uint8_t langid_to_add, bool new_scheme, bool allow_newlines, std::string_view text_to_add, StringID def_string)
Add the new read string into our structure.
StrongType::Typedef< uint32_t, struct GRFStringIDTag, StrongType::Compare, StrongType::Integer > GRFStringID
Type for GRF-internal string IDs.
Header of Action 0F "universal holder" structure and functions.
A number of safeguards to prevent using unsafe methods.
Definition of base types and functions in a cross-platform compatible way.
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.
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.