src/newgrf_config.h
branchgamebalance
changeset 9895 7bd07f43b0e3
parent 6465 dddb39b41ee0
child 9906 6f41b8713b65
equal deleted inserted replaced
9894:70d78ac95d6c 9895:7bd07f43b0e3
     4 #define NEWGRF_CONFIG_H
     4 #define NEWGRF_CONFIG_H
     5 
     5 
     6 #include "openttd.h"
     6 #include "openttd.h"
     7 
     7 
     8 /* GRF config bit flags */
     8 /* GRF config bit flags */
     9 typedef enum {
     9 enum GCF_Flags {
    10 	GCF_DISABLED,  ///< GRF file is disabled
       
    11 	GCF_NOT_FOUND, ///< GRF file was not found in the local cache
       
    12 	GCF_ACTIVATED, ///< GRF file is active
       
    13 	GCF_SYSTEM,    ///< GRF file is an openttd-internal system grf
    10 	GCF_SYSTEM,    ///< GRF file is an openttd-internal system grf
    14 	GCF_UNSAFE,    ///< GRF file is unsafe for static usage
    11 	GCF_UNSAFE,    ///< GRF file is unsafe for static usage
    15 	GCF_STATIC,    ///< GRF file is used statically (can be used in any MP game)
    12 	GCF_STATIC,    ///< GRF file is used statically (can be used in any MP game)
    16 	GCF_COMPATIBLE,///< GRF file does not exactly match the requested GRF (different MD5SUM), but grfid matches)
    13 	GCF_COMPATIBLE,///< GRF file does not exactly match the requested GRF (different MD5SUM), but grfid matches)
    17 	GCF_COPY,      ///< The data is copied from a grf in _all_grfs
    14 	GCF_COPY,      ///< The data is copied from a grf in _all_grfs
    18 } GCF_Flags;
    15 };
    19 
    16 
    20 typedef struct GRFIdentifier {
    17 enum GRFStatus {
       
    18 	GCS_UNKNOWN,      ///< The status of this grf file is unknown
       
    19 	GCS_DISABLED,     ///< GRF file is disabled
       
    20 	GCS_NOT_FOUND,    ///< GRF file was not found in the local cache
       
    21 	GCS_INITIALISED,  ///< GRF file has been initialised
       
    22 	GCS_ACTIVATED     ///< GRF file has been activated
       
    23 };
       
    24 
       
    25 enum GRFListCompatibility{
       
    26 	GLC_ALL_GOOD,
       
    27 	GLC_COMPATIBLE,
       
    28 	GLC_NOT_FOUND
       
    29 };
       
    30 
       
    31 struct GRFIdentifier {
    21 	uint32 grfid;
    32 	uint32 grfid;
    22 	uint8 md5sum[16];
    33 	uint8 md5sum[16];
    23 } GRF;
    34 };
    24 
    35 
    25 typedef struct GRFError {
    36 struct GRFError {
    26 	StringID message;
    37 	StringID message;
    27 	StringID data;
    38 	StringID data;
    28 	StringID severity;
    39 	StringID severity;
    29 	uint8 num_params;
    40 	uint8 num_params;
    30 	uint8 param_number[2];
    41 	uint8 param_number[2];
    31 } GRFError;
    42 };
    32 
    43 
    33 typedef struct GRFConfig : public GRFIdentifier {
    44 struct GRFConfig : public GRFIdentifier {
    34 	char *filename;
    45 	char *filename;
    35 	char *name;
    46 	char *name;
    36 	char *info;
    47 	char *info;
    37 	GRFError *error;
    48 	GRFError *error;
    38 
    49 
    39 	uint8 flags;
    50 	uint8 flags;
       
    51 	GRFStatus status;
    40 	uint32 param[0x80];
    52 	uint32 param[0x80];
    41 	uint8 num_params;
    53 	uint8 num_params;
    42 
    54 
    43 	struct GRFConfig *next;
    55 	struct GRFConfig *next;
    44 } GRFConfig;
    56 };
    45 
    57 
    46 /* First item in list of all scanned NewGRFs */
    58 /* First item in list of all scanned NewGRFs */
    47 extern GRFConfig *_all_grfs;
    59 extern GRFConfig *_all_grfs;
    48 
    60 
    49 /* First item in list of current GRF set up */
    61 /* First item in list of current GRF set up */
    53 extern GRFConfig *_grfconfig_newgame;
    65 extern GRFConfig *_grfconfig_newgame;
    54 
    66 
    55 /* First item in list of static GRF set up */
    67 /* First item in list of static GRF set up */
    56 extern GRFConfig *_grfconfig_static;
    68 extern GRFConfig *_grfconfig_static;
    57 
    69 
    58 void ScanNewGRFFiles(void);
    70 void ScanNewGRFFiles();
    59 const GRFConfig *FindGRFConfig(uint32 grfid, const uint8 *md5sum = NULL);
    71 const GRFConfig *FindGRFConfig(uint32 grfid, const uint8 *md5sum = NULL);
    60 GRFConfig *GetGRFConfig(uint32 grfid);
    72 GRFConfig *GetGRFConfig(uint32 grfid);
    61 GRFConfig **CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src);
    73 GRFConfig **CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src);
    62 void AppendStaticGRFConfigs(GRFConfig **dst);
    74 void AppendStaticGRFConfigs(GRFConfig **dst);
    63 void AppendToGRFConfigList(GRFConfig **dst, GRFConfig *el);
    75 void AppendToGRFConfigList(GRFConfig **dst, GRFConfig *el);
    64 void ClearGRFConfig(GRFConfig **config);
    76 void ClearGRFConfig(GRFConfig **config);
    65 void ClearGRFConfigList(GRFConfig **config);
    77 void ClearGRFConfigList(GRFConfig **config);
    66 void ResetGRFConfig(bool defaults);
    78 void ResetGRFConfig(bool defaults);
    67 GCF_Flags IsGoodGRFConfigList(void);
    79 GRFListCompatibility IsGoodGRFConfigList();
    68 bool FillGRFDetails(GRFConfig *config, bool is_static);
    80 bool FillGRFDetails(GRFConfig *config, bool is_static);
    69 char *GRFBuildParamList(char *dst, const GRFConfig *c, const char *last);
    81 char *GRFBuildParamList(char *dst, const GRFConfig *c, const char *last);
    70 
    82 
    71 /* In newgrf_gui.c */
    83 /* In newgrf_gui.c */
    72 void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config);
    84 void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config);