OpenTTD Source 20250205-master-gfd85ab1e2c
|
Functions to find and configure NewGRFs. More...
#include "strings_type.h"
#include "fileio_type.h"
#include "textfile_type.h"
#include "newgrf_text.h"
#include "3rdparty/md5/md5.h"
Go to the source code of this file.
Data Structures | |
struct | GRFIdentifier |
Basic data to distinguish a GRF. More... | |
struct | GRFError |
Information about why GRF had problems during initialisation. More... | |
struct | GRFParameterInfo |
Information about one grf parameter. More... | |
struct | GRFConfig |
Information about GRF, used in the game and (part of it) in savegames. More... | |
struct | NewGRFScanCallback |
Callback for NewGRF scanning. More... | |
Typedefs | |
using | GRFConfigFlags = EnumBitSet< GRFConfigFlag, uint8_t > |
using | GRFBugs = EnumBitSet< GRFBug, uint8_t > |
using | GRFConfigList = std::vector< std::unique_ptr< GRFConfig > > |
Enumerations | |
enum | GRFConfigFlag : uint8_t { System , Unsafe , Static , Compatible , Copy , InitOnly , Reserved , Invalid } |
GRF config bit flags. More... | |
enum | GRFStatus : uint8_t { GCS_UNKNOWN , GCS_DISABLED , GCS_NOT_FOUND , GCS_INITIALISED , GCS_ACTIVATED } |
Status of GRF. More... | |
enum class | GRFBug : uint8_t { VehLength = 0 , VehRefit = 1 , VehPoweredWagon = 2 , UnknownCbResult = 3 , VehCapacity = 4 } |
Encountered GRF bugs. More... | |
enum | GRFListCompatibility : uint8_t { GLC_ALL_GOOD , GLC_COMPATIBLE , GLC_NOT_FOUND } |
Status of post-gameload GRF compatibility check. More... | |
enum | GRFPalette : uint8_t { GRFP_USE_BIT = 0 , GRFP_GRF_OFFSET = 2 , GRFP_GRF_SIZE = 2 , GRFP_BLT_OFFSET = 4 , GRFP_BLT_SIZE = 1 , GRFP_USE_DOS = 0x0 , GRFP_USE_WINDOWS = 0x1 , GRFP_USE_MASK = 0x1 , GRFP_GRF_UNSET = 0x0 << GRFP_GRF_OFFSET , GRFP_GRF_DOS = 0x1 << GRFP_GRF_OFFSET , GRFP_GRF_WINDOWS = 0x2 << GRFP_GRF_OFFSET , GRFP_GRF_ANY = GRFP_GRF_DOS | GRFP_GRF_WINDOWS , GRFP_GRF_MASK = GRFP_GRF_ANY , GRFP_BLT_UNSET = 0x0 << GRFP_BLT_OFFSET , GRFP_BLT_32BPP = 0x1 << GRFP_BLT_OFFSET , GRFP_BLT_MASK = GRFP_BLT_32BPP } |
Information that can/has to be stored about a GRF's palette. More... | |
enum | GRFParameterType : uint8_t { PTYPE_UINT_ENUM , PTYPE_BOOL , PTYPE_END } |
The possible types of a newgrf parameter. More... | |
enum | FindGRFConfigMode : uint8_t { FGCM_EXACT , FGCM_COMPATIBLE , FGCM_NEWEST , FGCM_NEWEST_VALID , FGCM_ANY } |
Method to find GRFs using FindGRFConfig. More... | |
Functions | |
size_t | GRFGetSizeOfDataSection (FileHandle &f) |
Get the data section size of a GRF. | |
void | ScanNewGRFFiles (NewGRFScanCallback *callback) |
Scan for all NewGRFs. | |
const GRFConfig * | FindGRFConfig (uint32_t grfid, FindGRFConfigMode mode, const MD5Hash *md5sum=nullptr, uint32_t desired_version=0) |
Find a NewGRF in the scanned list. | |
GRFConfig * | GetGRFConfig (uint32_t grfid, uint32_t mask=0xFFFFFFFF) |
Retrieve a NewGRF from the current config by its grfid. | |
void | CopyGRFConfigList (GRFConfigList &dst, const GRFConfigList &src, bool init_only) |
Copy a GRF Config list. | |
void | AppendStaticGRFConfigs (GRFConfigList &dst) |
Appends the static GRFs to a list of GRFs. | |
void | AppendToGRFConfigList (GRFConfigList &dst, std::unique_ptr< GRFConfig > &&el) |
Appends an element to a list of GRFs. | |
void | ClearGRFConfigList (GRFConfigList &config) |
Clear a GRF Config list, freeing all nodes. | |
void | ResetGRFConfig (bool defaults) |
Reset the current GRF Config to either blank or newgame settings. | |
GRFListCompatibility | IsGoodGRFConfigList (GRFConfigList &grfconfig) |
Check if all GRFs in the GRF config from a savegame can be loaded. | |
bool | FillGRFDetails (GRFConfig &config, bool is_static, Subdirectory subdir=NEWGRF_DIR) |
Find the GRFID of a given grf, and calculate its md5sum. | |
std::string | GRFBuildParamList (const GRFConfig &c) |
Build a string containing space separated parameter values, and terminate. | |
void | ShowNewGRFSettings (bool editable, bool show_params, bool exec_changes, GRFConfigList &config) |
Setup the NewGRF gui. | |
void | OpenGRFParameterWindow (bool is_baseset, GRFConfig &c, bool editable) |
void | UpdateNewGRFScanStatus (uint num, const char *name) |
Update the NewGRF scan status. | |
void | UpdateNewGRFConfigPalette (int32_t new_value=0) |
Update the palettes of the graphics from the config file. | |
Variables | |
GRFConfigList | _all_grfs |
First item in list of all scanned NewGRFs. | |
GRFConfigList | _grfconfig |
First item in list of current GRF set up. | |
GRFConfigList | _grfconfig_newgame |
First item in list of default GRF set up. | |
GRFConfigList | _grfconfig_static |
First item in list of static GRF set up. | |
uint | _missing_extra_graphics |
Number of sprites provided by the fallback extra GRF, i.e. missing in the baseset. | |
Functions to find and configure NewGRFs.
Definition in file newgrf_config.h.
using GRFBugs = EnumBitSet<GRFBug, uint8_t> |
Definition at line 49 of file newgrf_config.h.
using GRFConfigFlags = EnumBitSet<GRFConfigFlag, uint8_t> |
Definition at line 30 of file newgrf_config.h.
using GRFConfigList = std::vector<std::unique_ptr<GRFConfig> > |
Definition at line 202 of file newgrf_config.h.
enum FindGRFConfigMode : uint8_t |
Method to find GRFs using FindGRFConfig.
Definition at line 205 of file newgrf_config.h.
|
strong |
Encountered GRF bugs.
Definition at line 42 of file newgrf_config.h.
enum GRFConfigFlag : uint8_t |
GRF config bit flags.
Definition at line 20 of file newgrf_config.h.
enum GRFListCompatibility : uint8_t |
Status of post-gameload GRF compatibility check.
Definition at line 52 of file newgrf_config.h.
enum GRFPalette : uint8_t |
Information that can/has to be stored about a GRF's palette.
Definition at line 59 of file newgrf_config.h.
enum GRFParameterType : uint8_t |
The possible types of a newgrf parameter.
Enumerator | |
---|---|
PTYPE_UINT_ENUM | The parameter allows a range of numbers, each of which can have a special name. |
PTYPE_BOOL | The parameter is either 0 or 1. |
PTYPE_END | Invalid parameter type. |
Definition at line 120 of file newgrf_config.h.
enum GRFStatus : uint8_t |
Status of GRF.
Definition at line 33 of file newgrf_config.h.
void AppendStaticGRFConfigs | ( | GRFConfigList & | dst | ) |
Appends the static GRFs to a list of GRFs.
dst | the head of the list to add to |
Definition at line 393 of file newgrf_config.cpp.
References _grfconfig_static, AppendGRFConfigList(), and RemoveDuplicatesFromGRFConfigList().
Referenced by NGRFChunkHandler::Load(), and ResetGRFConfig().
void AppendToGRFConfigList | ( | GRFConfigList & | dst, |
std::unique_ptr< GRFConfig > && | el | ||
) |
Appends an element to a list of GRFs.
dst | the head of the list to add to |
el | the new tail to be |
Definition at line 404 of file newgrf_config.cpp.
References RemoveDuplicatesFromGRFConfigList().
void ClearGRFConfigList | ( | GRFConfigList & | config | ) |
Clear a GRF Config list, freeing all nodes.
config | Start of the list. |
nullptr
. Definition at line 329 of file newgrf_config.cpp.
Referenced by LoadCheckData::Clear(), CopyGRFConfigList(), DoLoad(), DoScanNewGRFFiles(), NetworkAddServer(), NewGRFWindow::OnDropdownSelect(), ClientNetworkCoordinatorSocketHandler::Receive_GC_LISTING(), QueryNetworkGameSocketHandler::Receive_SERVER_GAME_INFO(), and SaveOrLoad().
void CopyGRFConfigList | ( | GRFConfigList & | dst, |
const GRFConfigList & | src, | ||
bool | init_only | ||
) |
Copy a GRF Config list.
dst | The destination list |
src | The source list |
init_only | the copied GRF will be processed up to GLS_INIT |
Definition at line 358 of file newgrf_config.cpp.
References AppendGRFConfigList(), and ClearGRFConfigList().
Referenced by NewGRFWindow::Close(), NewGRFConfirmationCallback(), NewGRFWindow::OnClick(), and ResetGRFConfig().
bool FillGRFDetails | ( | GRFConfig & | config, |
bool | is_static, | ||
Subdirectory | subdir | ||
) |
Find the GRFID of a given grf, and calculate its md5sum.
config | grf to fill. |
is_static | grf is static. |
subdir | the subdirectory to search in. |
Definition at line 297 of file newgrf_config.cpp.
References CalcGRFMD5Sum(), GRFConfig::filename, GRFConfig::FinalizeParameterInfo(), FioCheckFileExists(), GRFConfig::flags, GCS_NOT_FOUND, GRFIdentifier::grfid, GRFConfig::ident, LoadNewGRFFile(), GRFConfig::SetSuitablePalette(), GRFConfig::status, System, EnumBitSet< Tenum, Tstorage >::Test(), and Unsafe.
Referenced by GRFFileScanner::AddFile(), GetDefaultExtraGRFConfig(), GraphicsSet::GetOrCreateExtraConfig(), and GRFLoadConfig().
const GRFConfig * FindGRFConfig | ( | uint32_t | grfid, |
FindGRFConfigMode | mode, | ||
const MD5Hash * | md5sum, | ||
uint32_t | desired_version | ||
) |
Find a NewGRF in the scanned list.
grfid | GRFID to look for, |
mode | Restrictions for matching grfs |
md5sum | Expected MD5 sum |
desired_version | Requested version |
nullptr
. Definition at line 603 of file newgrf_config.cpp.
References _all_grfs, FGCM_ANY, FGCM_COMPATIBLE, FGCM_EXACT, FGCM_NEWEST, Invalid, and GRFConfig::version.
Referenced by AddGrfInfo(), ContentInfo::GetTextfile(), GRFLoadConfig(), HasGRFConfig(), IsGoodGRFConfigList(), NetworkAfterNewGRFScan(), NewGRFWindow::OnInvalidateData(), and ClientNetworkGameSocketHandler::Receive_SERVER_CHECK_NEWGRFS().
GRFConfig * GetGRFConfig | ( | uint32_t | grfid, |
uint32_t | mask | ||
) |
Retrieve a NewGRF from the current config by its grfid.
grfid | grf to look for. |
mask | GRFID mask to allow for partial matching. |
nullptr
. Definition at line 629 of file newgrf_config.cpp.
References _grfconfig.
Referenced by DrawVehiclePurchaseInfo(), ErrorUnknownCallbackResult(), ParamSet(), ShowNewGrfVehicleError(), TranslateGRFStrings(), and VehicleLengthChanged().
std::string GRFBuildParamList | ( | const GRFConfig & | c | ) |
Build a string containing space separated parameter values, and terminate.
Definition at line 639 of file newgrf_config.cpp.
References GRFConfig::param.
Referenced by GraphicsSetSaveConfig().
size_t GRFGetSizeOfDataSection | ( | FileHandle & | f | ) |
Get the data section size of a GRF.
f | GRF. |
Definition at line 232 of file newgrf_config.cpp.
References _grf_cont_v2_sig, Debug, and MemCmpT().
Referenced by CalcGRFMD5Sum(), and GraphicsSet::CheckMD5().
GRFListCompatibility IsGoodGRFConfigList | ( | GRFConfigList & | grfconfig | ) |
Check if all GRFs in the GRF config from a savegame can be loaded.
grfconfig | GrfConfig to check |
Definition at line 430 of file newgrf_config.cpp.
References Compatible, Copy, Debug, FGCM_COMPATIBLE, FGCM_EXACT, GRFConfig::filename, FindGRFConfig(), GRFConfig::flags, FormatArrayAsHex(), GCS_NOT_FOUND, GLC_ALL_GOOD, GLC_COMPATIBLE, GLC_NOT_FOUND, GRFIdentifier::grfid, GRFConfig::has_param_defaults, GRFConfig::ident, Invalid, GRFIdentifier::md5sum, GRFConfig::min_loadable_version, GRFConfig::name, GRFConfig::num_valid_params, GRFConfig::param_info, EnumBitSet< Tenum, Tstorage >::Test(), and GRFConfig::version.
Referenced by AfterLoadGame(), and DoLoad().
void OpenGRFParameterWindow | ( | bool | is_baseset, |
GRFConfig & | c, | ||
bool | editable | ||
) |
Definition at line 548 of file newgrf_gui.cpp.
void ResetGRFConfig | ( | bool | defaults | ) |
Reset the current GRF Config to either blank or newgame settings.
Definition at line 412 of file newgrf_config.cpp.
References _grfconfig, _grfconfig_newgame, AppendStaticGRFConfigs(), and CopyGRFConfigList().
Referenced by NewGRFWindow::Close(), NGRFChunkHandler::Load(), LoadIntroGame(), NewGRFWindow::OnClick(), and AfterNewGRFScan::OnNewGRFsScanned().
void ScanNewGRFFiles | ( | NewGRFScanCallback * | callback | ) |
Scan for all NewGRFs.
callback | The callback to call after the scanning is complete. |
Definition at line 585 of file newgrf_config.cpp.
References DoScanNewGRFFiles(), MarkWholeScreenDirty(), and SetModalProgress().
void ShowNewGRFSettings | ( | bool | editable, |
bool | show_params, | ||
bool | exec_changes, | ||
GRFConfigList & | config | ||
) |
Setup the NewGRF gui.
editable | allow the user to make changes to the grfconfig in the window |
show_params | show information about what parameters are set for the grf files |
exec_changes | if changes are made to the list (editable is true), apply these changes immediately or only update the list |
config | The GRFConfigList that will be shown. |
Definition at line 1985 of file newgrf_gui.cpp.
References CloseWindowByClass(), and WC_GAME_OPTIONS.
Referenced by MenuClickSettings(), SaveLoadWindow::OnClick(), GenerateLandscapeWindow::OnClick(), SelectGameWindow::OnClick(), and NetworkGameWindow::OnClick().
void UpdateNewGRFConfigPalette | ( | int32_t | new_value | ) |
Update the palettes of the graphics from the config file.
Called when changing the default palette in advanced settings.
Definition at line 220 of file newgrf_config.cpp.
References _all_grfs, _grfconfig_newgame, and _grfconfig_static.
Referenced by AfterNewGRFScan::OnNewGRFsScanned().
void UpdateNewGRFScanStatus | ( | uint | num, |
const char * | name | ||
) |
Update the NewGRF scan status.
num | The number of NewGRFs scanned so far. |
name | The name of the last scanned NewGRF. |
Definition at line 2251 of file newgrf_gui.cpp.
References FindWindowByClass(), ScanProgressWindow::UpdateNewGRFScanStatus(), and WC_MODAL_PROGRESS.
Referenced by GRFFileScanner::AddFile().
|
extern |
First item in list of all scanned NewGRFs.
Definition at line 149 of file newgrf_config.cpp.
Referenced by GRFFileScanner::AddFile(), NewGRFWindow::CanUpgradeCurrent(), DoScanNewGRFFiles(), FindGRFConfig(), UpdateNewGRFConfigPalette(), and NewGRFWindow::UpgradeCurrent().
|
extern |
First item in list of current GRF set up.
Definition at line 150 of file newgrf_config.cpp.
Referenced by AfterLoadGame(), DoLoad(), GetGRFConfig(), HandleSavegameLoadCrash(), NGRFChunkHandler::Load(), LoadNewGRF(), MakePNGImage(), MenuClickSettings(), NewGRFConfirmationCallback(), ResetGRFConfig(), ResetNewGRFErrors(), NGRFChunkHandler::Save(), SaveOrLoad(), ServerNetworkGameSocketHandler::SendNewGRFCheck(), ShowNewGRFError(), SurveyGrfs(), and SwitchNewGRFBlitter().
|
extern |
First item in list of default GRF set up.
Definition at line 151 of file newgrf_config.cpp.
Referenced by LoadFromConfig(), GenerateLandscapeWindow::OnClick(), SelectGameWindow::OnClick(), ResetGRFConfig(), SaveToConfig(), and UpdateNewGRFConfigPalette().
|
extern |
First item in list of static GRF set up.
Definition at line 152 of file newgrf_config.cpp.
Referenced by AppendStaticGRFConfigs(), LoadFromConfig(), SaveToConfig(), and UpdateNewGRFConfigPalette().
|
extern |
Number of sprites provided by the fallback extra GRF, i.e. missing in the baseset.
Definition at line 153 of file newgrf_config.cpp.
Referenced by SelectGameWindow::DrawWidget(), SelectGameWindow::OnInit(), and SelectGameWindow::OnResize().