OpenTTD
|
Functions to find and configure NewGRFs. More...
#include "strings_type.h"
#include "core/alloc_type.hpp"
#include "core/smallmap_type.hpp"
#include "misc/countedptr.hpp"
#include "fileio_type.h"
#include "textfile_type.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 | GRFTextWrapper |
Reference counted wrapper around a GRFText pointer. More... | |
struct | GRFConfig |
Information about GRF, used in the game and (part of it) in savegames. More... | |
struct | NewGRFScanCallback |
Callback for NewGRF scanning. More... |
Macros | |
#define | UNKNOWN_GRF_NAME_PLACEHOLDER "<Unknown>" |
For communication about GRFs over the network. |
Functions | |
size_t | GRFGetSizeOfDataSection (FILE *f) |
Get the data section size of a GRF. | |
void | ScanNewGRFFiles (NewGRFScanCallback *callback) |
Scan for all NewGRFs. | |
void | CheckForMissingSprites () |
Check whether we are (obviously) missing some of the extra (Action 0x05) sprites that we like to use. | |
const GRFConfig * | FindGRFConfig (uint32 grfid, FindGRFConfigMode mode, const uint8 *md5sum=NULL, uint32 desired_version=0) |
Find a NewGRF in the scanned list. | |
GRFConfig * | GetGRFConfig (uint32 grfid, uint32 mask=0xFFFFFFFF) |
Retrieve a NewGRF from the current config by its grfid. | |
GRFConfig ** | CopyGRFConfigList (GRFConfig **dst, const GRFConfig *src, bool init_only) |
Copy a GRF Config list. | |
void | AppendStaticGRFConfigs (GRFConfig **dst) |
Appends the static GRFs to a list of GRFs. | |
void | AppendToGRFConfigList (GRFConfig **dst, GRFConfig *el) |
Appends an element to a list of GRFs. | |
void | ClearGRFConfigList (GRFConfig **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 (GRFConfig *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. | |
char * | GRFBuildParamList (char *dst, const GRFConfig *c, const char *last) |
Build a string containing space separated parameter values, and terminate. | |
void | ShowNewGRFSettings (bool editable, bool show_params, bool exec_changes, GRFConfig **config) |
Setup the NewGRF gui. | |
GRFTextWrapper * | FindUnknownGRFName (uint32 grfid, uint8 *md5sum, bool create) |
Finds the name of a NewGRF in the list of names for unknown GRFs. | |
void | UpdateNewGRFScanStatus (uint num, const char *name) |
Update the NewGRF scan status. | |
bool | UpdateNewGRFConfigPalette (int32 p1=0) |
Update the palettes of the graphics from the config file. |
Variables | |
GRFConfig * | _all_grfs |
First item in list of all scanned NewGRFs. | |
GRFConfig * | _grfconfig |
First item in list of current GRF set up. | |
GRFConfig * | _grfconfig_newgame |
First item in list of default GRF set up. | |
GRFConfig * | _grfconfig_static |
First item in list of static GRF set up. |
Functions to find and configure NewGRFs.
Definition in file newgrf_config.h.
enum FindGRFConfigMode |
Method to find GRFs using FindGRFConfig.
Definition at line 195 of file newgrf_config.h.
enum GCF_Flags |
GRF config bit flags.
Definition at line 23 of file newgrf_config.h.
enum GRFBugs |
Encountered GRF bugs.
Definition at line 44 of file newgrf_config.h.
enum GRFListCompatibility |
Status of post-gameload GRF compatibility check.
Definition at line 53 of file newgrf_config.h.
enum GRFPalette |
Information that can/has to be stored about a GRF's palette.
Definition at line 60 of file newgrf_config.h.
enum GRFParameterType |
The possible types of a newgrf parameter.
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 116 of file newgrf_config.h.
enum GRFStatus |
Status of GRF.
Definition at line 35 of file newgrf_config.h.
void AppendStaticGRFConfigs | ( | GRFConfig ** | dst | ) |
Appends the static GRFs to a list of GRFs.
dst | the head of the list to add to |
Definition at line 513 of file newgrf_config.cpp.
References CopyGRFConfigList(), GRFConfig::next, and RemoveDuplicatesFromGRFConfigList().
Referenced by ResetGRFConfig().
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 527 of file newgrf_config.cpp.
References GRFConfig::next, and RemoveDuplicatesFromGRFConfigList().
void CheckForMissingSprites | ( | ) |
Check whether we are (obviously) missing some of the extra (Action 0x05) sprites that we like to use.
When missing sprites are found a warning will be shown.
Definition at line 5701 of file newgrf.cpp.
References A5BLOCK_INVALID, Action5Type::block_type, DEBUG, INVALID_STRING_ID, lengthof, Action5Type::max_sprites, Action5Type::name, ShowErrorMessage(), Action5Type::sprite_base, and WL_CRITICAL.
Referenced by LoadIntroGame().
void ClearGRFConfigList | ( | GRFConfig ** | config | ) |
Clear a GRF Config list, freeing all nodes.
config | Start of the list. |
NULL
. Definition at line 443 of file newgrf_config.cpp.
References GRFConfig::next.
Referenced by LoadCheckData::Clear(), CopyGRFConfigList(), DoLoad(), DoScanNewGRFFiles(), NetworkGameListHandleDelayedInsert(), NetworkGameListRemoveItem(), NewGRFWindow::OnDropdownSelect(), ClientNetworkUDPSocketHandler::Receive_SERVER_RESPONSE(), and SaveOrLoad().
Copy a GRF Config list.
dst | pointer to destination list |
src | pointer to source list values |
init_only | the copied GRF will be processed up to GLS_INIT |
Definition at line 461 of file newgrf_config.cpp.
References ClearGRFConfigList(), ClrBit(), GRFConfig::flags, GCF_INIT_ONLY, GRFConfig::next, and SetBit().
Referenced by AppendStaticGRFConfigs(), 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 411 of file newgrf_config.cpp.
References CalcGRFMD5Sum(), CONFIG_SLOT, GRFConfig::filename, GRFConfig::FinalizeParameterInfo(), FioCheckFileExists(), GRFConfig::flags, GCF_UNSAFE, GCS_NOT_FOUND, GRFIdentifier::grfid, HasBit(), GRFConfig::ident, GRFConfig::IsOpenTTDBaseGRF(), LoadNewGRFFile(), GRFConfig::SetSuitablePalette(), and GRFConfig::status.
Referenced by GRFLoadConfig(), and LoadSpriteTables().
const GRFConfig* FindGRFConfig | ( | uint32 | grfid, |
FindGRFConfigMode | mode, | ||
const uint8 * | md5sum, | ||
uint32 | 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 |
NULL
. Definition at line 808 of file newgrf_config.cpp.
References FGCM_ANY, FGCM_COMPATIBLE, FGCM_EXACT, FGCM_NEWEST, GRFConfig::flags, GCF_INVALID, HasBit(), GRFIdentifier::HasGrfIdentifier(), GRFConfig::ident, GRFConfig::min_loadable_version, GRFConfig::next, and GRFConfig::version.
Referenced by GamelogPrint(), ContentInfo::GetTextfile(), GRFLoadConfig(), ClientNetworkUDPSocketHandler::HandleIncomingNetworkGameInfoGRFConfig(), HasGRFConfig(), IsGoodGRFConfigList(), NetworkAfterNewGRFScan(), NewGRFWindow::OnInvalidateData(), PrintGrfInfo(), ServerNetworkUDPSocketHandler::Receive_CLIENT_GET_NEWGRFS(), and ClientNetworkGameSocketHandler::Receive_SERVER_CHECK_NEWGRFS().
GRFTextWrapper* FindUnknownGRFName | ( | uint32 | grfid, |
uint8 * | md5sum, | ||
bool | create | ||
) |
Finds the name of a NewGRF in the list of names for unknown GRFs.
An unknown GRF is a GRF where the .grf is not found during scanning.
The names are resolved via UDP calls to servers that should know the name, though the replies may not come. This leaves "<Unknown>" as name, though that shouldn't matter very much as they need GRF crawler or so to look up the GRF anyway and that works better with the GRF ID.
grfid | the GRF ID part of the 'unique' GRF identifier |
md5sum | the MD5 checksum part of the 'unique' GRF identifier |
create | whether to create a new GRFConfig if the GRFConfig did not exist in the fake list of GRFConfigs. |
Definition at line 853 of file newgrf_config.cpp.
References AddGRFTextToList(), GRFIdentifier::grfid, GRFIdentifier::md5sum, UnknownGRF::name, UnknownGRF::next, GRFTextWrapper::text, and UNKNOWN_GRF_NAME_PLACEHOLDER.
Referenced by ClientNetworkUDPSocketHandler::HandleIncomingNetworkGameInfoGRFConfig(), NetworkAfterNewGRFScan(), and ClientNetworkUDPSocketHandler::Receive_SERVER_NEWGRFS().
GRFConfig* GetGRFConfig | ( | uint32 | grfid, |
uint32 | mask | ||
) |
Retrieve a NewGRF from the current config by its grfid.
grfid | grf to look for. |
mask | GRFID mask to allow for partial matching. |
NULL
. Definition at line 888 of file newgrf_config.cpp.
References GRFIdentifier::grfid, GRFConfig::ident, and GRFConfig::next.
Referenced by ErrorUnknownCallbackResult(), ParamSet(), ShowNewGrfVehicleError(), TranslateGRFStrings(), and VehicleLengthChanged().
size_t GRFGetSizeOfDataSection | ( | FILE * | f | ) |
Get the data section size of a GRF.
f | GRF. |
Definition at line 342 of file newgrf_config.cpp.
References _grf_cont_v2_sig, DEBUG, and MemCmpT().
Referenced by CalcGRFMD5Sum(), and GraphicsSet::CheckMD5().
GRFListCompatibility IsGoodGRFConfigList | ( | GRFConfig * | grfconfig | ) |
Check if all GRFs in the GRF config from a savegame can be loaded.
grfconfig | GrfConfig to check |
Definition at line 556 of file newgrf_config.cpp.
References BSWAP32(), DEBUG, FGCM_COMPATIBLE, FGCM_EXACT, GRFConfig::filename, FindGRFConfig(), GRFConfig::flags, free(), GCF_COMPATIBLE, GCF_COPY, GCF_INVALID, GCS_NOT_FOUND, GLC_ALL_GOOD, GLC_COMPATIBLE, GLC_NOT_FOUND, GRFIdentifier::grfid, GRFConfig::has_param_defaults, HasBit(), GRFConfig::ident, lastof, SmallVector< T, S >::Length(), GRFIdentifier::md5sum, md5sumToString(), GRFConfig::min_loadable_version, GRFConfig::name, GRFConfig::next, GRFConfig::num_valid_params, GRFConfig::param_info, SetBit(), stredup(), and GRFConfig::version.
Referenced by AfterLoadGame(), and DoLoad().
void ResetGRFConfig | ( | bool | defaults | ) |
Reset the current GRF Config to either blank or newgame settings.
Definition at line 538 of file newgrf_config.cpp.
References AppendStaticGRFConfigs(), and CopyGRFConfigList().
Referenced by 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 782 of file newgrf_config.cpp.
References _modal_progress_paint_mutex, _modal_progress_work_mutex, ThreadMutex::BeginCritical(), DoScanNewGRFFiles(), ThreadMutex::EndCritical(), VideoDriver::GetInstance(), MarkWholeScreenDirty(), ThreadObject::New(), SetModalProgress(), and UpdateNewGRFScanStatus().
Referenced by NewGRFWindow::OnClick(), openttd_main(), and NetworkContentDownloadStatusWindow::~NetworkContentDownloadStatusWindow().
void ShowNewGRFSettings | ( | bool | editable, |
bool | show_params, | ||
bool | exec_changes, | ||
GRFConfig ** | 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 | pointer to a linked-list of grfconfig's that will be shown |
Definition at line 2006 of file newgrf_gui.cpp.
References DeleteWindowByClass(), and WC_GAME_OPTIONS.
Referenced by MenuClickSettings(), SelectGameWindow::OnClick(), SaveLoadWindow::OnClick(), and NetworkGameWindow::OnClick().
bool UpdateNewGRFConfigPalette | ( | int32 | p1 | ) |
Update the palettes of the graphics from the config file.
Called when changing the default palette in advanced settings.
p1 | Unused. |
Definition at line 329 of file newgrf_config.cpp.
References GRFConfig::next.
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 2280 of file newgrf_gui.cpp.
References FindWindowByClass(), ScanProgressWindow::UpdateNewGRFScanStatus(), and WC_MODAL_PROGRESS.
Referenced by ScanNewGRFFiles().