OpenTTD Source 20250205-master-gfd85ab1e2c
|
Information about GRF, used in the game and (part of it) in savegames. More...
#include <newgrf_config.h>
Public Member Functions | |
GRFConfig (const std::string &filename) | |
GRFConfig (const GRFConfig &config) | |
Create a new GRFConfig that is a deep copy of an existing config. | |
GRFConfig & | operator= (GRFConfig &rhs)=delete |
bool | IsCompatible (uint32_t old_version) const |
Return whether this NewGRF can replace an older version of the same NewGRF. | |
void | SetParams (std::span< const uint32_t > pars) |
void | CopyParams (const GRFConfig &src) |
Copy the parameter information from the src config. | |
uint32_t | GetValue (const GRFParameterInfo &info) const |
Get the value of the given user-changeable parameter. | |
void | SetValue (const GRFParameterInfo &info, uint32_t value) |
Set the value of the given user-changeable parameter. | |
std::optional< std::string > | GetTextfile (TextfileType type) const |
Search a textfile file next to this NewGRF. | |
const char * | GetName () const |
Get the name of this grf. | |
const char * | GetDescription () const |
Get the grf info. | |
const char * | GetURL () const |
Get the grf url. | |
void | SetParameterDefaults () |
Set the default value for all parameters as specified by action14. | |
void | SetSuitablePalette () |
Set the palette of this GRFConfig to something suitable. | |
void | FinalizeParameterInfo () |
Finalize Action 14 info after file scan is finished. | |
Data Fields | |
GRFIdentifier | ident {} |
grfid and md5sum to uniquely identify newgrfs | |
MD5Hash | original_md5sum {} |
MD5 checksum of original file if only a 'compatible' file was loaded. | |
std::string | filename {} |
Filename - either with or without full path. | |
GRFTextWrapper | name {} |
NOSAVE: GRF name (Action 0x08) | |
GRFTextWrapper | info {} |
NOSAVE: GRF info (author, copyright, ...) (Action 0x08) | |
GRFTextWrapper | url {} |
NOSAVE: URL belonging to this GRF. | |
std::optional< GRFError > | error = std::nullopt |
NOSAVE: Error/Warning during GRF loading (Action 0x0B) | |
uint32_t | version = 0 |
NOSAVE: Version a NewGRF can set so only the newest NewGRF is shown. | |
uint32_t | min_loadable_version = 0 |
NOSAVE: Minimum compatible version a NewGRF can define. | |
GRFConfigFlags | flags = {} |
NOSAVE: GCF_Flags, bitset. | |
GRFStatus | status = GCS_UNKNOWN |
NOSAVE: GRFStatus, enum. | |
GRFBugs | grf_bugs = {} |
NOSAVE: bugs in this GRF in this run,. | |
uint8_t | num_valid_params = MAX_NUM_PARAMS |
NOSAVE: Number of valid parameters (action 0x14) | |
uint8_t | palette = 0 |
GRFPalette, bitset. | |
bool | has_param_defaults = false |
NOSAVE: did this newgrf specify any defaults for it's parameters. | |
std::vector< std::optional< GRFParameterInfo > > | param_info |
NOSAVE: extra information about the parameters. | |
std::vector< uint32_t > | param |
GRF parameters. | |
Static Public Attributes | |
static constexpr uint8_t | MAX_NUM_PARAMS = 0x80 |
Information about GRF, used in the game and (part of it) in savegames.
Definition at line 156 of file newgrf_config.h.
|
inline |
Definition at line 160 of file newgrf_config.h.
GRFConfig::GRFConfig | ( | const GRFConfig & | config | ) |
Create a new GRFConfig that is a deep copy of an existing config.
config | The GRFConfig object to make a copy of. |
Definition at line 36 of file newgrf_config.cpp.
References Copy, flags, and EnumBitSet< Tenum, Tstorage >::Reset().
void GRFConfig::CopyParams | ( | const GRFConfig & | src | ) |
Copy the parameter information from the src config.
src | Source config. |
Definition at line 75 of file newgrf_config.cpp.
References param.
void GRFConfig::FinalizeParameterInfo | ( | ) |
Finalize Action 14 info after file scan is finished.
Definition at line 141 of file newgrf_config.cpp.
References info, and param_info.
Referenced by FillGRFDetails().
const char * GRFConfig::GetDescription | ( | ) | const |
Get the grf info.
Definition at line 95 of file newgrf_config.cpp.
References GetGRFStringFromGRFText(), and info.
const char * GRFConfig::GetName | ( | ) | const |
Get the name of this grf.
In case the name isn't known the filename is returned.
Definition at line 85 of file newgrf_config.cpp.
References filename, GetGRFStringFromGRFText(), name, and StrEmpty().
Referenced by DisableStaticNewGRFInfluencingNonStaticNewGRFs(), DrawVehiclePurchaseInfo(), NewGRFWindow::DrawWidget(), ErrorUnknownCallbackResult(), NewGRFWindow::NameSorter(), NewGRFTextfileWindow::SetStringParameters(), ShowMissingContentWindow(), and ShowNewGrfVehicleError().
std::optional< std::string > GRFConfig::GetTextfile | ( | TextfileType | type | ) | const |
Search a textfile file next to this NewGRF.
type | The type of the textfile to search for. |
Definition at line 654 of file newgrf_config.cpp.
References filename, and NEWGRF_DIR.
Referenced by NewGRFWindow::OnInvalidateData().
const char * GRFConfig::GetURL | ( | ) | const |
Get the grf url.
Definition at line 104 of file newgrf_config.cpp.
References GetGRFStringFromGRFText(), and url.
Referenced by NewGRFWindow::OnClick().
uint32_t GRFConfig::GetValue | ( | const GRFParameterInfo & | info | ) | const |
Get the value of the given user-changeable parameter.
info | The grf parameter info to get the value for. |
Definition at line 169 of file newgrf_config.cpp.
References GB(), info, param, and GRFParameterInfo::param_nr.
Referenced by NewGRFParametersWindow::DrawWidget(), and NewGRFParametersWindow::OnClick().
bool GRFConfig::IsCompatible | ( | uint32_t | old_version | ) | const |
Return whether this NewGRF can replace an older version of the same NewGRF.
Definition at line 66 of file newgrf_config.cpp.
References min_loadable_version, and version.
Referenced by openttd_main().
void GRFConfig::SetParameterDefaults | ( | ) |
Set the default value for all parameters as specified by action14.
Definition at line 110 of file newgrf_config.cpp.
References has_param_defaults, info, param, param_info, and SetValue().
Referenced by NewGRFParametersWindow::OnClick(), and GameOptionsWindow::OnClick().
void GRFConfig::SetParams | ( | std::span< const uint32_t > | pars | ) |
Definition at line 58 of file newgrf_config.cpp.
void GRFConfig::SetSuitablePalette | ( | ) |
Set the palette of this GRFConfig to something suitable.
That is either the setting coming from the NewGRF or the globally used palette.
Definition at line 127 of file newgrf_config.cpp.
References _settings_client, GRFP_GRF_DOS, GRFP_GRF_MASK, GRFP_GRF_WINDOWS, GRFP_USE_BIT, GRFP_USE_DOS, GRFP_USE_WINDOWS, ClientSettings::gui, GUISettings::newgrf_default_palette, PAL_DOS, PAL_WINDOWS, palette, and SB().
Referenced by FillGRFDetails().
void GRFConfig::SetValue | ( | const GRFParameterInfo & | info, |
uint32_t | value | ||
) |
Set the value of the given user-changeable parameter.
info | The grf parameter info to set the value for. |
value | The new value. |
Definition at line 185 of file newgrf_config.cpp.
References Clamp(), info, param, GRFParameterInfo::param_nr, SB(), SetWindowDirty(), WC_GAME_OPTIONS, and WN_GAME_OPTIONS_NEWGRF_STATE.
Referenced by NewGRFParametersWindow::OnClick(), NewGRFParametersWindow::OnDropdownSelect(), NewGRFParametersWindow::OnQueryTextFinished(), and SetParameterDefaults().
std::optional<GRFError> GRFConfig::error = std::nullopt |
NOSAVE: Error/Warning during GRF loading (Action 0x0B)
Definition at line 172 of file newgrf_config.h.
Referenced by NewGRFWindow::DrawWidget(), LoadNewGRF(), and ResetNewGRFErrors().
std::string GRFConfig::filename {} |
Filename - either with or without full path.
Definition at line 168 of file newgrf_config.h.
Referenced by GRFFileScanner::AddFile(), AddGrfInfo(), CalcGRFMD5Sum(), FillGRFDetails(), GetName(), ContentInfo::GetTextfile(), GetTextfile(), GRFFile::GRFFile(), GrfMsgI(), InitNewGRFFile(), IsGoodGRFConfigList(), LoadNewGRF(), LoadNewGRFFile(), LoadNewGRFFileFromFile(), and NetworkAfterNewGRFScan().
GRFConfigFlags GRFConfig::flags = {} |
NOSAVE: GCF_Flags, bitset.
Definition at line 176 of file newgrf_config.h.
Referenced by NewGRFWindow::AddGRFToActive(), FillGRFDetails(), NewGRFWindow::GetPalette(), GRFConfig(), GRFUnsafe(), IsGoodGRFConfigList(), IsLoggableGrfConfig(), LoadNewGRF(), LoadNewGRFFile(), NewGRFWindow::OnClick(), NewGRFWindow::OnInvalidateData(), ParamSet(), and ShowMissingContentWindow().
GRFBugs GRFConfig::grf_bugs = {} |
NOSAVE: bugs in this GRF in this run,.
Definition at line 178 of file newgrf_config.h.
Referenced by ErrorUnknownCallbackResult(), ShowNewGrfVehicleError(), and VehicleLengthChanged().
bool GRFConfig::has_param_defaults = false |
NOSAVE: did this newgrf specify any defaults for it's parameters.
Definition at line 181 of file newgrf_config.h.
Referenced by ChangeGRFParamDefault(), IsGoodGRFConfigList(), and SetParameterDefaults().
GRFIdentifier GRFConfig::ident {} |
grfid and md5sum to uniquely identify newgrfs
Definition at line 166 of file newgrf_config.h.
Referenced by NewGRFWindow::AddGRFToActive(), CalcGRFMD5Sum(), ChangeGRFDescription(), ChangeGRFName(), ChangeGRFParamDescription(), ChangeGRFParamName(), ChangeGRFParamValueNames(), ChangeGRFURL(), FillGRFDetails(), FillGrfidMap(), Gamelog::GetOverriddenIdentifier(), Gamelog::GRFAdd(), GRFFile::GRFFile(), Gamelog::GRFUpdate(), IsGoodGRFConfigList(), LoadNewGRF(), NewGRFWindow::NameSorter(), NewGRFWindow::OnInvalidateData(), and ShowMissingContentWindow().
GRFTextWrapper GRFConfig::info {} |
NOSAVE: GRF info (author, copyright, ...) (Action 0x08)
Definition at line 170 of file newgrf_config.h.
Referenced by ChangeGRFDescription(), FinalizeParameterInfo(), GetDescription(), GetValue(), NetworkAfterNewGRFScan(), SetParameterDefaults(), and SetValue().
|
staticconstexpr |
Definition at line 157 of file newgrf_config.h.
uint32_t GRFConfig::min_loadable_version = 0 |
NOSAVE: Minimum compatible version a NewGRF can define.
Definition at line 175 of file newgrf_config.h.
Referenced by ChangeGRFMinVersion(), ChangeGRFVersion(), IsCompatible(), and IsGoodGRFConfigList().
GRFTextWrapper GRFConfig::name {} |
NOSAVE: GRF name (Action 0x08)
Definition at line 169 of file newgrf_config.h.
Referenced by GRFFileScanner::AddFile(), ChangeGRFName(), GetName(), IsGoodGRFConfigList(), and NetworkAfterNewGRFScan().
uint8_t GRFConfig::num_valid_params = MAX_NUM_PARAMS |
NOSAVE: Number of valid parameters (action 0x14)
Definition at line 179 of file newgrf_config.h.
Referenced by ChangeGRFNumUsedParams(), HandleParameterInfo(), IsGoodGRFConfigList(), NewGRFWindow::OnClick(), NewGRFParametersWindow::OnInvalidateData(), and NewGRFWindow::OnInvalidateData().
MD5Hash GRFConfig::original_md5sum {} |
MD5 checksum of original file if only a 'compatible' file was loaded.
Definition at line 167 of file newgrf_config.h.
Referenced by NewGRFWindow::OnInvalidateData(), and ShowMissingContentWindow().
uint8_t GRFConfig::palette = 0 |
GRFPalette, bitset.
Definition at line 180 of file newgrf_config.h.
Referenced by ChangeGRFBlitter(), ChangeGRFPalette(), GetGlobalVariable(), LoadNewGRFFile(), NewGRFWindow::OnClick(), and SetSuitablePalette().
std::vector<uint32_t> GRFConfig::param |
GRF parameters.
Definition at line 183 of file newgrf_config.h.
Referenced by CopyParams(), GetValue(), GraphicsSetSaveConfig(), GRFBuildParamList(), GRFFile::GRFFile(), Gamelog::GRFUpdate(), NewGRFParametersWindow::OnClick(), GameOptionsWindow::OnClick(), NewGRFParametersWindow::OnInvalidateData(), SetParameterDefaults(), SetValue(), and SurveyConfiguration().
std::vector<std::optional<GRFParameterInfo> > GRFConfig::param_info |
NOSAVE: extra information about the parameters.
Definition at line 182 of file newgrf_config.h.
Referenced by FinalizeParameterInfo(), NewGRFParametersWindow::GetParameterInfo(), HandleParameterInfo(), NewGRFParametersWindow::HasParameterInfo(), IsGoodGRFConfigList(), SetParameterDefaults(), and NewGRFParametersWindow::UpdateWidgetSize().
GRFStatus GRFConfig::status = GCS_UNKNOWN |
NOSAVE: GRFStatus, enum.
Definition at line 177 of file newgrf_config.h.
Referenced by FillGRFDetails(), NewGRFWindow::GetPalette(), IsLoggableGrfConfig(), LoadNewGRF(), LoadNewGRFFile(), NewGRFWindow::OnInvalidateData(), ParamSet(), ShowMissingContentWindow(), and TranslateGRFStrings().
GRFTextWrapper GRFConfig::url {} |
NOSAVE: URL belonging to this GRF.
Definition at line 171 of file newgrf_config.h.
Referenced by ChangeGRFURL(), and GetURL().
uint32_t GRFConfig::version = 0 |
NOSAVE: Version a NewGRF can set so only the newest NewGRF is shown.
Definition at line 174 of file newgrf_config.h.
Referenced by ChangeGRFMinVersion(), ChangeGRFVersion(), FindGRFConfig(), GraphicsSetSaveConfig(), IsCompatible(), IsGoodGRFConfigList(), NewGRFWindow::NameSorter(), and ParamSet().