OpenTTD Source 20250331-master-g3c15e0c889
|
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 | |
typedef bool(* | DataHandler) (size_t, ByteReader &) |
Type of callback function for binary nodes. | |
typedef bool(* | TextHandler) (uint8_t, std::string_view str) |
Type of callback function for text nodes. | |
typedef bool(* | BranchHandler) (ByteReader &) |
Type of callback function for 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.
typedef bool(* BranchHandler) (ByteReader &) |
Type of callback function for branch nodes.
Definition at line 223 of file newgrf_act14.cpp.
typedef bool(* DataHandler) (size_t, ByteReader &) |
Type of callback function for binary nodes.
Definition at line 221 of file newgrf_act14.cpp.
typedef bool(* TextHandler) (uint8_t, std::string_view str) |
Type of callback function for text nodes.
Definition at line 222 of file newgrf_act14.cpp.
|
static |
Callback function for 'INFO'->'BLTR' to set the blitter info.
Definition at line 78 of file newgrf_act14.cpp.
References GrfProcessingState::grfconfig, GRFP_BLT_32BPP, GRFP_BLT_UNSET, GRFConfig::palette, and ByteReader::ReadByte().
|
static |
Callback function for 'INFO'->'DESC' to add a translation to the newgrf description.
Definition at line 26 of file newgrf_act14.cpp.
References AddGRFTextToList(), GrfProcessingState::grfconfig, GRFIdentifier::grfid, GRFConfig::ident, and GRFConfig::info.
|
static |
Callback function for 'INFO'->'MINV' to the minimum compatible version of the NewGRF.
Definition at line 113 of file newgrf_act14.cpp.
References GrfProcessingState::grfconfig, GRFConfig::min_loadable_version, ByteReader::ReadDWord(), and GRFConfig::version.
|
static |
Callback function for 'INFO'->'NAME' to add a translation to the newgrf name.
Definition at line 19 of file newgrf_act14.cpp.
References AddGRFTextToList(), GrfProcessingState::grfconfig, GRFIdentifier::grfid, GRFConfig::ident, and GRFConfig::name.
|
static |
Callback function for 'INFO'->'NPAR' to set the number of valid parameters.
Definition at line 40 of file newgrf_act14.cpp.
References GrfProcessingState::grfconfig, GRFConfig::num_valid_params, and ByteReader::ReadByte().
|
static |
Callback function for 'INFO'->'PALS' to set the number of valid parameters.
Definition at line 52 of file newgrf_act14.cpp.
References GrfProcessingState::grfconfig, GRFP_GRF_ANY, GRFP_GRF_DOS, GRFP_GRF_UNSET, GRFP_GRF_WINDOWS, GRFConfig::palette, and ByteReader::ReadByte().
|
static |
Callback function for 'INFO'->'PARAM'->param_num->'DFLT' to set the default value.
Definition at line 209 of file newgrf_act14.cpp.
References _cur_parameter, GRFParameterInfo::def_value, GrfProcessingState::grfconfig, GRFConfig::has_param_defaults, and ByteReader::ReadDWord().
|
static |
Callback function for 'INFO'->'PARAM'->param_num->'DESC' to set the description of a parameter.
Definition at line 142 of file newgrf_act14.cpp.
References _cur_parameter, AddGRFTextToList(), GRFParameterInfo::desc, GrfProcessingState::grfconfig, GRFIdentifier::grfid, and GRFConfig::ident.
|
static |
Callback function for 'INFO'->'PARAM'->param_num->'LIMI' to set the min/max value of a parameter.
Definition at line 166 of file newgrf_act14.cpp.
References _cur_parameter, GRFParameterInfo::max_value, GRFParameterInfo::min_value, PTYPE_UINT_ENUM, ByteReader::ReadDWord(), and GRFParameterInfo::type.
|
static |
Callback function for 'INFO'->'PARAM'->param_num->'MASK' to set the parameter and bits to use.
Definition at line 188 of file newgrf_act14.cpp.
References _cur_parameter, GRFParameterInfo::first_bit, GRFParameterInfo::num_bit, GRFParameterInfo::param_nr, and ByteReader::ReadByte().
|
static |
Callback function for 'INFO'->'PARAM'->param_num->'NAME' to set the name of a parameter.
Definition at line 135 of file newgrf_act14.cpp.
References _cur_parameter, AddGRFTextToList(), GrfProcessingState::grfconfig, GRFIdentifier::grfid, GRFConfig::ident, and GRFParameterInfo::name.
|
static |
Callback function for 'INFO'->'PARAM'->param_num->'TYPE' to set the typeof a parameter.
Definition at line 149 of file newgrf_act14.cpp.
References _cur_parameter, PTYPE_END, ByteReader::ReadByte(), and GRFParameterInfo::type.
|
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.
Definition at line 249 of file newgrf_act14.cpp.
References _cur_parameter, AddGRFTextToList(), GrfProcessingState::grfconfig, GRFIdentifier::grfid, GRFConfig::ident, GRFParameterInfo::max_value, ByteReader::ReadByte(), ByteReader::ReadDWord(), ByteReader::ReadString(), SkipUnknownInfo(), and GRFParameterInfo::value_names.
|
static |
Callback function for 'INFO'->'URL_' to set the newgrf url.
Definition at line 33 of file newgrf_act14.cpp.
References AddGRFTextToList(), GrfProcessingState::grfconfig, GRFIdentifier::grfid, GRFConfig::ident, and GRFConfig::url.
|
static |
Callback function for 'INFO'->'VRSN' to the version of the NewGRF.
Definition at line 100 of file newgrf_act14.cpp.
References GrfProcessingState::grfconfig, GRFConfig::min_loadable_version, ByteReader::ReadDWord(), and GRFConfig::version.
|
static |
Handle the nodes of an Action14.
type | Type of node. |
id | ID. |
buf | Buffer. |
subtags | Allowed subtags. |
Definition at line 383 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 436 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.
Definition at line 292 of file newgrf_act14.cpp.
References _cur_parameter, _tags_parameters, GrfProcessingState::grfconfig, HandleNodes(), GRFConfig::num_valid_params, GRFConfig::param_info, 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 343 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 451 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 319 of file newgrf_act14.cpp.
|
staticconstexpr |
Action14 parameter tags.
Definition at line 276 of file newgrf_act14.cpp.
Referenced by HandleParameterInfo().
|
staticconstexpr |
Action14 root tags.
Definition at line 332 of file newgrf_act14.cpp.
Referenced by StaticGRFInfo().