src/newgrf_config.h
author KUDr
Sat, 21 Apr 2007 08:23:57 +0000
branchcpp_gui
changeset 6308 646711c5feaa
parent 6307 f40e88cff863
permissions -rw-r--r--
(svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
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
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
     3
/** @file newgrf_config.h */
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
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
6268
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6016
diff changeset
     8
#include "openttd.h"
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6016
diff changeset
     9
5228
c4a780348f66 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff changeset
    10
/* GRF config bit flags */
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6268
diff changeset
    11
enum GCF_Flags {
5898
2ee7d23291fa (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: 5897
diff changeset
    12
	GCF_SYSTEM,    ///< GRF file is an openttd-internal system grf
2ee7d23291fa (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: 5897
diff changeset
    13
	GCF_UNSAFE,    ///< GRF file is unsafe for static usage
2ee7d23291fa (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: 5897
diff changeset
    14
	GCF_STATIC,    ///< GRF file is used statically (can be used in any MP game)
2ee7d23291fa (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: 5897
diff changeset
    15
	GCF_COMPATIBLE,///< GRF file does not exactly match the requested GRF (different MD5SUM), but grfid matches)
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
    16
	GCF_COPY,      ///< The data is copied from a grf in _all_grfs
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6268
diff changeset
    17
};
5228
c4a780348f66 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff changeset
    18
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6268
diff changeset
    19
enum GRFStatus {
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6268
diff changeset
    20
	GCS_UNKNOWN,      ///< The status of this grf file is unknown
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6268
diff changeset
    21
	GCS_DISABLED,     ///< GRF file is disabled
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6268
diff changeset
    22
	GCS_NOT_FOUND,    ///< GRF file was not found in the local cache
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6268
diff changeset
    23
	GCS_INITIALISED,  ///< GRF file has been initialised
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6268
diff changeset
    24
	GCS_ACTIVATED     ///< GRF file has been activated
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6268
diff changeset
    25
};
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6268
diff changeset
    26
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6268
diff changeset
    27
enum GRFListCompatibility{
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6268
diff changeset
    28
	GLC_ALL_GOOD,
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6268
diff changeset
    29
	GLC_COMPATIBLE,
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6268
diff changeset
    30
	GLC_NOT_FOUND
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6268
diff changeset
    31
};
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6268
diff changeset
    32
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6268
diff changeset
    33
struct GRFIdentifier {
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
    34
	uint32 grfid;
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
    35
	uint8 md5sum[16];
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6268
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
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6268
diff changeset
    38
struct GRFError {
6268
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6016
diff changeset
    39
	StringID message;
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6016
diff changeset
    40
	StringID data;
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6016
diff changeset
    41
	StringID severity;
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6016
diff changeset
    42
	uint8 num_params;
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6016
diff changeset
    43
	uint8 param_number[2];
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6268
diff changeset
    44
};
6268
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6016
diff changeset
    45
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6268
diff changeset
    46
struct GRFConfig : public GRFIdentifier {
5228
c4a780348f66 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff changeset
    47
	char *filename;
6307
f40e88cff863 (svn r9639) [cpp_gui] -Sync with trunk (r9476:9633)
KUDr
parents: 6303
diff changeset
    48
	char *full_path;
5228
c4a780348f66 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff changeset
    49
	char *name;
c4a780348f66 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff changeset
    50
	char *info;
6268
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6016
diff changeset
    51
	GRFError *error;
5228
c4a780348f66 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff changeset
    52
c4a780348f66 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff changeset
    53
	uint8 flags;
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6268
diff changeset
    54
	GRFStatus status;
5228
c4a780348f66 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff changeset
    55
	uint32 param[0x80];
c4a780348f66 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff changeset
    56
	uint8 num_params;
c4a780348f66 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff changeset
    57
c4a780348f66 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff changeset
    58
	struct GRFConfig *next;
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6268
diff changeset
    59
};
5228
c4a780348f66 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff changeset
    60
c4a780348f66 (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 */
c4a780348f66 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff changeset
    62
extern GRFConfig *_all_grfs;
c4a780348f66 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff changeset
    63
c4a780348f66 (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 */
c4a780348f66 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff changeset
    65
extern GRFConfig *_grfconfig;
c4a780348f66 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff changeset
    66
c4a780348f66 (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 */
c4a780348f66 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff changeset
    68
extern GRFConfig *_grfconfig_newgame;
c4a780348f66 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff changeset
    69
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
    70
/* First item in list of static GRF set up */
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
    71
extern GRFConfig *_grfconfig_static;
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
    72
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6268
diff changeset
    73
void ScanNewGRFFiles();
5897
016df903f3bb (svn r8105) -Codechange: Change FindGRFConfig so that if md5sum parameter is omitted (or NULL)
Darkvater
parents: 5726
diff changeset
    74
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
    75
GRFConfig *GetGRFConfig(uint32 grfid);
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
    76
GRFConfig **CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src);
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
    77
void AppendStaticGRFConfigs(GRFConfig **dst);
6268
4b5241e5dd10 (svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents: 6016
diff changeset
    78
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
    79
void ClearGRFConfig(GRFConfig **config);
5347
18836f961808 (svn r7518) -Codechange: more NULL pointer resets after free.
Darkvater
parents: 5346
diff changeset
    80
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
    81
void ResetGRFConfig(bool defaults);
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6268
diff changeset
    82
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
    83
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
    84
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
    85
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
    86
/* 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
    87
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
    88
5692
b83442e14fd4 (svn r7692) -Fix: OpenTTD didn't compile without network enabled (newgrf sync code)
Darkvater
parents: 5581
diff changeset
    89
#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
    90
/* 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
    91
#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
    92
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
    93
#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
    94
5228
c4a780348f66 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff changeset
    95
#endif /* NEWGRF_CONFIG_H */