peter1138@5228: /* $Id$ */ peter1138@5228: rubidium@9111: /** @file newgrf_config.h Functions to find and configure NewGRFs. */ belugas@6348: peter1138@5228: #ifndef NEWGRF_CONFIG_H peter1138@5228: #define NEWGRF_CONFIG_H peter1138@5228: rubidium@8142: #include "strings_type.h" maedhros@6139: smatz@8799: /** GRF config bit flags */ rubidium@6248: enum GCF_Flags { smatz@8799: GCF_SYSTEM, ///< GRF file is an openttd-internal system grf smatz@8799: GCF_UNSAFE, ///< GRF file is unsafe for static usage smatz@8799: GCF_STATIC, ///< GRF file is used statically (can be used in any MP game) smatz@8799: GCF_COMPATIBLE, ///< GRF file does not exactly match the requested GRF (different MD5SUM), but grfid matches) smatz@8799: GCF_COPY, ///< The data is copied from a grf in _all_grfs smatz@8799: GCF_INIT_ONLY, ///< GRF file is processed up to GLS_INIT smatz@8799: GCF_RESERVED, ///< GRF file passed GLS_RESERVE stage smatz@8799: rubidium@6248: }; peter1138@5228: smatz@8799: /** Status of GRF */ rubidium@6248: enum GRFStatus { maedhros@6229: GCS_UNKNOWN, ///< The status of this grf file is unknown maedhros@6229: GCS_DISABLED, ///< GRF file is disabled maedhros@6229: GCS_NOT_FOUND, ///< GRF file was not found in the local cache maedhros@6229: GCS_INITIALISED, ///< GRF file has been initialised maedhros@6229: GCS_ACTIVATED ///< GRF file has been activated rubidium@6248: }; maedhros@6229: smatz@8799: /** Status of post-gameload GRF compatibility check */ rubidium@6248: enum GRFListCompatibility{ smatz@8799: GLC_ALL_GOOD, ///< All GRF needed by game are present smatz@8799: GLC_COMPATIBLE, ///< Compatible (eg. the same ID, but different chacksum) GRF found in at least one case smatz@8799: GLC_NOT_FOUND ///< At least one GRF couldn't be found (higher priority than GLC_COMPATIBLE) rubidium@6248: }; rubidium@5765: smatz@8799: /** Basic data to distinguish a GRF. Used in the server list window */ smatz@8799: struct GRFIdentifier { smatz@8799: uint32 grfid; ///< GRF ID (defined by Action 0x08) smatz@8799: uint8 md5sum[16]; ///< MD5 checksum of file to distinguish files with the same GRF ID (eg. newer version of GRF) rubidium@6248: }; maedhros@6139: smatz@8799: /** Information about why GRF had problems during initialisation */ smatz@8799: struct GRFError { smatz@8799: char *custom_message; ///< Custom message (if present) smatz@8799: char *data; ///< Additional data for message and custom_message smatz@8799: StringID message; ///< Default message smatz@8799: StringID severity; ///< Info / Warning / Error / Fatal smatz@8799: uint8 num_params; ///< Number of additinal parameters for custom_message (0, 1 or 2) smatz@8799: uint8 param_number[2]; ///< GRF parameters to show for custom_message smatz@8799: }; peter1138@5228: smatz@8799: /** Information about GRF, used in the game and (part of it) in savegames */ smatz@8799: struct GRFConfig : public GRFIdentifier { smatz@8799: char *filename; ///< Filename - either with or without full path smatz@8799: char *name; ///< NOSAVE: GRF name (Action 0x08) smatz@8799: char *info; ///< NOSAVE: GRF info (author, copyright, ...) (Action 0x08) smatz@8799: GRFError *error; ///< NOSAVE: Error/Warning during GRF loading (Action 0x0B) peter1138@5228: smatz@8799: uint8 flags; ///< NOSAVE: GCF_Flags, bitset smatz@8799: GRFStatus status; ///< NOSAVE: GRFStatus, enum smatz@8799: uint32 param[0x80]; ///< GRF parameters smatz@8799: uint8 num_params; ///< Number of used parameters smatz@8799: smatz@8799: struct GRFConfig *next; ///< NOSAVE: Next item in the linked list rubidium@7882: rubidium@7882: bool IsOpenTTDBaseGRF() const; rubidium@6248: }; peter1138@5228: smatz@8799: extern GRFConfig *_all_grfs; ///< First item in list of all scanned NewGRFs smatz@8799: extern GRFConfig *_grfconfig; ///< First item in list of current GRF set up smatz@8799: extern GRFConfig *_grfconfig_newgame; ///< First item in list of default GRF set up smatz@8799: extern GRFConfig *_grfconfig_static; ///< First item in list of static GRF set up peter1138@5329: rubidium@6247: void ScanNewGRFFiles(); Darkvater@5646: const GRFConfig *FindGRFConfig(uint32 grfid, const uint8 *md5sum = NULL); peter1138@5333: GRFConfig *GetGRFConfig(uint32 grfid); glx@6956: GRFConfig **CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src, bool init_only); rubidium@5393: void AppendStaticGRFConfigs(GRFConfig **dst); Darkvater@6108: void AppendToGRFConfigList(GRFConfig **dst, GRFConfig *el); Darkvater@5346: void ClearGRFConfig(GRFConfig **config); Darkvater@5347: void ClearGRFConfigList(GRFConfig **config); peter1138@5228: void ResetGRFConfig(bool defaults); rubidium@6247: GRFListCompatibility IsGoodGRFConfigList(); peter1138@5329: bool FillGRFDetails(GRFConfig *config, bool is_static); peter1138@5308: char *GRFBuildParamList(char *dst, const GRFConfig *c, const char *last); peter1138@5228: belugas@6348: /* In newgrf_gui.cpp */ Darkvater@5352: void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config); peter1138@5237: Darkvater@5441: #ifdef ENABLE_NETWORK rubidium@5339: /* For communication about GRFs over the network */ rubidium@5339: #define UNKNOWN_GRF_NAME_PLACEHOLDER "" rubidium@5339: char *FindUnknownGRFName(uint32 grfid, uint8 *md5sum, bool create); Darkvater@5441: #endif /* ENABLE_NETWORK */ rubidium@5339: peter1138@5228: #endif /* NEWGRF_CONFIG_H */