src/newgrf_config.h
author convert-repo
Mon, 07 Apr 2008 16:21:55 +0000
changeset 10076 dfd70e42c4ae
parent 9295 50de67372594
child 10429 1b99254f9607
permissions -rw-r--r--
update tags
5228
c4a780348f66 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff changeset
     1
/* $Id$ */
c4a780348f66 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff changeset
     2
6674
64f4781b4653 (svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents: 6574
diff changeset
     3
/** @file newgrf_config.h */
64f4781b4653 (svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents: 6574
diff changeset
     4
5228
c4a780348f66 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff changeset
     5
#ifndef NEWGRF_CONFIG_H
c4a780348f66 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff changeset
     6
#define NEWGRF_CONFIG_H
c4a780348f66 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff changeset
     7
8638
d997e3a75b36 (svn r11704) -Codechange: remove another bunch of useless includes.
rubidium
parents: 8378
diff changeset
     8
#include "strings_type.h"
6465
dddb39b41ee0 (svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents: 6434
diff changeset
     9
9295
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    10
/** GRF config bit flags */
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    11
enum GCF_Flags {
9295
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    12
	GCF_SYSTEM,     ///< GRF file is an openttd-internal system grf
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    13
	GCF_UNSAFE,     ///< GRF file is unsafe for static usage
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    14
	GCF_STATIC,     ///< GRF file is used statically (can be used in any MP game)
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    15
	GCF_COMPATIBLE, ///< GRF file does not exactly match the requested GRF (different MD5SUM), but grfid matches)
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    16
	GCF_COPY,       ///< The data is copied from a grf in _all_grfs
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    17
	GCF_INIT_ONLY,  ///< GRF file is processed up to GLS_INIT
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    18
	GCF_RESERVED,   ///< GRF file passed GLS_RESERVE stage
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    19
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    20
};
5228
c4a780348f66 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff changeset
    21
9295
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    22
/** Status of GRF */
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    23
enum GRFStatus {
6555
c27c9d5b459f (svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents: 6465
diff changeset
    24
	GCS_UNKNOWN,      ///< The status of this grf file is unknown
c27c9d5b459f (svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents: 6465
diff changeset
    25
	GCS_DISABLED,     ///< GRF file is disabled
c27c9d5b459f (svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents: 6465
diff changeset
    26
	GCS_NOT_FOUND,    ///< GRF file was not found in the local cache
c27c9d5b459f (svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents: 6465
diff changeset
    27
	GCS_INITIALISED,  ///< GRF file has been initialised
c27c9d5b459f (svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents: 6465
diff changeset
    28
	GCS_ACTIVATED     ///< GRF file has been activated
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    29
};
6555
c27c9d5b459f (svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents: 6465
diff changeset
    30
9295
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    31
/** Status of post-gameload GRF compatibility check */
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    32
enum GRFListCompatibility{
9295
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    33
	GLC_ALL_GOOD,   ///< All GRF needed by game are present
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    34
	GLC_COMPATIBLE, ///< Compatible (eg. the same ID, but different chacksum) GRF found in at least one case
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    35
	GLC_NOT_FOUND   ///< At least one GRF couldn't be found (higher priority than GLC_COMPATIBLE)
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    36
};
6016
9d7b851ffe1c (svn r8316) -Codechange: move the GRF ID and MD5 checksum from GRFConfig to GRFIdentifier so it can be reused.
rubidium
parents: 5898
diff changeset
    37
9295
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    38
/** Basic data to distinguish a GRF. Used in the server list window */
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    39
struct GRFIdentifier {
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    40
	uint32 grfid;     ///< GRF ID (defined by Action 0x08)
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    41
	uint8 md5sum[16]; ///< MD5 checksum of file to distinguish files with the same GRF ID (eg. newer version of GRF)
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    42
};
6465
dddb39b41ee0 (svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents: 6434
diff changeset
    43
9295
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    44
/** Information about why GRF had problems during initialisation */
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    45
struct GRFError {
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    46
	char *custom_message;  ///< Custom message (if present)
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    47
	char *data;            ///< Additional data for message and custom_message
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    48
	StringID message;      ///< Default message
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    49
	StringID severity;     ///< Info / Warning / Error / Fatal
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    50
	uint8 num_params;      ///< Number of additinal parameters for custom_message (0, 1 or 2)
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    51
	uint8 param_number[2]; ///< GRF parameters to show for custom_message
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    52
};
5228
c4a780348f66 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff changeset
    53
9295
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    54
/** Information about GRF, used in the game and (part of it) in savegames */
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    55
struct GRFConfig : public GRFIdentifier {
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    56
	char *filename;     ///< Filename - either with or without full path
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    57
	char *name;         ///< NOSAVE: GRF name (Action 0x08)
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    58
	char *info;         ///< NOSAVE: GRF info (author, copyright, ...) (Action 0x08)
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    59
	GRFError *error;    ///< NOSAVE: Error/Warning during GRF loading (Action 0x0B)
5228
c4a780348f66 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff changeset
    60
9295
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    61
	uint8 flags;        ///< NOSAVE: GCF_Flags, bitset
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    62
	GRFStatus status;   ///< NOSAVE: GRFStatus, enum
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    63
	uint32 param[0x80]; ///< GRF parameters
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    64
	uint8 num_params;   ///< Number of used parameters
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    65
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    66
	struct GRFConfig *next; ///< NOSAVE: Next item in the linked list
8378
9f849e5763e2 (svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium
parents: 8327
diff changeset
    67
9f849e5763e2 (svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium
parents: 8327
diff changeset
    68
	bool IsOpenTTDBaseGRF() const;
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    69
};
5228
c4a780348f66 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff changeset
    70
9295
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    71
extern GRFConfig *_all_grfs;          ///< First item in list of all scanned NewGRFs
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    72
extern GRFConfig *_grfconfig;         ///< First item in list of current GRF set up
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    73
extern GRFConfig *_grfconfig_newgame; ///< First item in list of default GRF set up
50de67372594 (svn r12537) -Cleanup: comment newgrf_config.h a bit
smatz
parents: 8638
diff changeset
    74
extern GRFConfig *_grfconfig_static;  ///< First item in list of static GRF set up
5329
2b117d8652f0 (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5308
diff changeset
    75
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6555
diff changeset
    76
void ScanNewGRFFiles();
5897
016df903f3bb (svn r8105) -Codechange: Change FindGRFConfig so that if md5sum parameter is omitted (or NULL)
Darkvater
parents: 5726
diff changeset
    77
const GRFConfig *FindGRFConfig(uint32 grfid, const uint8 *md5sum = NULL);
5333
8e7d68b06399 (svn r7495) -Fix (r7354): [NewGRF] Deactivate the target GRF, not the current GRF.
peter1138
parents: 5329
diff changeset
    78
GRFConfig *GetGRFConfig(uint32 grfid);
7452
f6fd23727af0 (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 7369
diff changeset
    79
GRFConfig **CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src, bool init_only);
5581
d0407b8e20ce (svn r7582) -Fix (r7490): appending static GRFs to the list of to-be loaded GRF for a game could result in duplicate GRFs in that list, which can cause a segmentation fault while loading the GRFs.
rubidium
parents: 5352
diff changeset
    80
void AppendStaticGRFConfigs(GRFConfig **dst);
6434
d12a3ab5acbc (svn r8844) -Revert partly (r8820, r8806): Change AppendToGRFConfigList to add the allocated GRFConfig to its list and not copy it.
Darkvater
parents: 6429
diff changeset
    81
void AppendToGRFConfigList(GRFConfig **dst, GRFConfig *el);
5346
0d7cc9cefd2b (svn r7517) -Codechange: Set pointers to NULL when freeing the newgrf config variables and add the proper const to CopyGRFConfigList
Darkvater
parents: 5339
diff changeset
    82
void ClearGRFConfig(GRFConfig **config);
5347
18836f961808 (svn r7518) -Codechange: more NULL pointer resets after free.
Darkvater
parents: 5346
diff changeset
    83
void ClearGRFConfigList(GRFConfig **config);
5228
c4a780348f66 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff changeset
    84
void ResetGRFConfig(bool defaults);
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6555
diff changeset
    85
GRFListCompatibility IsGoodGRFConfigList();
5329
2b117d8652f0 (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5308
diff changeset
    86
bool FillGRFDetails(GRFConfig *config, bool is_static);
5308
bad31e174cc6 (svn r7464) -Codechange: move BuildParamList from newgrf_gui to newgrf_config and
peter1138
parents: 5237
diff changeset
    87
char *GRFBuildParamList(char *dst, const GRFConfig *c, const char *last);
5228
c4a780348f66 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff changeset
    88
6674
64f4781b4653 (svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents: 6574
diff changeset
    89
/* In newgrf_gui.cpp */
5352
82a50c80b0c4 (svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents: 5347
diff changeset
    90
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config);
5237
c14c97d7030a (svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents: 5234
diff changeset
    91
5692
b83442e14fd4 (svn r7692) -Fix: OpenTTD didn't compile without network enabled (newgrf sync code)
Darkvater
parents: 5581
diff changeset
    92
#ifdef ENABLE_NETWORK
5339
7573f179efe8 (svn r7505) -Feature: show NewGRFs used on a game server, show which NewGRFs you do and do not have.
rubidium
parents: 5333
diff changeset
    93
/* For communication about GRFs over the network */
7573f179efe8 (svn r7505) -Feature: show NewGRFs used on a game server, show which NewGRFs you do and do not have.
rubidium
parents: 5333
diff changeset
    94
#define UNKNOWN_GRF_NAME_PLACEHOLDER "<Unknown>"
7573f179efe8 (svn r7505) -Feature: show NewGRFs used on a game server, show which NewGRFs you do and do not have.
rubidium
parents: 5333
diff changeset
    95
char *FindUnknownGRFName(uint32 grfid, uint8 *md5sum, bool create);
5692
b83442e14fd4 (svn r7692) -Fix: OpenTTD didn't compile without network enabled (newgrf sync code)
Darkvater
parents: 5581
diff changeset
    96
#endif /* ENABLE_NETWORK */
5339
7573f179efe8 (svn r7505) -Feature: show NewGRFs used on a game server, show which NewGRFs you do and do not have.
rubidium
parents: 5333
diff changeset
    97
5228
c4a780348f66 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff changeset
    98
#endif /* NEWGRF_CONFIG_H */