OpenTTD Source
12.0-beta2
|
Go to the documentation of this file.
10 #ifndef NEWGRF_CONFIG_H
11 #define NEWGRF_CONFIG_H
105 if (this->grfid !=
grfid)
return false;
106 if (
md5sum ==
nullptr)
return true;
107 return memcmp(
md5sum, this->md5sum,
sizeof(this->md5sum)) == 0;
190 const char *
GetURL()
const;
uint32 version
NOSAVE: Version a NewGRF can set so only the newest NewGRF is shown.
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config)
Setup the NewGRF gui.
void SetSuitablePalette()
Set the palette of this GRFConfig to something suitable.
@ GRFP_USE_MASK
Bitmask to get only the use palette use states.
uint8 num_valid_params
NOSAVE: Number of valid parameters (action 0x14)
GRFTextWrapper info
NOSAVE: GRF info (author, copyright, ...) (Action 0x08)
bool HasGrfIdentifier(uint32 grfid, const uint8 *md5sum) const
Does the identification match the provided values?
GRFError * error
NOSAVE: Error/Warning during GRF loading (Action 0x0B)
std::vector< GRFText > GRFTextList
A GRF text with a list of translations.
std::string custom_message
Custom message (if present)
@ GCS_ACTIVATED
GRF file has been activated.
@ GBUG_VEH_REFIT
Articulated vehicles carry different cargoes resp. are differently refittable than specified in purch...
@ GLC_COMPATIBLE
Compatible (eg. the same ID, but different checksum) GRF found in at least one case.
@ GBUG_VEH_POWERED_WAGON
Powered wagon changed poweredness state when not inside a depot.
GRFConfig * GetGRFConfig(uint32 grfid, uint32 mask=0xFFFFFFFF)
Retrieve a NewGRF from the current config by its grfid.
uint8 num_params
Number of used parameters.
void AppendStaticGRFConfigs(GRFConfig **dst)
Appends the static GRFs to a list of GRFs.
uint _missing_extra_graphics
Number of sprites provided by the fallback extra GRF, i.e. missing in the baseset.
@ GRFP_GRF_SIZE
The size of the GRFP_GRF data.
void SetValue(struct GRFConfig *config, uint32 value)
Set the value of this user-changeable parameter in the given config.
@ FGCM_COMPATIBLE
Find best compatible Grf wrt. desired_version.
byte param_nr
GRF parameter to store content in.
StringID severity
Info / Warning / Error / Fatal.
uint32 def_value
Default value of this parameter.
@ GCS_NOT_FOUND
GRF file was not found in the local cache.
GRFIdentifier ident
grfid and md5sum to uniquely identify newgrfs
@ GCF_COPY
The data is copied from a grf in _all_grfs.
GCF_Flags
GRF config bit flags.
GRFStatus status
NOSAVE: GRFStatus, enum.
@ GRFP_GRF_UNSET
The NewGRF provided no information.
@ GRFP_USE_BIT
The bit used for storing the palette to use.
void ClearGRFConfigList(GRFConfig **config)
Clear a GRF Config list, freeing all nodes.
GRFParameterType type
The type of this parameter.
const GRFConfig * FindGRFConfig(uint32 grfid, FindGRFConfigMode mode, const uint8 *md5sum=nullptr, uint32 desired_version=0)
Find a NewGRF in the scanned list.
static void MemCpyT(T *destination, const T *source, size_t num=1)
Type-safe version of memcpy().
uint8 md5sum[16]
MD5 checksum of file to distinguish files with the same GRF ID (eg. newer version of GRF)
uint32 grfid
GRF ID (defined by Action 0x08)
@ GRFP_BLT_UNSET
The NewGRF provided no information or doesn't care about a 32 bpp blitter.
uint32 GetValue(struct GRFConfig *config) const
Get the value of this user-changeable parameter from the given config.
GRFBugs
Encountered GRF bugs.
@ GCF_COMPATIBLE
GRF file does not exactly match the requested GRF (different MD5SUM), but grfid matches)
byte num_bit
Number of bits to use for this parameter.
GRFConfig * _grfconfig_newgame
First item in list of default GRF set up.
void UpdateNewGRFScanStatus(uint num, const char *name)
Update the NewGRF scan status.
@ GCF_INVALID
GRF is unusable with this version of OpenTTD.
@ GCF_INIT_ONLY
GRF file is processed up to GLS_INIT.
void ResetGRFConfig(bool defaults)
Reset the current GRF Config to either blank or newgame settings.
@ GBUG_VEH_CAPACITY
Capacity of vehicle changes when not refitting or arranging.
@ FGCM_ANY
Use first found.
@ GRFP_GRF_OFFSET
The offset of the GRFP_GRF data.
Basic data to distinguish a GRF.
@ GRFP_GRF_DOS
The NewGRF says the DOS palette can be used.
uint32 grf_bugs
NOSAVE: bugs in this GRF in this run,.
@ GRFP_BLT_SIZE
The size of the GRFP_BLT data.
@ GCF_UNSAFE
GRF file is unsafe for static usage.
@ GCS_INITIALISED
GRF file has been initialised.
Information about GRF, used in the game and (part of it) in savegames.
GRFConfig * _all_grfs
First item in list of all scanned NewGRFs.
GRFError(StringID severity, StringID message=0)
Construct a new GRFError.
@ GRFP_GRF_ANY
The NewGRF says any palette can be used.
@ GCF_SYSTEM
GRF file is an openttd-internal system grf.
@ GRFP_USE_DOS
The palette state is set to use the DOS palette.
virtual ~NewGRFScanCallback()
Make sure the right destructor gets called.
void SetParameterDefaults()
Set the default value for all parameters as specified by action14.
uint8 flags
NOSAVE: GCF_Flags, bitset.
@ GRFP_USE_WINDOWS
The palette state is set to use the Windows palette.
Base class that provides memory initialization on dynamically created objects.
const char * GetTextfile(TextfileType type) const
Search a textfile file next to this NewGRF.
FindGRFConfigMode
Method to find GRFs using FindGRFConfig.
Information about one grf parameter.
@ GRFP_BLT_32BPP
The NewGRF prefers a 32 bpp blitter.
bool has_param_defaults
NOSAVE: did this newgrf specify any defaults for it's parameters.
~GRFConfig()
Cleanup a GRFConfig object.
const char * GetURL() const
Get the grf url.
@ GRFP_GRF_MASK
Bitmask to get only the NewGRF supplied information.
void ScanNewGRFFiles(NewGRFScanCallback *callback)
Scan for all NewGRFs.
void CopyParams(const GRFConfig &src)
Copy the parameter information from the src config.
void UpdateNewGRFConfigPalette(int32 new_value=0)
Update the palettes of the graphics from the config file.
@ NEWGRF_DIR
Subdirectory for all NewGRFs.
@ GRFP_BLT_OFFSET
The offset of the GRFP_BLT data.
@ GBUG_UNKNOWN_CB_RESULT
A callback returned an unknown/invalid result.
GRFListCompatibility IsGoodGRFConfigList(GRFConfig *grfconfig)
Check if all GRFs in the GRF config from a savegame can be loaded.
byte first_bit
First bit to use in the GRF parameter.
GRFParameterType
The possible types of a newgrf parameter.
@ GCS_UNKNOWN
The status of this grf file is unknown.
Information about why GRF had problems during initialisation.
@ GCS_DISABLED
GRF file is disabled.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
void Finalize()
Finalize Action 14 info after file scan is finished.
uint32 max_value
The maximal value of this parameter.
StringID message
Default message.
@ GRFP_GRF_WINDOWS
The NewGRF says the Windows palette can be used.
SmallMap< uint32, GRFTextList > value_names
Names for each value.
GRFTextWrapper name
NOSAVE: GRF name (Action 0x08)
GRFTextList desc
The description of this parameter.
@ GCF_RESERVED
GRF file passed GLS_RESERVE stage.
char * GRFBuildParamList(char *dst, const GRFConfig *c, const char *last)
Build a string containing space separated parameter values, and terminate.
uint32 min_loadable_version
NOSAVE: Minimum compatible version a NewGRF can define.
const char * GetDescription() const
Get the grf info.
uint8 original_md5sum[16]
MD5 checksum of original file if only a 'compatible' file was loaded.
struct GRFConfig * next
NOSAVE: Next item in the linked list.
@ FGCM_NEWEST
Find newest Grf.
@ FGCM_NEWEST_VALID
Find newest Grf, ignoring Grfs with GCF_INVALID set.
GRFTextList name
The name of this parameter.
GRFConfig ** CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src, bool init_only)
Copy a GRF Config list.
virtual void OnNewGRFsScanned()=0
Called whenever the NewGRF scan completed.
Subdirectory
The different kinds of subdirectories OpenTTD uses.
GRFTextWrapper url
NOSAVE: URL belonging to this GRF.
GRFConfig(const char *filename=nullptr)
Create a new GRFConfig.
@ PTYPE_END
Invalid parameter type.
bool FillGRFDetails(GRFConfig *config, bool is_static, Subdirectory subdir=NEWGRF_DIR)
Find the GRFID of a given grf, and calculate its md5sum.
uint8 palette
GRFPalette, bitset.
bool complete_labels
True if all values have a label.
void CDECL error(const char *s,...)
Error handling for fatal non-user errors.
Callback for NewGRF scanning.
#define lengthof(x)
Return the length of an fixed size array.
void FinalizeParameterInfo()
Finalize Action 14 info after file scan is finished.
@ PTYPE_BOOL
The parameter is either 0 or 1.
GRFConfig * _grfconfig
First item in list of current GRF set up.
@ PTYPE_UINT_ENUM
The parameter allows a range of numbers, each of which can have a special name.
TextfileType
Additional text files accompanying Tar archives.
GRFPalette
Information that can/has to be stored about a GRF's palette.
@ FGCM_EXACT
Only find Grfs matching md5sum.
std::shared_ptr< GRFTextList > GRFTextWrapper
Reference counted wrapper around a GRFText pointer.
GRFParameterInfo(uint nr)
Create a new empty GRFParameterInfo object.
@ GLC_ALL_GOOD
All GRF needed by game are present.
char * filename
Filename - either with or without full path.
void AppendToGRFConfigList(GRFConfig **dst, GRFConfig *el)
Appends an element to a list of GRFs.
GRFConfig * _grfconfig_static
First item in list of static GRF set up.
size_t GRFGetSizeOfDataSection(FILE *f)
Get the data section size of a GRF.
uint32 param_value[2]
Values of GRF parameters to show for message and custom_message.
@ GBUG_VEH_LENGTH
Length of rail vehicle changes when not inside a depot.
@ GLC_NOT_FOUND
At least one GRF couldn't be found (higher priority than GLC_COMPATIBLE)
GRFListCompatibility
Status of post-gameload GRF compatibility check.
@ GCF_STATIC
GRF file is used statically (can be used in any MP game)
std::vector< GRFParameterInfo * > param_info
NOSAVE: extra information about the parameters.
uint32 param[0x80]
GRF parameters.
uint32 min_value
The minimal value this parameter can have.
const char * GetName() const
Get the name of this grf.
std::string data
Additional data for message and custom_message.
@ GRFP_BLT_MASK
Bitmask to only get the blitter information.