author | KUDr |
Fri, 20 Apr 2007 19:43:06 +0000 | |
changeset 6513 | 454347ca3dfb |
parent 6424 | d410d4c31d15 |
child 6873 | b4d0648edd29 |
permissions | -rw-r--r-- |
5228
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
1 |
/* $Id$ */ |
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
2 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6248
diff
changeset
|
3 |
/** @file newgrf_config.h */ |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6248
diff
changeset
|
4 |
|
5228
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
5 |
#ifndef NEWGRF_CONFIG_H |
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
6 |
#define NEWGRF_CONFIG_H |
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
7 |
|
6139
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6108
diff
changeset
|
8 |
#include "openttd.h" |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6108
diff
changeset
|
9 |
|
5228
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
10 |
/* GRF config bit flags */ |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
11 |
enum GCF_Flags { |
5647
9a96d72c23be
(svn r8106) -Feature/Fix: Add the ability to load savegames when you don't have the exact GRF files in your list. GRF files that are found based on GRFID (but not on matching md5sum) are used instead of disabling them. This does not affect MP games, there you still need an exact match.
Darkvater
parents:
5646
diff
changeset
|
12 |
GCF_SYSTEM, ///< GRF file is an openttd-internal system grf |
9a96d72c23be
(svn r8106) -Feature/Fix: Add the ability to load savegames when you don't have the exact GRF files in your list. GRF files that are found based on GRFID (but not on matching md5sum) are used instead of disabling them. This does not affect MP games, there you still need an exact match.
Darkvater
parents:
5646
diff
changeset
|
13 |
GCF_UNSAFE, ///< GRF file is unsafe for static usage |
9a96d72c23be
(svn r8106) -Feature/Fix: Add the ability to load savegames when you don't have the exact GRF files in your list. GRF files that are found based on GRFID (but not on matching md5sum) are used instead of disabling them. This does not affect MP games, there you still need an exact match.
Darkvater
parents:
5646
diff
changeset
|
14 |
GCF_STATIC, ///< GRF file is used statically (can be used in any MP game) |
9a96d72c23be
(svn r8106) -Feature/Fix: Add the ability to load savegames when you don't have the exact GRF files in your list. GRF files that are found based on GRFID (but not on matching md5sum) are used instead of disabling them. This does not affect MP games, there you still need an exact match.
Darkvater
parents:
5646
diff
changeset
|
15 |
GCF_COMPATIBLE,///< GRF file does not exactly match the requested GRF (different MD5SUM), but grfid matches) |
5339
96ac3f4933bb
(svn r7505) -Feature: show NewGRFs used on a game server, show which NewGRFs you do and do not have.
rubidium
parents:
5333
diff
changeset
|
16 |
GCF_COPY, ///< The data is copied from a grf in _all_grfs |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
17 |
}; |
5228
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
18 |
|
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
19 |
enum GRFStatus { |
6229
695400602ab0
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6139
diff
changeset
|
20 |
GCS_UNKNOWN, ///< The status of this grf file is unknown |
695400602ab0
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6139
diff
changeset
|
21 |
GCS_DISABLED, ///< GRF file is disabled |
695400602ab0
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6139
diff
changeset
|
22 |
GCS_NOT_FOUND, ///< GRF file was not found in the local cache |
695400602ab0
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6139
diff
changeset
|
23 |
GCS_INITIALISED, ///< GRF file has been initialised |
695400602ab0
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6139
diff
changeset
|
24 |
GCS_ACTIVATED ///< GRF file has been activated |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
25 |
}; |
6229
695400602ab0
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6139
diff
changeset
|
26 |
|
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
27 |
enum GRFListCompatibility{ |
6229
695400602ab0
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6139
diff
changeset
|
28 |
GLC_ALL_GOOD, |
695400602ab0
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6139
diff
changeset
|
29 |
GLC_COMPATIBLE, |
695400602ab0
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6139
diff
changeset
|
30 |
GLC_NOT_FOUND |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
31 |
}; |
6229
695400602ab0
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6139
diff
changeset
|
32 |
|
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
33 |
struct GRFIdentifier { |
5765
27dbbe543fcf
(svn r8316) -Codechange: move the GRF ID and MD5 checksum from GRFConfig to GRFIdentifier so it can be reused.
rubidium
parents:
5647
diff
changeset
|
34 |
uint32 grfid; |
27dbbe543fcf
(svn r8316) -Codechange: move the GRF ID and MD5 checksum from GRFConfig to GRFIdentifier so it can be reused.
rubidium
parents:
5647
diff
changeset
|
35 |
uint8 md5sum[16]; |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
36 |
}; |
5765
27dbbe543fcf
(svn r8316) -Codechange: move the GRF ID and MD5 checksum from GRFConfig to GRFIdentifier so it can be reused.
rubidium
parents:
5647
diff
changeset
|
37 |
|
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
38 |
struct GRFError { |
6139
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6108
diff
changeset
|
39 |
StringID message; |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6108
diff
changeset
|
40 |
StringID data; |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6108
diff
changeset
|
41 |
StringID severity; |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6108
diff
changeset
|
42 |
uint8 num_params; |
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6108
diff
changeset
|
43 |
uint8 param_number[2]; |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
44 |
}; |
6139
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6108
diff
changeset
|
45 |
|
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
46 |
struct GRFConfig : public GRFIdentifier { |
5228
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
47 |
char *filename; |
6424
d410d4c31d15
(svn r9560) -Codechange: add support for multiple 'base' directories for newgrf searching.
rubidium
parents:
6348
diff
changeset
|
48 |
char *full_path; |
5228
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
49 |
char *name; |
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
50 |
char *info; |
6139
cd42df0c1f0f
(svn r8881) -Feature: Allow built-in newgrf error messages to be translated, and load custom error messages properly.
maedhros
parents:
6108
diff
changeset
|
51 |
GRFError *error; |
5228
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
52 |
|
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
53 |
uint8 flags; |
6229
695400602ab0
(svn r9031) -Codechange: Introduce grfconfig->status, and use it for states that are
maedhros
parents:
6139
diff
changeset
|
54 |
GRFStatus status; |
5228
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
55 |
uint32 param[0x80]; |
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
56 |
uint8 num_params; |
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
57 |
|
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
58 |
struct GRFConfig *next; |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
59 |
}; |
5228
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
60 |
|
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
61 |
/* First item in list of all scanned NewGRFs */ |
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
62 |
extern GRFConfig *_all_grfs; |
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
63 |
|
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
64 |
/* First item in list of current GRF set up */ |
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
65 |
extern GRFConfig *_grfconfig; |
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
66 |
|
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
67 |
/* First item in list of default GRF set up */ |
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
68 |
extern GRFConfig *_grfconfig_newgame; |
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
69 |
|
5329
9c5e8061ea0f
(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
|
70 |
/* First item in list of static GRF set up */ |
9c5e8061ea0f
(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
|
71 |
extern GRFConfig *_grfconfig_static; |
9c5e8061ea0f
(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
|
72 |
|
6247 | 73 |
void ScanNewGRFFiles(); |
5646
e94c63712efe
(svn r8105) -Codechange: Change FindGRFConfig so that if md5sum parameter is omitted (or NULL)
Darkvater
parents:
5475
diff
changeset
|
74 |
const GRFConfig *FindGRFConfig(uint32 grfid, const uint8 *md5sum = NULL); |
5333
dedf1f6de6d3
(svn r7495) -Fix (r7354): [NewGRF] Deactivate the target GRF, not the current GRF.
peter1138
parents:
5329
diff
changeset
|
75 |
GRFConfig *GetGRFConfig(uint32 grfid); |
5346
3687c73bc65b
(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
|
76 |
GRFConfig **CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src); |
5393
cf584337ea2c
(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
|
77 |
void AppendStaticGRFConfigs(GRFConfig **dst); |
6108
c0929232db31
(svn r8844) -Revert partly (r8820, r8806): Change AppendToGRFConfigList to add the allocated GRFConfig to its list and not copy it.
Darkvater
parents:
6103
diff
changeset
|
78 |
void AppendToGRFConfigList(GRFConfig **dst, GRFConfig *el); |
5346
3687c73bc65b
(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
|
79 |
void ClearGRFConfig(GRFConfig **config); |
5347
9b1bc705f2ae
(svn r7518) -Codechange: more NULL pointer resets after free.
Darkvater
parents:
5346
diff
changeset
|
80 |
void ClearGRFConfigList(GRFConfig **config); |
5228
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
81 |
void ResetGRFConfig(bool defaults); |
6247 | 82 |
GRFListCompatibility IsGoodGRFConfigList(); |
5329
9c5e8061ea0f
(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
|
83 |
bool FillGRFDetails(GRFConfig *config, bool is_static); |
5308
990a4b188233
(svn r7464) -Codechange: move BuildParamList from newgrf_gui to newgrf_config and
peter1138
parents:
5237
diff
changeset
|
84 |
char *GRFBuildParamList(char *dst, const GRFConfig *c, const char *last); |
5228
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
85 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6248
diff
changeset
|
86 |
/* In newgrf_gui.cpp */ |
5352
86fca6a41aa1
(svn r7523) -Feature: Add the possibility to change the newgrf configuration of a running game.
Darkvater
parents:
5347
diff
changeset
|
87 |
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config); |
5237
4fce3ea379c2
(svn r7357) -Codechange: new NewGRF set up window which allows modification of NewGRF settings.
peter1138
parents:
5234
diff
changeset
|
88 |
|
5441
e8bac228a6db
(svn r7692) -Fix: OpenTTD didn't compile without network enabled (newgrf sync code)
Darkvater
parents:
5393
diff
changeset
|
89 |
#ifdef ENABLE_NETWORK |
5339
96ac3f4933bb
(svn r7505) -Feature: show NewGRFs used on a game server, show which NewGRFs you do and do not have.
rubidium
parents:
5333
diff
changeset
|
90 |
/* For communication about GRFs over the network */ |
96ac3f4933bb
(svn r7505) -Feature: show NewGRFs used on a game server, show which NewGRFs you do and do not have.
rubidium
parents:
5333
diff
changeset
|
91 |
#define UNKNOWN_GRF_NAME_PLACEHOLDER "<Unknown>" |
96ac3f4933bb
(svn r7505) -Feature: show NewGRFs used on a game server, show which NewGRFs you do and do not have.
rubidium
parents:
5333
diff
changeset
|
92 |
char *FindUnknownGRFName(uint32 grfid, uint8 *md5sum, bool create); |
5441
e8bac228a6db
(svn r7692) -Fix: OpenTTD didn't compile without network enabled (newgrf sync code)
Darkvater
parents:
5393
diff
changeset
|
93 |
#endif /* ENABLE_NETWORK */ |
5339
96ac3f4933bb
(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 |
|
5228
26dc9acf7d94
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
95 |
#endif /* NEWGRF_CONFIG_H */ |