Finding NewGRFs and configuring them. More...
#include "stdafx.h"
#include "debug.h"
#include "3rdparty/md5/md5.h"
#include "newgrf.h"
#include "gamelog.h"
#include "network/network_func.h"
#include "gfx_func.h"
#include "fileio_func.h"
#include "fios.h"
Go to the source code of this file.
Data Structures | |
class | GRFFileScanner |
Helper for scanning for files with GRF as extension. More... | |
struct | UnknownGRF |
Structure for UnknownGRFs; this is a lightweight variant of GRFConfig. More... | |
Functions | |
void | UpdateNewGRFConfigPalette () |
Update the palettes of the graphics from the config file. | |
static bool | CalcGRFMD5Sum (GRFConfig *config) |
bool | FillGRFDetails (GRFConfig *config, bool is_static) |
void | ClearGRFConfig (GRFConfig **config) |
void | ClearGRFConfigList (GRFConfig **config) |
GRFConfig * | DuplicateGRFConfig (const GRFConfig *c) |
Make a deep copy of a GRFConfig. | |
GRFConfig ** | CopyGRFConfigList (GRFConfig **dst, const GRFConfig *src, bool init_only) |
Copy a GRF Config list. | |
static void | RemoveDuplicatesFromGRFConfigList (GRFConfig *list) |
Removes duplicates from lists of GRFConfigs. | |
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 | ResetGRFConfig (bool defaults) |
GRFListCompatibility | IsGoodGRFConfigList () |
Check if all GRFs in the GRF config from a savegame can be loaded. | |
static int CDECL | GRFSorter (GRFConfig *const *p1, GRFConfig *const *p2) |
Simple sorter for GRFS. | |
void | ScanNewGRFFiles () |
const GRFConfig * | FindGRFConfig (uint32 grfid, const uint8 *md5sum) |
char * | FindUnknownGRFName (uint32 grfid, uint8 *md5sum, bool create) |
Finds the name of a NewGRF in the list of names for unknown GRFs. | |
GRFConfig * | GetGRFConfig (uint32 grfid, uint32 mask) |
char * | GRFBuildParamList (char *dst, const GRFConfig *c, const char *last) |
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. | |
static const uint32 | OPENTTD_GRAPHICS_BASE_GRF_ID = BSWAP32(0xFF4F5400) |
Base GRF ID for OpenTTD's base graphics GRFs. |
Finding NewGRFs and configuring them.
Definition in file newgrf_config.cpp.
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 217 of file newgrf_config.cpp.
References CopyGRFConfigList(), GRFConfig::next, and RemoveDuplicatesFromGRFConfigList().
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 229 of file newgrf_config.cpp.
References GRFConfig::next, and RemoveDuplicatesFromGRFConfigList().
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 165 of file newgrf_config.cpp.
References ClrBit(), DuplicateGRFConfig(), GRFConfig::flags, GCF_INIT_ONLY, GRFConfig::next, and SetBit().
Referenced by AppendStaticGRFConfigs(), NewGRFConfirmationCallback(), and NewGRFWindow::OnClick().
Make a deep copy of a GRFConfig.
c | the grfconfig to copy |
Definition at line 139 of file newgrf_config.cpp.
References ClrBit(), GRFError::custom_message, GRFError::data, GRFConfig::error, GRFConfig::filename, GCF_COPY, GRFConfig::info, GRFError::message, GRFConfig::name, GRFError::num_params, GRFError::param_value, and GRFError::severity.
Referenced by CopyGRFConfigList(), and NewGRFAddWindow::OnClick().
char* 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 457 of file newgrf_config.cpp.
References GRFIdentifier::grfid, lastof, GRFIdentifier::md5sum, and strecpy().
Referenced by DEF_UDP_RECEIVE_COMMAND(), ClientNetworkUDPSocketHandler::HandleIncomingNetworkGameInfoGRFConfig(), and NetworkAfterNewGRFScan().
Simple sorter for GRFS.
Definition at line 370 of file newgrf_config.cpp.
References GRFConfig::filename, and GRFConfig::name.
GRFListCompatibility IsGoodGRFConfigList | ( | ) |
Check if all GRFs in the GRF config from a savegame can be loaded.
Definition at line 255 of file newgrf_config.cpp.
References BSWAP32(), GRFConfig::error, GRFConfig::filename, GRFConfig::flags, GamelogGRFCompatible(), GamelogGRFRemove(), GCF_COMPATIBLE, GCF_COPY, GCS_NOT_FOUND, GLC_ALL_GOOD, GLC_COMPATIBLE, GLC_NOT_FOUND, GRFIdentifier::grfid, HasBit(), GRFConfig::info, lastof, GRFIdentifier::md5sum, md5sumToString(), GRFConfig::name, GRFConfig::next, SetBit(), and GRFConfig::status.
static void RemoveDuplicatesFromGRFConfigList | ( | GRFConfig * | list | ) | [static] |
Removes duplicates from lists of GRFConfigs.
These duplicates are introduced when the _grfconfig_static GRFs are appended to the _grfconfig on a newgame or savegame. As the parameters of the static GRFs could be different that the parameters of the ones used non-statically. This can result in desyncs in multiplayers, so the duplicate static GRFs have to be removed.
This function _assumes_ that all static GRFs are placed after the non-static GRFs.
list | the list to remove the duplicates from |
Definition at line 195 of file newgrf_config.cpp.
References GRFIdentifier::grfid, and GRFConfig::next.
Referenced by AppendStaticGRFConfigs(), and AppendToGRFConfigList().
void UpdateNewGRFConfigPalette | ( | ) |
Update the palettes of the graphics from the config file.
This is needed because the config file gets read and parsed before the palette is chosen (one can configure the base graphics set governing the palette in the config after all). As a result of this we update the settings from the config once we have determined the palette.
Definition at line 49 of file newgrf_config.cpp.
References _use_palette, GRFConfig::next, and PAL_WINDOWS.
Referenced by BaseGraphics::DeterminePalette().
const uint32 OPENTTD_GRAPHICS_BASE_GRF_ID = BSWAP32(0xFF4F5400) [static] |
Base GRF ID for OpenTTD's base graphics GRFs.
Definition at line 512 of file newgrf_config.cpp.