peter1138@5228: /* $Id$ */ peter1138@5228: rubidium@10429: /** @file newgrf_config.h Functions to find and configure NewGRFs. */ belugas@6674: peter1138@5228: #ifndef NEWGRF_CONFIG_H peter1138@5228: #define NEWGRF_CONFIG_H peter1138@5228: rubidium@8638: #include "strings_type.h" maedhros@6465: smatz@9295: /** GRF config bit flags */ rubidium@6574: enum GCF_Flags { smatz@9295: GCF_SYSTEM, ///< GRF file is an openttd-internal system grf smatz@9295: GCF_UNSAFE, ///< GRF file is unsafe for static usage smatz@9295: GCF_STATIC, ///< GRF file is used statically (can be used in any MP game) smatz@9295: GCF_COMPATIBLE, ///< GRF file does not exactly match the requested GRF (different MD5SUM), but grfid matches) smatz@9295: GCF_COPY, ///< The data is copied from a grf in _all_grfs smatz@9295: GCF_INIT_ONLY, ///< GRF file is processed up to GLS_INIT smatz@9295: GCF_RESERVED, ///< GRF file passed GLS_RESERVE stage terom@11180: GCF_CACHE, ///< GRF file was loaded from cache rubidium@6574: }; peter1138@5228: smatz@9295: /** Status of GRF */ rubidium@6574: enum GRFStatus { maedhros@6555: GCS_UNKNOWN, ///< The status of this grf file is unknown maedhros@6555: GCS_DISABLED, ///< GRF file is disabled maedhros@6555: GCS_NOT_FOUND, ///< GRF file was not found in the local cache maedhros@6555: GCS_INITIALISED, ///< GRF file has been initialised terom@11175: GCS_ACTIVATED, ///< GRF file has been activated terom@11175: GCS_AVAILABLE ///< GRF was not found in the local cache, but the download repo has it rubidium@6574: }; maedhros@6555: smatz@9295: /** Status of post-gameload GRF compatibility check */ rubidium@6574: enum GRFListCompatibility{ smatz@9295: GLC_ALL_GOOD, ///< All GRF needed by game are present terom@11175: GLC_COMPATIBLE, ///< Compatible (eg. the same ID, but different checksum) GRF found in at least one case smatz@9295: GLC_NOT_FOUND ///< At least one GRF couldn't be found (higher priority than GLC_COMPATIBLE) rubidium@6574: }; rubidium@6016: smatz@9295: /** Basic data to distinguish a GRF. Used in the server list window */ smatz@9295: struct GRFIdentifier { smatz@9295: uint32 grfid; ///< GRF ID (defined by Action 0x08) smatz@9295: uint8 md5sum[16]; ///< MD5 checksum of file to distinguish files with the same GRF ID (eg. newer version of GRF) rubidium@6574: }; maedhros@6465: smatz@9295: /** Information about why GRF had problems during initialisation */ smatz@9295: struct GRFError { smatz@9295: char *custom_message; ///< Custom message (if present) smatz@9295: char *data; ///< Additional data for message and custom_message smatz@9295: StringID message; ///< Default message smatz@9295: StringID severity; ///< Info / Warning / Error / Fatal smatz@9295: uint8 num_params; ///< Number of additinal parameters for custom_message (0, 1 or 2) smatz@9295: uint8 param_number[2]; ///< GRF parameters to show for custom_message smatz@9295: }; peter1138@5228: smatz@9295: /** Information about GRF, used in the game and (part of it) in savegames */ smatz@9295: struct GRFConfig : public GRFIdentifier { smatz@9295: char *filename; ///< Filename - either with or without full path smatz@9295: char *name; ///< NOSAVE: GRF name (Action 0x08) smatz@9295: char *info; ///< NOSAVE: GRF info (author, copyright, ...) (Action 0x08) smatz@9295: GRFError *error; ///< NOSAVE: Error/Warning during GRF loading (Action 0x0B) peter1138@5228: smatz@9295: uint8 flags; ///< NOSAVE: GCF_Flags, bitset smatz@9295: GRFStatus status; ///< NOSAVE: GRFStatus, enum smatz@9295: uint32 param[0x80]; ///< GRF parameters smatz@9295: uint8 num_params; ///< Number of used parameters smatz@9295: smatz@9295: struct GRFConfig *next; ///< NOSAVE: Next item in the linked list rubidium@8378: rubidium@8378: bool IsOpenTTDBaseGRF() const; rubidium@6574: }; peter1138@5228: smatz@9295: extern GRFConfig *_all_grfs; ///< First item in list of all scanned NewGRFs smatz@9295: extern GRFConfig *_grfconfig; ///< First item in list of current GRF set up smatz@9295: extern GRFConfig *_grfconfig_newgame; ///< First item in list of default GRF set up smatz@9295: extern GRFConfig *_grfconfig_static; ///< First item in list of static GRF set up peter1138@5329: rubidium@6573: void ScanNewGRFFiles(); Darkvater@5897: const GRFConfig *FindGRFConfig(uint32 grfid, const uint8 *md5sum = NULL); peter1138@5333: GRFConfig *GetGRFConfig(uint32 grfid); glx@7452: GRFConfig **CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src, bool init_only); rubidium@5581: void AppendStaticGRFConfigs(GRFConfig **dst); Darkvater@6434: 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@6573: 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@6674: /* In newgrf_gui.cpp */ Darkvater@5352: void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config); peter1138@5237: Darkvater@5692: #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@5692: #endif /* ENABLE_NETWORK */ rubidium@5339: peter1138@5228: #endif /* NEWGRF_CONFIG_H */