OpenTTD Source: src/newgrf/newgrf_act14.cpp Source File

OpenTTD Source 15.3

newgrf_act14.cpp
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
10#include "../stdafx.h"
11#include "../debug.h"
12#include "../newgrf_text.h"
13#include "newgrf_bytereader.h"
14#include "newgrf_internal.h"
15
16#include "../safeguards.h"
17
19 static bool ChangeGRFName(uint8_t langid, std::string_view str)
20{
21 AddGRFTextToList(_cur_gps.grfconfig->name, langid, _cur_gps.grfconfig->ident.grfid, false, str);
22 return true;
23}
24
26 static bool ChangeGRFDescription(uint8_t langid, std::string_view str)
27{
28 AddGRFTextToList(_cur_gps.grfconfig->info, langid, _cur_gps.grfconfig->ident.grfid, true, str);
29 return true;
30}
31
33 static bool ChangeGRFURL(uint8_t langid, std::string_view str)
34{
35 AddGRFTextToList(_cur_gps.grfconfig->url, langid, _cur_gps.grfconfig->ident.grfid, false, str);
36 return true;
37}
38
40 static bool ChangeGRFNumUsedParams(size_t len, ByteReader &buf)
41{
42 if (len != 1) {
43 GrfMsg(2, "StaticGRFInfo: expected only 1 byte for 'INFO'->'NPAR' but got {}, ignoring this field", len);
44 buf.Skip(len);
45 } else {
46 _cur_gps.grfconfig->num_valid_params = std::min(buf.ReadByte(), GRFConfig::MAX_NUM_PARAMS);
47 }
48 return true;
49}
50
52 static bool ChangeGRFPalette(size_t len, ByteReader &buf)
53{
54 if (len != 1) {
55 GrfMsg(2, "StaticGRFInfo: expected only 1 byte for 'INFO'->'PALS' but got {}, ignoring this field", len);
56 buf.Skip(len);
57 } else {
58 char data = buf.ReadByte();
59 GRFPalette pal = GRFP_GRF_UNSET;
60 switch (data) {
61 case '*':
62 case 'A': pal = GRFP_GRF_ANY; break;
63 case 'W': pal = GRFP_GRF_WINDOWS; break;
64 case 'D': pal = GRFP_GRF_DOS; break;
65 default:
66 GrfMsg(2, "StaticGRFInfo: unexpected value '{:02X}' for 'INFO'->'PALS', ignoring this field", data);
67 break;
68 }
69 if (pal != GRFP_GRF_UNSET) {
70 _cur_gps.grfconfig->palette &= ~GRFP_GRF_MASK;
71 _cur_gps.grfconfig->palette |= pal;
72 }
73 }
74 return true;
75}
76
78 static bool ChangeGRFBlitter(size_t len, ByteReader &buf)
79{
80 if (len != 1) {
81 GrfMsg(2, "StaticGRFInfo: expected only 1 byte for 'INFO'->'BLTR' but got {}, ignoring this field", len);
82 buf.Skip(len);
83 } else {
84 char data = buf.ReadByte();
85 GRFPalette pal = GRFP_BLT_UNSET;
86 switch (data) {
87 case '8': pal = GRFP_BLT_UNSET; break;
88 case '3': pal = GRFP_BLT_32BPP; break;
89 default:
90 GrfMsg(2, "StaticGRFInfo: unexpected value '{:02X}' for 'INFO'->'BLTR', ignoring this field", data);
91 return true;
92 }
93 _cur_gps.grfconfig->palette &= ~GRFP_BLT_MASK;
94 _cur_gps.grfconfig->palette |= pal;
95 }
96 return true;
97}
98
100 static bool ChangeGRFVersion(size_t len, ByteReader &buf)
101{
102 if (len != 4) {
103 GrfMsg(2, "StaticGRFInfo: expected 4 bytes for 'INFO'->'VRSN' but got {}, ignoring this field", len);
104 buf.Skip(len);
105 } else {
106 /* Set min_loadable_version as well (default to minimal compatibility) */
107 _cur_gps.grfconfig->version = _cur_gps.grfconfig->min_loadable_version = buf.ReadDWord();
108 }
109 return true;
110}
111
113 static bool ChangeGRFMinVersion(size_t len, ByteReader &buf)
114{
115 if (len != 4) {
116 GrfMsg(2, "StaticGRFInfo: expected 4 bytes for 'INFO'->'MINV' but got {}, ignoring this field", len);
117 buf.Skip(len);
118 } else {
119 _cur_gps.grfconfig->min_loadable_version = buf.ReadDWord();
120 if (_cur_gps.grfconfig->version == 0) {
121 GrfMsg(2, "StaticGRFInfo: 'MINV' defined before 'VRSN' or 'VRSN' set to 0, ignoring this field");
122 _cur_gps.grfconfig->min_loadable_version = 0;
123 }
124 if (_cur_gps.grfconfig->version < _cur_gps.grfconfig->min_loadable_version) {
125 GrfMsg(2, "StaticGRFInfo: 'MINV' defined as {}, limiting it to 'VRSN'", _cur_gps.grfconfig->min_loadable_version);
126 _cur_gps.grfconfig->min_loadable_version = _cur_gps.grfconfig->version;
127 }
128 }
129 return true;
130}
131
132 static GRFParameterInfo *_cur_parameter;
133
135 static bool ChangeGRFParamName(uint8_t langid, std::string_view str)
136{
137 AddGRFTextToList(_cur_parameter->name, langid, _cur_gps.grfconfig->ident.grfid, false, str);
138 return true;
139}
140
142 static bool ChangeGRFParamDescription(uint8_t langid, std::string_view str)
143{
144 AddGRFTextToList(_cur_parameter->desc, langid, _cur_gps.grfconfig->ident.grfid, true, str);
145 return true;
146}
147
149 static bool ChangeGRFParamType(size_t len, ByteReader &buf)
150{
151 if (len != 1) {
152 GrfMsg(2, "StaticGRFInfo: expected 1 byte for 'INFO'->'PARA'->'TYPE' but got {}, ignoring this field", len);
153 buf.Skip(len);
154 } else {
155 GRFParameterType type = (GRFParameterType)buf.ReadByte();
156 if (type < PTYPE_END) {
157 _cur_parameter->type = type;
158 } else {
159 GrfMsg(3, "StaticGRFInfo: unknown parameter type {}, ignoring this field", type);
160 }
161 }
162 return true;
163}
164
166 static bool ChangeGRFParamLimits(size_t len, ByteReader &buf)
167{
168 if (_cur_parameter->type != PTYPE_UINT_ENUM) {
169 GrfMsg(2, "StaticGRFInfo: 'INFO'->'PARA'->'LIMI' is only valid for parameters with type uint/enum, ignoring this field");
170 buf.Skip(len);
171 } else if (len != 8) {
172 GrfMsg(2, "StaticGRFInfo: expected 8 bytes for 'INFO'->'PARA'->'LIMI' but got {}, ignoring this field", len);
173 buf.Skip(len);
174 } else {
175 uint32_t min_value = buf.ReadDWord();
176 uint32_t max_value = buf.ReadDWord();
177 if (min_value <= max_value) {
178 _cur_parameter->min_value = min_value;
179 _cur_parameter->max_value = max_value;
180 } else {
181 GrfMsg(2, "StaticGRFInfo: 'INFO'->'PARA'->'LIMI' values are incoherent, ignoring this field");
182 }
183 }
184 return true;
185}
186
188 static bool ChangeGRFParamMask(size_t len, ByteReader &buf)
189{
190 if (len < 1 || len > 3) {
191 GrfMsg(2, "StaticGRFInfo: expected 1 to 3 bytes for 'INFO'->'PARA'->'MASK' but got {}, ignoring this field", len);
192 buf.Skip(len);
193 } else {
194 uint8_t param_nr = buf.ReadByte();
195 if (param_nr >= GRFConfig::MAX_NUM_PARAMS) {
196 GrfMsg(2, "StaticGRFInfo: invalid parameter number in 'INFO'->'PARA'->'MASK', param {}, ignoring this field", param_nr);
197 buf.Skip(len - 1);
198 } else {
199 _cur_parameter->param_nr = param_nr;
200 if (len >= 2) _cur_parameter->first_bit = std::min<uint8_t>(buf.ReadByte(), 31);
201 if (len >= 3) _cur_parameter->num_bit = std::min<uint8_t>(buf.ReadByte(), 32 - _cur_parameter->first_bit);
202 }
203 }
204
205 return true;
206}
207
209 static bool ChangeGRFParamDefault(size_t len, ByteReader &buf)
210{
211 if (len != 4) {
212 GrfMsg(2, "StaticGRFInfo: expected 4 bytes for 'INFO'->'PARA'->'DEFA' but got {}, ignoring this field", len);
213 buf.Skip(len);
214 } else {
215 _cur_parameter->def_value = buf.ReadDWord();
216 }
217 _cur_gps.grfconfig->has_param_defaults = true;
218 return true;
219}
220
221 typedef bool (*DataHandler)(size_t, ByteReader &);
222 typedef bool (*TextHandler)(uint8_t, std::string_view str);
223 typedef bool (*BranchHandler)(ByteReader &);
224
232 struct AllowedSubtags {
234 using Span = std::pair<const AllowedSubtags *, const AllowedSubtags *>;
235
236 uint32_t id;
237 std::variant<DataHandler, TextHandler, BranchHandler, Span> handler;
238};
239
240static bool SkipUnknownInfo(ByteReader &buf, uint8_t type);
241static bool HandleNodes(ByteReader &buf, std::span<const AllowedSubtags> tags);
242
249 static bool ChangeGRFParamValueNames(ByteReader &buf)
250{
251 uint8_t type = buf.ReadByte();
252 while (type != 0) {
253 uint32_t id = buf.ReadDWord();
254 if (type != 'T' || id > _cur_parameter->max_value) {
255 GrfMsg(2, "StaticGRFInfo: all child nodes of 'INFO'->'PARA'->param_num->'VALU' should have type 't' and the value/bit number as id");
256 if (!SkipUnknownInfo(buf, type)) return false;
257 type = buf.ReadByte();
258 continue;
259 }
260
261 uint8_t langid = buf.ReadByte();
262 std::string_view name_string = buf.ReadString();
263
264 auto it = std::ranges::lower_bound(_cur_parameter->value_names, id, std::less{}, &GRFParameterInfo::ValueName::first);
265 if (it == std::end(_cur_parameter->value_names) || it->first != id) {
266 it = _cur_parameter->value_names.emplace(it, id, GRFTextList{});
267 }
268 AddGRFTextToList(it->second, langid, _cur_gps.grfconfig->ident.grfid, false, name_string);
269
270 type = buf.ReadByte();
271 }
272 return true;
273}
274
276 static constexpr AllowedSubtags _tags_parameters[] = {
277 AllowedSubtags{'NAME', ChangeGRFParamName},
278 AllowedSubtags{'DESC', ChangeGRFParamDescription},
279 AllowedSubtags{'TYPE', ChangeGRFParamType},
280 AllowedSubtags{'LIMI', ChangeGRFParamLimits},
281 AllowedSubtags{'MASK', ChangeGRFParamMask},
282 AllowedSubtags{'VALU', ChangeGRFParamValueNames},
283 AllowedSubtags{'DFLT', ChangeGRFParamDefault},
284};
285
292 static bool HandleParameterInfo(ByteReader &buf)
293{
294 uint8_t type = buf.ReadByte();
295 while (type != 0) {
296 uint32_t id = buf.ReadDWord();
297 if (type != 'C' || id >= _cur_gps.grfconfig->num_valid_params) {
298 GrfMsg(2, "StaticGRFInfo: all child nodes of 'INFO'->'PARA' should have type 'C' and their parameter number as id");
299 if (!SkipUnknownInfo(buf, type)) return false;
300 type = buf.ReadByte();
301 continue;
302 }
303
304 if (id >= _cur_gps.grfconfig->param_info.size()) {
305 _cur_gps.grfconfig->param_info.resize(id + 1);
306 }
307 if (!_cur_gps.grfconfig->param_info[id].has_value()) {
308 _cur_gps.grfconfig->param_info[id] = GRFParameterInfo(id);
309 }
310 _cur_parameter = &_cur_gps.grfconfig->param_info[id].value();
311 /* Read all parameter-data and process each node. */
312 if (!HandleNodes(buf, _tags_parameters)) return false;
313 type = buf.ReadByte();
314 }
315 return true;
316}
317
319 static constexpr AllowedSubtags _tags_info[] = {
320 AllowedSubtags{'NAME', ChangeGRFName},
321 AllowedSubtags{'DESC', ChangeGRFDescription},
322 AllowedSubtags{'URL_', ChangeGRFURL},
323 AllowedSubtags{'NPAR', ChangeGRFNumUsedParams},
324 AllowedSubtags{'PALS', ChangeGRFPalette},
325 AllowedSubtags{'BLTR', ChangeGRFBlitter},
326 AllowedSubtags{'VRSN', ChangeGRFVersion},
327 AllowedSubtags{'MINV', ChangeGRFMinVersion},
328 AllowedSubtags{'PARA', HandleParameterInfo},
329};
330
332 static constexpr AllowedSubtags _tags_root[] = {
333 AllowedSubtags{'INFO', std::make_pair(std::begin(_tags_info), std::end(_tags_info))},
334};
335
336
343 static bool SkipUnknownInfo(ByteReader &buf, uint8_t type)
344{
345 /* type and id are already read */
346 switch (type) {
347 case 'C': {
348 uint8_t new_type = buf.ReadByte();
349 while (new_type != 0) {
350 buf.ReadDWord(); // skip the id
351 if (!SkipUnknownInfo(buf, new_type)) return false;
352 new_type = buf.ReadByte();
353 }
354 break;
355 }
356
357 case 'T':
358 buf.ReadByte(); // lang
359 buf.ReadString(); // actual text
360 break;
361
362 case 'B': {
363 uint16_t size = buf.ReadWord();
364 buf.Skip(size);
365 break;
366 }
367
368 default:
369 return false;
370 }
371
372 return true;
373}
374
383 static bool HandleNode(uint8_t type, uint32_t id, ByteReader &buf, std::span<const AllowedSubtags> subtags)
384{
385 /* Visitor to get a subtag handler's type. */
386 struct type_visitor {
387 char operator()(const DataHandler &) { return 'B'; }
388 char operator()(const TextHandler &) { return 'T'; }
389 char operator()(const BranchHandler &) { return 'C'; }
390 char operator()(const AllowedSubtags::Span &) { return 'C'; }
391 };
392
393 /* Visitor to evaluate a subtag handler. */
394 struct evaluate_visitor {
395 ByteReader &buf;
396
397 bool operator()(const DataHandler &handler)
398 {
399 size_t len = buf.ReadWord();
400 if (buf.Remaining() < len) return false;
401 return handler(len, buf);
402 }
403
404 bool operator()(const TextHandler &handler)
405 {
406 uint8_t langid = buf.ReadByte();
407 return handler(langid, buf.ReadString());
408 }
409
410 bool operator()(const BranchHandler &handler)
411 {
412 return handler(buf);
413 }
414
415 bool operator()(const AllowedSubtags::Span &subtags)
416 {
417 return HandleNodes(buf, {subtags.first, subtags.second});
418 }
419 };
420
421 for (const auto &tag : subtags) {
422 if (tag.id != std::byteswap(id) || std::visit(type_visitor{}, tag.handler) != type) continue;
423 return std::visit(evaluate_visitor{buf}, tag.handler);
424 }
425
426 GrfMsg(2, "StaticGRFInfo: unknown type/id combination found, type={:c}, id={:x}", type, id);
427 return SkipUnknownInfo(buf, type);
428}
429
436 static bool HandleNodes(ByteReader &buf, std::span<const AllowedSubtags> subtags)
437{
438 uint8_t type = buf.ReadByte();
439 while (type != 0) {
440 uint32_t id = buf.ReadDWord();
441 if (!HandleNode(type, id, buf, subtags)) return false;
442 type = buf.ReadByte();
443 }
444 return true;
445}
446
451 static void StaticGRFInfo(ByteReader &buf)
452{
453 /* <14> <type> <id> <text/data...> */
454 HandleNodes(buf, _tags_root);
455}
456
457template <> void GrfActionHandler<0x14>::FileScan(ByteReader &buf) { StaticGRFInfo(buf); }
458template <> void GrfActionHandler<0x14>::SafetyScan(ByteReader &) { }
459template <> void GrfActionHandler<0x14>::LabelScan(ByteReader &) { }
460template <> void GrfActionHandler<0x14>::Init(ByteReader &) { }
461template <> void GrfActionHandler<0x14>::Reserve(ByteReader &) { }
462template <> void GrfActionHandler<0x14>::Activation(ByteReader &) { }
ByteReader
Class to read from a NewGRF file.
Definition newgrf_bytereader.h:18
ByteReader::ReadDWord
uint32_t ReadDWord()
Read a single DWord (32 bits).
Definition newgrf_bytereader.h:66
ByteReader::ReadWord
uint16_t ReadWord()
Read a single Word (16 bits).
Definition newgrf_bytereader.h:45
ByteReader::ReadString
std::string_view ReadString()
Read a NUL-terminated string.
Definition newgrf_bytereader.h:91
ByteReader::ReadByte
uint8_t ReadByte()
Read a single byte (8 bits).
Definition newgrf_bytereader.h:34
ChangeGRFParamType
static bool ChangeGRFParamType(size_t len, ByteReader &buf)
Callback function for 'INFO'->'PARAM'->param_num->'TYPE' to set the typeof a parameter.
Definition newgrf_act14.cpp:149
BranchHandler
bool(* BranchHandler)(ByteReader &)
Type of callback function for branch nodes.
Definition newgrf_act14.cpp:223
ChangeGRFParamLimits
static bool ChangeGRFParamLimits(size_t len, ByteReader &buf)
Callback function for 'INFO'->'PARAM'->param_num->'LIMI' to set the min/max value of a parameter.
Definition newgrf_act14.cpp:166
ChangeGRFNumUsedParams
static bool ChangeGRFNumUsedParams(size_t len, ByteReader &buf)
Callback function for 'INFO'->'NPAR' to set the number of valid parameters.
Definition newgrf_act14.cpp:40
_tags_info
static constexpr AllowedSubtags _tags_info[]
Action14 tags for the INFO node.
Definition newgrf_act14.cpp:319
ChangeGRFURL
static bool ChangeGRFURL(uint8_t langid, std::string_view str)
Callback function for 'INFO'->'URL_' to set the newgrf url.
Definition newgrf_act14.cpp:33
DataHandler
bool(* DataHandler)(size_t, ByteReader &)
Type of callback function for binary nodes.
Definition newgrf_act14.cpp:221
ChangeGRFParamDescription
static bool ChangeGRFParamDescription(uint8_t langid, std::string_view str)
Callback function for 'INFO'->'PARAM'->param_num->'DESC' to set the description of a parameter.
Definition newgrf_act14.cpp:142
ChangeGRFMinVersion
static bool ChangeGRFMinVersion(size_t len, ByteReader &buf)
Callback function for 'INFO'->'MINV' to the minimum compatible version of the NewGRF.
Definition newgrf_act14.cpp:113
ChangeGRFParamDefault
static bool ChangeGRFParamDefault(size_t len, ByteReader &buf)
Callback function for 'INFO'->'PARAM'->param_num->'DFLT' to set the default value.
Definition newgrf_act14.cpp:209
ChangeGRFParamValueNames
static bool ChangeGRFParamValueNames(ByteReader &buf)
Callback function for 'INFO'->'PARA'->param_num->'VALU' to set the names of some parameter values (ty...
Definition newgrf_act14.cpp:249
HandleParameterInfo
static bool HandleParameterInfo(ByteReader &buf)
Callback function for 'INFO'->'PARA' to set extra information about the parameters.
Definition newgrf_act14.cpp:292
_cur_parameter
static GRFParameterInfo * _cur_parameter
The parameter which info is currently changed by the newgrf.
Definition newgrf_act14.cpp:132
HandleNodes
static bool HandleNodes(ByteReader &buf, std::span< const AllowedSubtags > tags)
Handle the contents of a 'C' choice of an Action14.
Definition newgrf_act14.cpp:436
ChangeGRFName
static bool ChangeGRFName(uint8_t langid, std::string_view str)
Callback function for 'INFO'->'NAME' to add a translation to the newgrf name.
Definition newgrf_act14.cpp:19
TextHandler
bool(* TextHandler)(uint8_t, std::string_view str)
Type of callback function for text nodes.
Definition newgrf_act14.cpp:222
_tags_root
static constexpr AllowedSubtags _tags_root[]
Action14 root tags.
Definition newgrf_act14.cpp:332
StaticGRFInfo
static void StaticGRFInfo(ByteReader &buf)
Handle Action 0x14.
Definition newgrf_act14.cpp:451
ChangeGRFParamMask
static bool ChangeGRFParamMask(size_t len, ByteReader &buf)
Callback function for 'INFO'->'PARAM'->param_num->'MASK' to set the parameter and bits to use.
Definition newgrf_act14.cpp:188
SkipUnknownInfo
static bool SkipUnknownInfo(ByteReader &buf, uint8_t type)
Try to skip the current node and all subnodes (if it's a branch node).
Definition newgrf_act14.cpp:343
ChangeGRFDescription
static bool ChangeGRFDescription(uint8_t langid, std::string_view str)
Callback function for 'INFO'->'DESC' to add a translation to the newgrf description.
Definition newgrf_act14.cpp:26
ChangeGRFPalette
static bool ChangeGRFPalette(size_t len, ByteReader &buf)
Callback function for 'INFO'->'PALS' to set the number of valid parameters.
Definition newgrf_act14.cpp:52
ChangeGRFVersion
static bool ChangeGRFVersion(size_t len, ByteReader &buf)
Callback function for 'INFO'->'VRSN' to the version of the NewGRF.
Definition newgrf_act14.cpp:100
ChangeGRFParamName
static bool ChangeGRFParamName(uint8_t langid, std::string_view str)
Callback function for 'INFO'->'PARAM'->param_num->'NAME' to set the name of a parameter.
Definition newgrf_act14.cpp:135
HandleNode
static bool HandleNode(uint8_t type, uint32_t id, ByteReader &buf, std::span< const AllowedSubtags > subtags)
Handle the nodes of an Action14.
Definition newgrf_act14.cpp:383
ChangeGRFBlitter
static bool ChangeGRFBlitter(size_t len, ByteReader &buf)
Callback function for 'INFO'->'BLTR' to set the blitter info.
Definition newgrf_act14.cpp:78
_tags_parameters
static constexpr AllowedSubtags _tags_parameters[]
Action14 parameter tags.
Definition newgrf_act14.cpp:276
newgrf_bytereader.h
NewGRF buffer reader definition.
GRFParameterType
GRFParameterType
The possible types of a newgrf parameter.
Definition newgrf_config.h:122
PTYPE_UINT_ENUM
@ PTYPE_UINT_ENUM
The parameter allows a range of numbers, each of which can have a special name.
Definition newgrf_config.h:123
PTYPE_END
@ PTYPE_END
Invalid parameter type.
Definition newgrf_config.h:125
GRFPalette
GRFPalette
Information that can/has to be stored about a GRF's palette.
Definition newgrf_config.h:59
GRFP_GRF_UNSET
@ GRFP_GRF_UNSET
The NewGRF provided no information.
Definition newgrf_config.h:70
GRFP_BLT_UNSET
@ GRFP_BLT_UNSET
The NewGRF provided no information or doesn't care about a 32 bpp blitter.
Definition newgrf_config.h:76
GRFP_GRF_WINDOWS
@ GRFP_GRF_WINDOWS
The NewGRF says the Windows palette can be used.
Definition newgrf_config.h:72
GRFP_GRF_DOS
@ GRFP_GRF_DOS
The NewGRF says the DOS palette can be used.
Definition newgrf_config.h:71
GRFP_GRF_ANY
@ GRFP_GRF_ANY
The NewGRF says any palette can be used.
Definition newgrf_config.h:73
GRFP_BLT_32BPP
@ GRFP_BLT_32BPP
The NewGRF prefers a 32 bpp blitter.
Definition newgrf_config.h:77
newgrf_internal.h
NewGRF internal processing state.
AddGRFTextToList
static void AddGRFTextToList(GRFTextList &list, uint8_t langid, std::string_view text_to_add)
Add a new text to a GRFText list.
Definition newgrf_text.cpp:478
GRFTextList
std::vector< GRFText > GRFTextList
A GRF text with a list of translations.
Definition newgrf_text_type.h:30
AllowedSubtags
Data structure to store the allowed id/type combinations for action 14.
Definition newgrf_act14.cpp:232
AllowedSubtags::id
uint32_t id
The identifier for this node.
Definition newgrf_act14.cpp:236
AllowedSubtags::handler
std::variant< DataHandler, TextHandler, BranchHandler, Span > handler
The handler for this node.
Definition newgrf_act14.cpp:237
AllowedSubtags::Span
std::pair< const AllowedSubtags *, const AllowedSubtags * > Span
Custom 'span' of subtags.
Definition newgrf_act14.cpp:234
GRFConfig::url
GRFTextWrapper url
NOSAVE: URL belonging to this GRF.
Definition newgrf_config.h:173
GRFConfig::palette
uint8_t palette
GRFPalette, bitset.
Definition newgrf_config.h:182
GRFConfig::info
GRFTextWrapper info
NOSAVE: GRF info (author, copyright, ...) (Action 0x08)
Definition newgrf_config.h:172
GRFConfig::param_info
std::vector< std::optional< GRFParameterInfo > > param_info
NOSAVE: extra information about the parameters.
Definition newgrf_config.h:184
GRFConfig::version
uint32_t version
NOSAVE: Version a NewGRF can set so only the newest NewGRF is shown.
Definition newgrf_config.h:176
GRFConfig::has_param_defaults
bool has_param_defaults
NOSAVE: did this newgrf specify any defaults for it's parameters.
Definition newgrf_config.h:183
GRFConfig::name
GRFTextWrapper name
NOSAVE: GRF name (Action 0x08)
Definition newgrf_config.h:171
GRFConfig::num_valid_params
uint8_t num_valid_params
NOSAVE: Number of valid parameters (action 0x14)
Definition newgrf_config.h:181
GRFConfig::ident
GRFIdentifier ident
grfid and md5sum to uniquely identify newgrfs
Definition newgrf_config.h:168
GRFConfig::min_loadable_version
uint32_t min_loadable_version
NOSAVE: Minimum compatible version a NewGRF can define.
Definition newgrf_config.h:177
GRFIdentifier::grfid
uint32_t grfid
GRF ID (defined by Action 0x08)
Definition newgrf_config.h:84
GRFParameterInfo
Information about one grf parameter.
Definition newgrf_config.h:129
GRFParameterInfo::param_nr
uint8_t param_nr
GRF parameter to store content in.
Definition newgrf_config.h:145
GRFParameterInfo::min_value
uint32_t min_value
The minimal value this parameter can have.
Definition newgrf_config.h:139
GRFParameterInfo::num_bit
uint8_t num_bit
Number of bits to use for this parameter.
Definition newgrf_config.h:147
GRFParameterInfo::first_bit
uint8_t first_bit
First bit to use in the GRF parameter.
Definition newgrf_config.h:146
GRFParameterInfo::max_value
uint32_t max_value
The maximal value of this parameter.
Definition newgrf_config.h:140
GRFParameterInfo::type
GRFParameterType type
The type of this parameter.
Definition newgrf_config.h:143
GRFParameterInfo::value_names
std::vector< ValueName > value_names
Names for each value.
Definition newgrf_config.h:152
GRFParameterInfo::def_value
uint32_t def_value
Default value of this parameter.
Definition newgrf_config.h:141
GRFParameterInfo::name
GRFTextList name
The name of this parameter.
Definition newgrf_config.h:136
GRFParameterInfo::desc
GRFTextList desc
The description of this parameter.
Definition newgrf_config.h:137
GrfActionHandler
GRF action handler.
Definition newgrf_internal.h:37
GrfProcessingState::grfconfig
GRFConfig * grfconfig
Config of the currently processed GRF file.
Definition newgrf_internal.h:68