src/newgrf_config.h
branchnoai
changeset 9869 6404afe43575
parent 9723 eee46cb39750
child 10455 22c441f5adf9
equal deleted inserted replaced
9868:3998f2e73dda 9869:6404afe43575
     5 #ifndef NEWGRF_CONFIG_H
     5 #ifndef NEWGRF_CONFIG_H
     6 #define NEWGRF_CONFIG_H
     6 #define NEWGRF_CONFIG_H
     7 
     7 
     8 #include "strings_type.h"
     8 #include "strings_type.h"
     9 
     9 
    10 /* GRF config bit flags */
    10 /** GRF config bit flags */
    11 enum GCF_Flags {
    11 enum GCF_Flags {
    12 	GCF_SYSTEM,    ///< GRF file is an openttd-internal system grf
    12 	GCF_SYSTEM,     ///< GRF file is an openttd-internal system grf
    13 	GCF_UNSAFE,    ///< GRF file is unsafe for static usage
    13 	GCF_UNSAFE,     ///< GRF file is unsafe for static usage
    14 	GCF_STATIC,    ///< GRF file is used statically (can be used in any MP game)
    14 	GCF_STATIC,     ///< GRF file is used statically (can be used in any MP game)
    15 	GCF_COMPATIBLE,///< GRF file does not exactly match the requested GRF (different MD5SUM), but grfid matches)
    15 	GCF_COMPATIBLE, ///< GRF file does not exactly match the requested GRF (different MD5SUM), but grfid matches)
    16 	GCF_COPY,      ///< The data is copied from a grf in _all_grfs
    16 	GCF_COPY,       ///< The data is copied from a grf in _all_grfs
    17 	GCF_INIT_ONLY, ///< GRF file is processed up to GLS_INIT
    17 	GCF_INIT_ONLY,  ///< GRF file is processed up to GLS_INIT
    18 	GCF_RESERVED,  ///< GRF file passed GLS_RESERVE stage
    18 	GCF_RESERVED,   ///< GRF file passed GLS_RESERVE stage
       
    19 
    19 };
    20 };
    20 
    21 
       
    22 /** Status of GRF */
    21 enum GRFStatus {
    23 enum GRFStatus {
    22 	GCS_UNKNOWN,      ///< The status of this grf file is unknown
    24 	GCS_UNKNOWN,      ///< The status of this grf file is unknown
    23 	GCS_DISABLED,     ///< GRF file is disabled
    25 	GCS_DISABLED,     ///< GRF file is disabled
    24 	GCS_NOT_FOUND,    ///< GRF file was not found in the local cache
    26 	GCS_NOT_FOUND,    ///< GRF file was not found in the local cache
    25 	GCS_INITIALISED,  ///< GRF file has been initialised
    27 	GCS_INITIALISED,  ///< GRF file has been initialised
    26 	GCS_ACTIVATED     ///< GRF file has been activated
    28 	GCS_ACTIVATED     ///< GRF file has been activated
    27 };
    29 };
    28 
    30 
       
    31 /** Status of post-gameload GRF compatibility check */
    29 enum GRFListCompatibility{
    32 enum GRFListCompatibility{
    30 	GLC_ALL_GOOD,
    33 	GLC_ALL_GOOD,   ///< All GRF needed by game are present
    31 	GLC_COMPATIBLE,
    34 	GLC_COMPATIBLE, ///< Compatible (eg. the same ID, but different chacksum) GRF found in at least one case
    32 	GLC_NOT_FOUND
    35 	GLC_NOT_FOUND   ///< At least one GRF couldn't be found (higher priority than GLC_COMPATIBLE)
    33 };
    36 };
    34 
    37 
       
    38 /** Basic data to distinguish a GRF. Used in the server list window */
    35 struct GRFIdentifier {
    39 struct GRFIdentifier {
    36 	uint32 grfid;
    40 	uint32 grfid;     ///< GRF ID (defined by Action 0x08)
    37 	uint8 md5sum[16];
    41 	uint8 md5sum[16]; ///< MD5 checksum of file to distinguish files with the same GRF ID (eg. newer version of GRF)
    38 };
    42 };
    39 
    43 
       
    44 /** Information about why GRF had problems during initialisation */
    40 struct GRFError {
    45 struct GRFError {
    41 	char *custom_message;
    46 	char *custom_message;  ///< Custom message (if present)
    42 	char *data;
    47 	char *data;            ///< Additional data for message and custom_message
    43 	StringID message;
    48 	StringID message;      ///< Default message
    44 	StringID severity;
    49 	StringID severity;     ///< Info / Warning / Error / Fatal
    45 	uint8 num_params;
    50 	uint8 num_params;      ///< Number of additinal parameters for custom_message (0, 1 or 2)
    46 	uint8 param_number[2];
    51 	uint8 param_number[2]; ///< GRF parameters to show for custom_message
    47 };
    52 };
    48 
    53 
       
    54 /** Information about GRF, used in the game and (part of it) in savegames */
    49 struct GRFConfig : public GRFIdentifier {
    55 struct GRFConfig : public GRFIdentifier {
    50 	char *filename;
    56 	char *filename;     ///< Filename - either with or without full path
    51 	char *name;
    57 	char *name;         ///< NOSAVE: GRF name (Action 0x08)
    52 	char *info;
    58 	char *info;         ///< NOSAVE: GRF info (author, copyright, ...) (Action 0x08)
    53 	GRFError *error;
    59 	GRFError *error;    ///< NOSAVE: Error/Warning during GRF loading (Action 0x0B)
    54 
    60 
    55 	uint8 flags;
    61 	uint8 flags;        ///< NOSAVE: GCF_Flags, bitset
    56 	GRFStatus status;
    62 	GRFStatus status;   ///< NOSAVE: GRFStatus, enum
    57 	uint32 param[0x80];
    63 	uint32 param[0x80]; ///< GRF parameters
    58 	uint8 num_params;
    64 	uint8 num_params;   ///< Number of used parameters
    59 
    65 
    60 	struct GRFConfig *next;
    66 	struct GRFConfig *next; ///< NOSAVE: Next item in the linked list
    61 
    67 
    62 	bool IsOpenTTDBaseGRF() const;
    68 	bool IsOpenTTDBaseGRF() const;
    63 };
    69 };
    64 
    70 
    65 /* First item in list of all scanned NewGRFs */
    71 extern GRFConfig *_all_grfs;          ///< First item in list of all scanned NewGRFs
    66 extern GRFConfig *_all_grfs;
    72 extern GRFConfig *_grfconfig;         ///< First item in list of current GRF set up
    67 
    73 extern GRFConfig *_grfconfig_newgame; ///< First item in list of default GRF set up
    68 /* First item in list of current GRF set up */
    74 extern GRFConfig *_grfconfig_static;  ///< First item in list of static GRF set up
    69 extern GRFConfig *_grfconfig;
       
    70 
       
    71 /* First item in list of default GRF set up */
       
    72 extern GRFConfig *_grfconfig_newgame;
       
    73 
       
    74 /* First item in list of static GRF set up */
       
    75 extern GRFConfig *_grfconfig_static;
       
    76 
    75 
    77 void ScanNewGRFFiles();
    76 void ScanNewGRFFiles();
    78 const GRFConfig *FindGRFConfig(uint32 grfid, const uint8 *md5sum = NULL);
    77 const GRFConfig *FindGRFConfig(uint32 grfid, const uint8 *md5sum = NULL);
    79 GRFConfig *GetGRFConfig(uint32 grfid);
    78 GRFConfig *GetGRFConfig(uint32 grfid);
    80 GRFConfig **CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src, bool init_only);
    79 GRFConfig **CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src, bool init_only);