OpenTTD
Public Member Functions | Data Fields
GRFConfig Struct Reference

Information about GRF, used in the game and (part of it) in savegames. More...

#include <newgrf_config.h>

Inheritance diagram for GRFConfig:
ZeroedMemoryAllocator

Public Member Functions

 GRFConfig (const char *filename=NULL)
 Create a new GRFConfig. More...
 
 GRFConfig (const GRFConfig &config)
 Create a new GRFConfig that is a deep copy of an existing config. More...
 
 ~GRFConfig ()
 Cleanup a GRFConfig object. More...
 
void CopyParams (const GRFConfig &src)
 Copy the parameter information from the src config. More...
 
const char * GetTextfile (TextfileType type) const
 Search a textfile file next to this NewGRF. More...
 
const char * GetName () const
 Get the name of this grf. More...
 
const char * GetDescription () const
 Get the grf info. More...
 
const char * GetURL () const
 Get the grf url. More...
 
void SetParameterDefaults ()
 Set the default value for all parameters as specified by action14. More...
 
void SetSuitablePalette ()
 Set the palette of this GRFConfig to something suitable. More...
 
void FinalizeParameterInfo ()
 Finalize Action 14 info after file scan is finished.
 
- Public Member Functions inherited from ZeroedMemoryAllocator
void * operator new (size_t size)
 Memory allocator for a single class instance. More...
 
void * operator new[] (size_t size)
 Memory allocator for an array of class instances. More...
 
void operator delete (void *ptr)
 Memory release for a single class instance. More...
 
void operator delete[] (void *ptr)
 Memory release for an array of class instances. More...
 

Data Fields

GRFIdentifier ident
 grfid and md5sum to uniquely identify newgrfs
 
uint8 original_md5sum [16]
 MD5 checksum of original file if only a 'compatible' file was loaded.
 
char * filename
 Filename - either with or without full path.
 
GRFTextWrappername
 NOSAVE: GRF name (Action 0x08)
 
GRFTextWrapperinfo
 NOSAVE: GRF info (author, copyright, ...) (Action 0x08)
 
GRFTextWrapperurl
 NOSAVE: URL belonging to this GRF.
 
GRFErrorerror
 NOSAVE: Error/Warning during GRF loading (Action 0x0B)
 
uint32 version
 NOSAVE: Version a NewGRF can set so only the newest NewGRF is shown.
 
uint32 min_loadable_version
 NOSAVE: Minimum compatible version a NewGRF can define.
 
uint8 flags
 NOSAVE: GCF_Flags, bitset.
 
GRFStatus status
 NOSAVE: GRFStatus, enum.
 
uint32 grf_bugs
 NOSAVE: bugs in this GRF in this run,. More...
 
uint32 param [0x80]
 GRF parameters.
 
uint8 num_params
 Number of used parameters.
 
uint8 num_valid_params
 NOSAVE: Number of valid parameters (action 0x14)
 
uint8 palette
 GRFPalette, bitset.
 
SmallVector< GRFParameterInfo *, 4 > param_info
 NOSAVE: extra information about the parameters.
 
bool has_param_defaults
 NOSAVE: did this newgrf specify any defaults for it's parameters.
 
struct GRFConfignext
 NOSAVE: Next item in the linked list.
 

Detailed Description

Information about GRF, used in the game and (part of it) in savegames.

Definition at line 153 of file newgrf_config.h.

Constructor & Destructor Documentation

◆ GRFConfig() [1/2]

GRFConfig::GRFConfig ( const char *  filename = NULL)

Create a new GRFConfig.

Parameters
filenameSet the filename of this GRFConfig to filename. The argument is copied so the original string isn't needed after the constructor.

Definition at line 47 of file newgrf_config.cpp.

References info, name, stredup(), and url.

◆ GRFConfig() [2/2]

GRFConfig::GRFConfig ( const GRFConfig config)

Create a new GRFConfig that is a deep copy of an existing config.

Parameters
configThe GRFConfig object to make a copy of.

Definition at line 63 of file newgrf_config.cpp.

References SmallVector< T, S >::Append(), error, filename, info, SmallVector< T, S >::Length(), lengthof, name, original_md5sum, param, param_info, stredup(), and url.

◆ ~GRFConfig()

GRFConfig::~GRFConfig ( )

Cleanup a GRFConfig object.

Definition at line 96 of file newgrf_config.cpp.

References error, filename, flags, free(), GCF_COPY, HasBit(), info, SmallVector< T, S >::Length(), name, param_info, and url.

Member Function Documentation

◆ CopyParams()

void GRFConfig::CopyParams ( const GRFConfig src)

Copy the parameter information from the src config.

Parameters
srcSource config.

Definition at line 114 of file newgrf_config.cpp.

References lengthof, num_params, num_valid_params, and param.

Referenced by NewGRFWindow::UpgradeCurrent().

◆ GetDescription()

const char * GRFConfig::GetDescription ( ) const

Get the grf info.

Returns
A string with a description of this grf.

Definition at line 136 of file newgrf_config.cpp.

References GetGRFStringFromGRFText(), info, and GRFTextWrapper::text.

◆ GetName()

const char * GRFConfig::GetName ( ) const

◆ GetTextfile()

const char * GRFConfig::GetTextfile ( TextfileType  type) const

Search a textfile file next to this NewGRF.

Parameters
typeThe type of the textfile to search for.
Returns
The filename for the textfile, NULL otherwise.

Definition at line 924 of file newgrf_config.cpp.

References GetTextfile(), and NEWGRF_DIR.

◆ GetURL()

const char * GRFConfig::GetURL ( ) const

Get the grf url.

Returns
A string with an url of this grf.

Definition at line 145 of file newgrf_config.cpp.

References GetGRFStringFromGRFText(), GRFTextWrapper::text, and url.

◆ SetParameterDefaults()

void GRFConfig::SetParameterDefaults ( )

Set the default value for all parameters as specified by action14.

Definition at line 151 of file newgrf_config.cpp.

References has_param_defaults, SmallVector< T, S >::Length(), lengthof, num_params, param, and param_info.

Referenced by NewGRFWindow::AddGRFToActive().

◆ SetSuitablePalette()

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 169 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().

Field Documentation

◆ grf_bugs

uint32 GRFConfig::grf_bugs

NOSAVE: bugs in this GRF in this run,.

See also
enum GRFBugs

Definition at line 170 of file newgrf_config.h.

Referenced by ErrorUnknownCallbackResult(), ShowNewGrfVehicleError(), and VehicleLengthChanged().


The documentation for this struct was generated from the following files: