|
OpenTTD Source 20260218-master-g2123fca5ea
|
NewGRF Action 0x14 handler. More...
#include "../stdafx.h"#include "../debug.h"#include "../newgrf_text.h"#include "newgrf_bytereader.h"#include "newgrf_internal.h"#include "../safeguards.h"Go to the source code of this file.
Data Structures | |
| struct | AllowedSubtags |
| Data structure to store the allowed id/type combinations for action 14. More... | |
Typedefs | |
| using | DataHandler = bool(*)(size_t len, ByteReader &buf) |
| Callback to read binary data. | |
| using | TextHandler = bool(*)(uint8_t langid, std::string_view str) |
| Callback to read text data. | |
| using | BranchHandler = bool(*)(ByteReader &buf) |
| Callback for parsing branch nodes. | |
Functions | |
| static bool | ChangeGRFName (uint8_t langid, std::string_view str) |
| Callback function for 'INFO'->'NAME' to add a translation to the newgrf name. | |
| static bool | ChangeGRFDescription (uint8_t langid, std::string_view str) |
| Callback function for 'INFO'->'DESC' to add a translation to the newgrf description. | |
| static bool | ChangeGRFURL (uint8_t langid, std::string_view str) |
| Callback function for 'INFO'->'URL_' to set the newgrf url. | |
| static bool | ChangeGRFNumUsedParams (size_t len, ByteReader &buf) |
| Callback function for 'INFO'->'NPAR' to set the number of valid parameters. | |
| static bool | ChangeGRFPalette (size_t len, ByteReader &buf) |
| Callback function for 'INFO'->'PALS' to set the number of valid parameters. | |
| static bool | ChangeGRFBlitter (size_t len, ByteReader &buf) |
| Callback function for 'INFO'->'BLTR' to set the blitter info. | |
| static bool | ChangeGRFVersion (size_t len, ByteReader &buf) |
| Callback function for 'INFO'->'VRSN' to the version of the NewGRF. | |
| static bool | ChangeGRFMinVersion (size_t len, ByteReader &buf) |
| Callback function for 'INFO'->'MINV' to the minimum compatible version of the NewGRF. | |
| 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. | |
| 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. | |
| static bool | ChangeGRFParamType (size_t len, ByteReader &buf) |
| Callback function for 'INFO'->'PARAM'->param_num->'TYPE' to set the typeof a parameter. | |
| 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. | |
| static bool | ChangeGRFParamMask (size_t len, ByteReader &buf) |
| Callback function for 'INFO'->'PARAM'->param_num->'MASK' to set the parameter and bits to use. | |
| static bool | ChangeGRFParamDefault (size_t len, ByteReader &buf) |
| Callback function for 'INFO'->'PARAM'->param_num->'DFLT' to set the default value. | |
| static bool | SkipUnknownInfo (ByteReader &buf, uint8_t type) |
| Try to skip the current node and all subnodes (if it's a branch node). | |
| static bool | HandleNodes (ByteReader &buf, std::span< const AllowedSubtags > subtags) |
| Handle the contents of a 'C' choice of an Action14. | |
| static bool | ChangeGRFParamValueNames (ByteReader &buf) |
| Callback function for 'INFO'->'PARA'->param_num->'VALU' to set the names of some parameter values (type uint/enum) or the names of some bits (type bitmask). | |
| static bool | HandleParameterInfo (ByteReader &buf) |
| Callback function for 'INFO'->'PARA' to set extra information about the parameters. | |
| static bool | HandleNode (uint8_t type, uint32_t id, ByteReader &buf, std::span< const AllowedSubtags > subtags) |
| Handle the nodes of an Action14. | |
| static void | StaticGRFInfo (ByteReader &buf) |
| Handle Action 0x14. | |
Variables | |
| static GRFParameterInfo * | _cur_parameter |
| The parameter which info is currently changed by the newgrf. | |
| static constexpr AllowedSubtags | _tags_parameters [] |
| Action14 parameter tags. | |
| static constexpr AllowedSubtags | _tags_info [] |
| Action14 tags for the INFO node. | |
| static constexpr AllowedSubtags | _tags_root [] |
| Action14 root tags. | |
NewGRF Action 0x14 handler.
Definition in file newgrf_act14.cpp.
| using BranchHandler = bool(*)(ByteReader &buf) |
Callback for parsing branch nodes.
| buf | The buffer to read from. |
true iff the data could be processed. Definition at line 242 of file newgrf_act14.cpp.
| using DataHandler = bool(*)(size_t len, ByteReader &buf) |
Callback to read binary data.
| len | The number of bytes to read. |
| buf | The buffer to read from. |
true iff the data could be processed. Definition at line 227 of file newgrf_act14.cpp.
| using TextHandler = bool(*)(uint8_t langid, std::string_view str) |
Callback to read text data.
| langid | The language the text is for. |
| str | The actual text. |
true iff the data could be processed. Definition at line 235 of file newgrf_act14.cpp.
|
static |
Callback function for 'INFO'->'BLTR' to set the blitter info.
Callback to read binary data.
| len | The number of bytes to read. |
| buf | The buffer to read from. |
true iff the data could be processed. Definition at line 78 of file newgrf_act14.cpp.
References GRFP_BLT_32BPP, GRFP_BLT_MASK, GRFP_BLT_UNSET, and ByteReader::ReadByte().
|
static |
Callback function for 'INFO'->'DESC' to add a translation to the newgrf description.
Callback to read text data.
| langid | The language the text is for. |
| str | The actual text. |
true iff the data could be processed. Definition at line 26 of file newgrf_act14.cpp.
References AddGRFTextToList().
|
static |
Callback function for 'INFO'->'MINV' to the minimum compatible version of the NewGRF.
Callback to read binary data.
| len | The number of bytes to read. |
| buf | The buffer to read from. |
true iff the data could be processed. Definition at line 113 of file newgrf_act14.cpp.
References ByteReader::ReadDWord().
|
static |
Callback function for 'INFO'->'NAME' to add a translation to the newgrf name.
Callback to read text data.
| langid | The language the text is for. |
| str | The actual text. |
true iff the data could be processed. Definition at line 19 of file newgrf_act14.cpp.
References AddGRFTextToList().
|
static |
Callback function for 'INFO'->'NPAR' to set the number of valid parameters.
Callback to read binary data.
| len | The number of bytes to read. |
| buf | The buffer to read from. |
true iff the data could be processed. Definition at line 40 of file newgrf_act14.cpp.
References ByteReader::ReadByte().
|
static |
Callback function for 'INFO'->'PALS' to set the number of valid parameters.
Callback to read binary data.
| len | The number of bytes to read. |
| buf | The buffer to read from. |
true iff the data could be processed. Definition at line 52 of file newgrf_act14.cpp.
References GRFP_GRF_ANY, GRFP_GRF_DOS, GRFP_GRF_MASK, GRFP_GRF_UNSET, GRFP_GRF_WINDOWS, and ByteReader::ReadByte().
|
static |
Callback function for 'INFO'->'PARAM'->param_num->'DFLT' to set the default value.
Callback to read binary data.
| len | The number of bytes to read. |
| buf | The buffer to read from. |
true iff the data could be processed. Definition at line 209 of file newgrf_act14.cpp.
References _cur_parameter, and ByteReader::ReadDWord().
|
static |
Callback function for 'INFO'->'PARAM'->param_num->'DESC' to set the description of a parameter.
Callback to read text data.
| langid | The language the text is for. |
| str | The actual text. |
true iff the data could be processed. Definition at line 142 of file newgrf_act14.cpp.
References _cur_parameter, and AddGRFTextToList().
|
static |
Callback function for 'INFO'->'PARAM'->param_num->'LIMI' to set the min/max value of a parameter.
Callback to read binary data.
| len | The number of bytes to read. |
| buf | The buffer to read from. |
true iff the data could be processed. Definition at line 166 of file newgrf_act14.cpp.
References _cur_parameter, PTYPE_UINT_ENUM, and ByteReader::ReadDWord().
|
static |
Callback function for 'INFO'->'PARAM'->param_num->'MASK' to set the parameter and bits to use.
Callback to read binary data.
| len | The number of bytes to read. |
| buf | The buffer to read from. |
true iff the data could be processed. Definition at line 188 of file newgrf_act14.cpp.
References _cur_parameter, and ByteReader::ReadByte().
|
static |
Callback function for 'INFO'->'PARAM'->param_num->'NAME' to set the name of a parameter.
Callback to read text data.
| langid | The language the text is for. |
| str | The actual text. |
true iff the data could be processed. Definition at line 135 of file newgrf_act14.cpp.
References _cur_parameter, and AddGRFTextToList().
|
static |
Callback function for 'INFO'->'PARAM'->param_num->'TYPE' to set the typeof a parameter.
Callback to read binary data.
| len | The number of bytes to read. |
| buf | The buffer to read from. |
true iff the data could be processed. Definition at line 149 of file newgrf_act14.cpp.
References _cur_parameter, PTYPE_END, and ByteReader::ReadByte().
|
static |
Callback function for 'INFO'->'PARA'->param_num->'VALU' to set the names of some parameter values (type uint/enum) or the names of some bits (type bitmask).
In both cases the format is the same: Each subnode should be a text node with the value/bit number as id. Callback for parsing branch nodes.
| buf | The buffer to read from. |
true iff the data could be processed. Definition at line 269 of file newgrf_act14.cpp.
References _cur_parameter, AddGRFTextToList(), ByteReader::ReadByte(), ByteReader::ReadDWord(), ByteReader::ReadString(), and SkipUnknownInfo().
|
static |
Callback function for 'INFO'->'URL_' to set the newgrf url.
Callback to read text data.
| langid | The language the text is for. |
| str | The actual text. |
true iff the data could be processed. Definition at line 33 of file newgrf_act14.cpp.
References AddGRFTextToList().
|
static |
Callback function for 'INFO'->'VRSN' to the version of the NewGRF.
Callback to read binary data.
| len | The number of bytes to read. |
| buf | The buffer to read from. |
true iff the data could be processed. Definition at line 100 of file newgrf_act14.cpp.
References ByteReader::ReadDWord().
|
static |
Handle the nodes of an Action14.
| type | Type of node. |
| id | ID. |
| buf | Buffer. |
| subtags | Allowed subtags. |
Definition at line 404 of file newgrf_act14.cpp.
References HandleNodes(), ByteReader::ReadByte(), ByteReader::ReadString(), ByteReader::ReadWord(), and SkipUnknownInfo().
Referenced by HandleNodes().
|
static |
Handle the contents of a 'C' choice of an Action14.
| buf | Buffer. |
| subtags | List of subtags. |
Definition at line 457 of file newgrf_act14.cpp.
References HandleNode(), ByteReader::ReadByte(), and ByteReader::ReadDWord().
Referenced by HandleNode(), HandleParameterInfo(), and StaticGRFInfo().
|
static |
Callback function for 'INFO'->'PARA' to set extra information about the parameters.
Each subnode of 'INFO'->'PARA' should be a branch node with the parameter number as id. The first parameter has id 0. The maximum parameter that can be changed is set by 'INFO'->'NPAR' which defaults to 80. Callback for parsing branch nodes.
| buf | The buffer to read from. |
true iff the data could be processed. Definition at line 313 of file newgrf_act14.cpp.
References _cur_parameter, _tags_parameters, HandleNodes(), ByteReader::ReadByte(), ByteReader::ReadDWord(), and SkipUnknownInfo().
|
static |
Try to skip the current node and all subnodes (if it's a branch node).
| buf | Buffer. |
| type | The node type to skip. |
Definition at line 364 of file newgrf_act14.cpp.
References ByteReader::ReadByte(), ByteReader::ReadDWord(), ByteReader::ReadString(), ByteReader::ReadWord(), and SkipUnknownInfo().
Referenced by ChangeGRFParamValueNames(), HandleNode(), HandleParameterInfo(), and SkipUnknownInfo().
|
static |
Handle Action 0x14.
| buf | Buffer. |
Definition at line 472 of file newgrf_act14.cpp.
References _tags_root, and HandleNodes().
|
static |
The parameter which info is currently changed by the newgrf.
Definition at line 132 of file newgrf_act14.cpp.
Referenced by ChangeGRFParamDefault(), ChangeGRFParamDescription(), ChangeGRFParamLimits(), ChangeGRFParamMask(), ChangeGRFParamName(), ChangeGRFParamType(), ChangeGRFParamValueNames(), and HandleParameterInfo().
|
staticconstexpr |
Action14 tags for the INFO node.
Definition at line 340 of file newgrf_act14.cpp.
|
staticconstexpr |
Action14 parameter tags.
Definition at line 296 of file newgrf_act14.cpp.
Referenced by HandleParameterInfo().
|
staticconstexpr |
Action14 root tags.
Definition at line 353 of file newgrf_act14.cpp.
Referenced by StaticGRFInfo().