2006-12-04 08:30:04 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2008-05-06 15:11:33 +00:00
|
|
|
/** @file newgrf_config.h Functions to find and configure NewGRFs. */
|
2007-03-21 03:06:21 +00:00
|
|
|
|
2006-12-04 08:30:04 +00:00
|
|
|
#ifndef NEWGRF_CONFIG_H
|
|
|
|
#define NEWGRF_CONFIG_H
|
|
|
|
|
2007-12-26 23:04:26 +00:00
|
|
|
#include "strings_type.h"
|
2007-02-24 16:34:37 +00:00
|
|
|
|
2008-04-02 00:13:44 +00:00
|
|
|
/** GRF config bit flags */
|
2007-03-07 12:11:48 +00:00
|
|
|
enum GCF_Flags {
|
2008-04-02 00:13:44 +00:00
|
|
|
GCF_SYSTEM, ///< GRF file is an openttd-internal system grf
|
|
|
|
GCF_UNSAFE, ///< GRF file is unsafe for static usage
|
|
|
|
GCF_STATIC, ///< GRF file is used statically (can be used in any MP game)
|
|
|
|
GCF_COMPATIBLE, ///< GRF file does not exactly match the requested GRF (different MD5SUM), but grfid matches)
|
|
|
|
GCF_COPY, ///< The data is copied from a grf in _all_grfs
|
|
|
|
GCF_INIT_ONLY, ///< GRF file is processed up to GLS_INIT
|
|
|
|
GCF_RESERVED, ///< GRF file passed GLS_RESERVE stage
|
|
|
|
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2006-12-04 08:30:04 +00:00
|
|
|
|
2008-04-02 00:13:44 +00:00
|
|
|
/** Status of GRF */
|
2007-03-07 12:11:48 +00:00
|
|
|
enum GRFStatus {
|
2007-03-06 19:33:28 +00:00
|
|
|
GCS_UNKNOWN, ///< The status of this grf file is unknown
|
|
|
|
GCS_DISABLED, ///< GRF file is disabled
|
|
|
|
GCS_NOT_FOUND, ///< GRF file was not found in the local cache
|
|
|
|
GCS_INITIALISED, ///< GRF file has been initialised
|
|
|
|
GCS_ACTIVATED ///< GRF file has been activated
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2007-03-06 19:33:28 +00:00
|
|
|
|
2008-07-24 15:19:26 +00:00
|
|
|
/** Encountered GRF bugs */
|
|
|
|
enum GRFBugs {
|
|
|
|
GBUG_VEH_LENGTH, ///< Length of rail vehicle changes when not inside a depot
|
|
|
|
};
|
|
|
|
|
2008-04-02 00:13:44 +00:00
|
|
|
/** Status of post-gameload GRF compatibility check */
|
2008-07-24 15:19:26 +00:00
|
|
|
enum GRFListCompatibility {
|
2008-04-02 00:13:44 +00:00
|
|
|
GLC_ALL_GOOD, ///< All GRF needed by game are present
|
|
|
|
GLC_COMPATIBLE, ///< Compatible (eg. the same ID, but different chacksum) GRF found in at least one case
|
|
|
|
GLC_NOT_FOUND ///< At least one GRF couldn't be found (higher priority than GLC_COMPATIBLE)
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2007-03-06 19:33:28 +00:00
|
|
|
|
2008-04-02 00:13:44 +00:00
|
|
|
/** Basic data to distinguish a GRF. Used in the server list window */
|
2007-03-07 12:11:48 +00:00
|
|
|
struct GRFIdentifier {
|
2008-04-02 00:13:44 +00:00
|
|
|
uint32 grfid; ///< GRF ID (defined by Action 0x08)
|
|
|
|
uint8 md5sum[16]; ///< MD5 checksum of file to distinguish files with the same GRF ID (eg. newer version of GRF)
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2007-01-21 17:29:38 +00:00
|
|
|
|
2008-04-02 00:13:44 +00:00
|
|
|
/** Information about why GRF had problems during initialisation */
|
2007-03-07 12:11:48 +00:00
|
|
|
struct GRFError {
|
2008-04-02 00:13:44 +00:00
|
|
|
char *custom_message; ///< Custom message (if present)
|
|
|
|
char *data; ///< Additional data for message and custom_message
|
|
|
|
StringID message; ///< Default message
|
|
|
|
StringID severity; ///< Info / Warning / Error / Fatal
|
|
|
|
uint8 num_params; ///< Number of additinal parameters for custom_message (0, 1 or 2)
|
|
|
|
uint8 param_number[2]; ///< GRF parameters to show for custom_message
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2007-02-24 16:34:37 +00:00
|
|
|
|
2008-04-02 00:13:44 +00:00
|
|
|
/** Information about GRF, used in the game and (part of it) in savegames */
|
2007-03-07 12:11:48 +00:00
|
|
|
struct GRFConfig : public GRFIdentifier {
|
2008-04-02 00:13:44 +00:00
|
|
|
char *filename; ///< Filename - either with or without full path
|
|
|
|
char *name; ///< NOSAVE: GRF name (Action 0x08)
|
|
|
|
char *info; ///< NOSAVE: GRF info (author, copyright, ...) (Action 0x08)
|
|
|
|
GRFError *error; ///< NOSAVE: Error/Warning during GRF loading (Action 0x0B)
|
2006-12-04 08:30:04 +00:00
|
|
|
|
2008-04-02 00:13:44 +00:00
|
|
|
uint8 flags; ///< NOSAVE: GCF_Flags, bitset
|
|
|
|
GRFStatus status; ///< NOSAVE: GRFStatus, enum
|
2008-07-24 15:19:26 +00:00
|
|
|
uint32 grf_bugs; ///< NOSAVE: bugs in this GRF in this run, @see enum GRFBugs
|
2008-04-02 00:13:44 +00:00
|
|
|
uint32 param[0x80]; ///< GRF parameters
|
|
|
|
uint8 num_params; ///< Number of used parameters
|
2008-09-03 07:51:07 +00:00
|
|
|
bool windows_paletted; ///< Whether the NewGRF is Windows paletted or not
|
2006-12-04 08:30:04 +00:00
|
|
|
|
2008-04-02 00:13:44 +00:00
|
|
|
struct GRFConfig *next; ///< NOSAVE: Next item in the linked list
|
2007-11-15 07:42:25 +00:00
|
|
|
|
|
|
|
bool IsOpenTTDBaseGRF() const;
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2006-12-04 08:30:04 +00:00
|
|
|
|
2008-04-02 00:13:44 +00:00
|
|
|
extern GRFConfig *_all_grfs; ///< First item in list of all scanned NewGRFs
|
|
|
|
extern GRFConfig *_grfconfig; ///< First item in list of current GRF set up
|
|
|
|
extern GRFConfig *_grfconfig_newgame; ///< First item in list of default GRF set up
|
|
|
|
extern GRFConfig *_grfconfig_static; ///< First item in list of static GRF set up
|
2006-12-12 19:38:41 +00:00
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
void ScanNewGRFFiles();
|
2007-01-13 17:23:02 +00:00
|
|
|
const GRFConfig *FindGRFConfig(uint32 grfid, const uint8 *md5sum = NULL);
|
2009-01-16 19:53:52 +00:00
|
|
|
GRFConfig *GetGRFConfig(uint32 grfid, uint32 mask = 0xFFFFFFFF);
|
2007-06-18 23:00:55 +00:00
|
|
|
GRFConfig **CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src, bool init_only);
|
2006-12-27 18:25:17 +00:00
|
|
|
void AppendStaticGRFConfigs(GRFConfig **dst);
|
2007-02-22 16:16:44 +00:00
|
|
|
void AppendToGRFConfigList(GRFConfig **dst, GRFConfig *el);
|
2006-12-20 20:43:52 +00:00
|
|
|
void ClearGRFConfig(GRFConfig **config);
|
2006-12-20 21:17:33 +00:00
|
|
|
void ClearGRFConfigList(GRFConfig **config);
|
2006-12-04 08:30:04 +00:00
|
|
|
void ResetGRFConfig(bool defaults);
|
2007-03-07 11:47:46 +00:00
|
|
|
GRFListCompatibility IsGoodGRFConfigList();
|
2006-12-12 19:38:41 +00:00
|
|
|
bool FillGRFDetails(GRFConfig *config, bool is_static);
|
2006-12-10 11:29:14 +00:00
|
|
|
char *GRFBuildParamList(char *dst, const GRFConfig *c, const char *last);
|
2006-12-04 08:30:04 +00:00
|
|
|
|
2007-03-21 03:06:21 +00:00
|
|
|
/* In newgrf_gui.cpp */
|
2006-12-21 10:29:16 +00:00
|
|
|
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config);
|
2006-12-04 14:27:54 +00:00
|
|
|
|
2006-12-31 11:12:49 +00:00
|
|
|
#ifdef ENABLE_NETWORK
|
2006-12-18 12:26:55 +00:00
|
|
|
/* For communication about GRFs over the network */
|
|
|
|
#define UNKNOWN_GRF_NAME_PLACEHOLDER "<Unknown>"
|
|
|
|
char *FindUnknownGRFName(uint32 grfid, uint8 *md5sum, bool create);
|
2006-12-31 11:12:49 +00:00
|
|
|
#endif /* ENABLE_NETWORK */
|
2006-12-18 12:26:55 +00:00
|
|
|
|
2006-12-04 08:30:04 +00:00
|
|
|
#endif /* NEWGRF_CONFIG_H */
|