author | KUDr |
Sun, 31 Dec 2006 02:53:23 +0000 | |
branch | custombridgeheads |
changeset 5611 | 11da6bafbfb9 |
parent 5592 | fd60d4ecc921 |
child 5623 | ef2a8a524a95 |
permissions | -rw-r--r-- |
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 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
3 |
#include "stdafx.h" |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
4 |
#include "openttd.h" |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
5 |
#include "functions.h" |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
6 |
#include "macros.h" |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
7 |
#include "debug.h" |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
8 |
#include "variables.h" |
5308
bad31e174cc6
(svn r7464) -Codechange: move BuildParamList from newgrf_gui to newgrf_config and
peter1138
parents:
5296
diff
changeset
|
9 |
#include "string.h" |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
10 |
#include "saveload.h" |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
11 |
#include "md5.h" |
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
|
12 |
#include "network_data.h" |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
13 |
#include "newgrf.h" |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
14 |
#include "newgrf_config.h" |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
15 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
16 |
#include "fileio.h" |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
17 |
#include "fios.h" |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
18 |
#include <sys/types.h> |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
19 |
#include <sys/stat.h> |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
20 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
21 |
#ifdef WIN32 |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
22 |
# include <io.h> |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
23 |
#else |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
24 |
# include <unistd.h> |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
25 |
# include <dirent.h> |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
26 |
#endif /* WIN32 */ |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
27 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
28 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
29 |
GRFConfig *_all_grfs; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
30 |
GRFConfig *_grfconfig; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
31 |
GRFConfig *_grfconfig_newgame; |
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
|
32 |
GRFConfig *_grfconfig_static; |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
33 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
34 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
35 |
/* Calculate the MD5 Sum for a GRF */ |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
36 |
static bool CalcGRFMD5Sum(GRFConfig *config) |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
37 |
{ |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
38 |
FILE *f; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
39 |
char filename[MAX_PATH]; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
40 |
md5_state_t md5state; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
41 |
md5_byte_t buffer[1024]; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
42 |
size_t len; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
43 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
44 |
/* open the file */ |
5296
6a4aaa66eed3
(svn r7449) -Codechange: Rename _path to _paths as it is technically more correct, but mainly because
Darkvater
parents:
5234
diff
changeset
|
45 |
snprintf(filename, lengthof(filename), "%s%s", _paths.data_dir, config->filename); |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
46 |
f = fopen(filename, "rb"); |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
47 |
if (f == NULL) return false; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
48 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
49 |
/* calculate md5sum */ |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
50 |
md5_init(&md5state); |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
51 |
while ((len = fread(buffer, 1, sizeof(buffer), f)) != 0) { |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
52 |
md5_append(&md5state, buffer, len); |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
53 |
} |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
54 |
md5_finish(&md5state, config->md5sum); |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
55 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
56 |
fclose(f); |
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 |
return true; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
59 |
} |
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 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
62 |
/* Find the GRFID and calculate the md5sum */ |
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
|
63 |
bool FillGRFDetails(GRFConfig *config, bool is_static) |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
64 |
{ |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
65 |
if (!FioCheckFileExists(config->filename)) { |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
66 |
SETBIT(config->flags, GCF_NOT_FOUND); |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
67 |
return false; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
68 |
} |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
69 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
70 |
/* Find and load the Action 8 information */ |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
71 |
/* 62 is the last file slot before sample.cat. |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
72 |
* Should perhaps be some "don't care" value */ |
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
|
73 |
LoadNewGRFFile(config, 62, is_static ? GLS_SAFETYSCAN : GLS_FILESCAN); |
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
|
74 |
|
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 |
/* GCF_UNSAFE is set if GLS_SAFETYSCAN finds unsafe actions */ |
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
|
76 |
if (HASBIT(config->flags, GCF_UNSAFE)) return false; |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
77 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
78 |
/* Skip if the grfid is 0 (not read) or 0xFFFFFFFF (ttdp system grf) */ |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
79 |
if (config->grfid == 0 || config->grfid == 0xFFFFFFFF) return false; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
80 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
81 |
return CalcGRFMD5Sum(config); |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
82 |
} |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
83 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
84 |
|
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
|
85 |
void ClearGRFConfig(GRFConfig **config) |
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 |
{ |
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
|
87 |
/* GCF_COPY as in NOT strdupped/alloced the filename, name and info */ |
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
|
88 |
if (!HASBIT((*config)->flags, GCF_COPY)) { |
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
|
89 |
free((*config)->filename); |
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
|
90 |
free((*config)->name); |
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
|
91 |
free((*config)->info); |
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
|
92 |
} |
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
|
93 |
free(*config); |
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
|
94 |
*config = NULL; |
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
|
95 |
} |
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
|
96 |
|
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
|
97 |
|
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
98 |
/* Clear a GRF Config list */ |
5347
18836f961808
(svn r7518) -Codechange: more NULL pointer resets after free.
Darkvater
parents:
5346
diff
changeset
|
99 |
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
|
100 |
{ |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
101 |
GRFConfig *c, *next; |
5347
18836f961808
(svn r7518) -Codechange: more NULL pointer resets after free.
Darkvater
parents:
5346
diff
changeset
|
102 |
for (c = *config; c != NULL; c = next) { |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
103 |
next = c->next; |
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
|
104 |
ClearGRFConfig(&c); |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
105 |
} |
5347
18836f961808
(svn r7518) -Codechange: more NULL pointer resets after free.
Darkvater
parents:
5346
diff
changeset
|
106 |
*config = NULL; |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
107 |
} |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
108 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
109 |
|
5347
18836f961808
(svn r7518) -Codechange: more NULL pointer resets after free.
Darkvater
parents:
5346
diff
changeset
|
110 |
/** Copy a GRF Config list |
18836f961808
(svn r7518) -Codechange: more NULL pointer resets after free.
Darkvater
parents:
5346
diff
changeset
|
111 |
* @param dst pointer to destination list |
18836f961808
(svn r7518) -Codechange: more NULL pointer resets after free.
Darkvater
parents:
5346
diff
changeset
|
112 |
* @param srt pointer to source list values |
18836f961808
(svn r7518) -Codechange: more NULL pointer resets after free.
Darkvater
parents:
5346
diff
changeset
|
113 |
* @return pointer to the last value added to the destination list */ |
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
|
114 |
GRFConfig **CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src) |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
115 |
{ |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
116 |
GRFConfig *c; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
117 |
|
5351
0980b66406af
(svn r7522) -Codechange: Have CopyGRFConfigList clear the destination list before assigning
Darkvater
parents:
5349
diff
changeset
|
118 |
/* Clear destination as it will be overwritten */ |
0980b66406af
(svn r7522) -Codechange: Have CopyGRFConfigList clear the destination list before assigning
Darkvater
parents:
5349
diff
changeset
|
119 |
ClearGRFConfigList(dst); |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
120 |
for (; src != NULL; src = src->next) { |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
121 |
c = calloc(1, sizeof(*c)); |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
122 |
*c = *src; |
5554
a3e614f5d837
(svn r7551) -Fix (r7523): segmentation fault on showing NewGRF settings of a network game.
rubidium
parents:
5351
diff
changeset
|
123 |
if (src->filename != NULL) c->filename = strdup(src->filename); |
a3e614f5d837
(svn r7551) -Fix (r7523): segmentation fault on showing NewGRF settings of a network game.
rubidium
parents:
5351
diff
changeset
|
124 |
if (src->name != NULL) c->name = strdup(src->name); |
a3e614f5d837
(svn r7551) -Fix (r7523): segmentation fault on showing NewGRF settings of a network game.
rubidium
parents:
5351
diff
changeset
|
125 |
if (src->info != NULL) c->info = strdup(src->info); |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
126 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
127 |
*dst = c; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
128 |
dst = &c->next; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
129 |
} |
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
|
130 |
|
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
|
131 |
return dst; |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
132 |
} |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
133 |
|
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:
5568
diff
changeset
|
134 |
/** |
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:
5568
diff
changeset
|
135 |
* Removes duplicates from lists of GRFConfigs. These duplicates |
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:
5568
diff
changeset
|
136 |
* are introduced when the _grfconfig_static GRFs are appended |
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:
5568
diff
changeset
|
137 |
* to the _grfconfig on a newgame or savegame. As the parameters |
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:
5568
diff
changeset
|
138 |
* of the static GRFs could be different that the parameters of |
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:
5568
diff
changeset
|
139 |
* the ones used non-statically. This can result in desyncs in |
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:
5568
diff
changeset
|
140 |
* multiplayers, so the duplicate static GRFs have to be removed. |
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:
5568
diff
changeset
|
141 |
* |
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:
5568
diff
changeset
|
142 |
* This function _assumes_ that all static GRFs are placed after |
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:
5568
diff
changeset
|
143 |
* the non-static GRFs. |
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:
5568
diff
changeset
|
144 |
* |
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:
5568
diff
changeset
|
145 |
* @param list the list to remove the duplicates from |
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:
5568
diff
changeset
|
146 |
*/ |
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:
5568
diff
changeset
|
147 |
static void RemoveDuplicatesFromGRFConfigList(GRFConfig *list) |
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:
5568
diff
changeset
|
148 |
{ |
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:
5568
diff
changeset
|
149 |
GRFConfig *prev; |
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:
5568
diff
changeset
|
150 |
GRFConfig *cur; |
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:
5568
diff
changeset
|
151 |
|
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:
5568
diff
changeset
|
152 |
if (list == NULL) return; |
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:
5568
diff
changeset
|
153 |
|
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:
5568
diff
changeset
|
154 |
for (prev = list, cur = list->next; cur != NULL; prev = cur, cur = cur->next) { |
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:
5568
diff
changeset
|
155 |
if (cur->grfid != list->grfid) continue; |
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:
5568
diff
changeset
|
156 |
assert(HASBIT(cur->flags, GCF_STATIC)); |
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:
5568
diff
changeset
|
157 |
prev->next = cur->next; |
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:
5568
diff
changeset
|
158 |
ClearGRFConfig(&cur); |
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:
5568
diff
changeset
|
159 |
cur = prev; // Just go back one so it continues as normal later on |
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:
5568
diff
changeset
|
160 |
} |
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:
5568
diff
changeset
|
161 |
|
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:
5568
diff
changeset
|
162 |
RemoveDuplicatesFromGRFConfigList(list->next); |
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:
5568
diff
changeset
|
163 |
} |
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:
5568
diff
changeset
|
164 |
|
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:
5568
diff
changeset
|
165 |
/** |
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:
5568
diff
changeset
|
166 |
* Appends the static GRFs to a list of GRFs |
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:
5568
diff
changeset
|
167 |
* @param dst the head of the list to add to |
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:
5568
diff
changeset
|
168 |
*/ |
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:
5568
diff
changeset
|
169 |
void AppendStaticGRFConfigs(GRFConfig **dst) |
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:
5568
diff
changeset
|
170 |
{ |
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:
5568
diff
changeset
|
171 |
GRFConfig **tail = dst; |
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:
5568
diff
changeset
|
172 |
while (*tail != NULL) tail = &(*tail)->next; |
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:
5568
diff
changeset
|
173 |
|
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:
5568
diff
changeset
|
174 |
CopyGRFConfigList(tail, _grfconfig_static); |
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:
5568
diff
changeset
|
175 |
RemoveDuplicatesFromGRFConfigList(*dst); |
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:
5568
diff
changeset
|
176 |
} |
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:
5568
diff
changeset
|
177 |
|
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
178 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
179 |
/* Reset the current GRF Config to either blank or newgame settings */ |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
180 |
void ResetGRFConfig(bool defaults) |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
181 |
{ |
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
|
182 |
GRFConfig **c = &_grfconfig; |
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
|
183 |
|
5592
fd60d4ecc921
(svn r7608) [cbh] - Merge with trunk r7593:7607 because I need 7607 here
celestar
parents:
5581
diff
changeset
|
184 |
if (defaults) { |
fd60d4ecc921
(svn r7608) [cbh] - Merge with trunk r7593:7607 because I need 7607 here
celestar
parents:
5581
diff
changeset
|
185 |
c = CopyGRFConfigList(c, _grfconfig_newgame); |
fd60d4ecc921
(svn r7608) [cbh] - Merge with trunk r7593:7607 because I need 7607 here
celestar
parents:
5581
diff
changeset
|
186 |
} else { |
fd60d4ecc921
(svn r7608) [cbh] - Merge with trunk r7593:7607 because I need 7607 here
celestar
parents:
5581
diff
changeset
|
187 |
ClearGRFConfigList(c); |
fd60d4ecc921
(svn r7608) [cbh] - Merge with trunk r7593:7607 because I need 7607 here
celestar
parents:
5581
diff
changeset
|
188 |
} |
fd60d4ecc921
(svn r7608) [cbh] - Merge with trunk r7593:7607 because I need 7607 here
celestar
parents:
5581
diff
changeset
|
189 |
|
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:
5568
diff
changeset
|
190 |
AppendStaticGRFConfigs(&_grfconfig); |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
191 |
} |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
192 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
193 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
194 |
/* Check if all GRFs in the GRF Config can be loaded */ |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
195 |
bool IsGoodGRFConfigList(void) |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
196 |
{ |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
197 |
bool res = true; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
198 |
GRFConfig *c; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
199 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
200 |
for (c = _grfconfig; c != NULL; c = c->next) { |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
201 |
const GRFConfig *f = FindGRFConfig(c->grfid, c->md5sum); |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
202 |
if (f == NULL) { |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
203 |
char buf[512], *p = buf; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
204 |
uint i; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
205 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
206 |
p += snprintf(p, lastof(buf) - p, "Couldn't find NewGRF %08X (%s) checksum ", BSWAP32(c->grfid), c->filename); |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
207 |
for (i = 0; i < lengthof(c->md5sum); i++) { |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
208 |
p += snprintf(p, lastof(buf) - p, "%02X", c->md5sum[i]); |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
209 |
} |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
210 |
ShowInfo(buf); |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
211 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
212 |
res = false; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
213 |
} else { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5554
diff
changeset
|
214 |
DEBUG(grf, 1, "Loading GRF %08X from '%s'", BSWAP32(c->grfid), f->filename); |
5349
6a220d58c0ce
(svn r7520) -Fix(r7348): memleak due to unconditionally overwriting the filename, name and info of a GRFConfig in IsGoodGRFConfigList.
rubidium
parents:
5347
diff
changeset
|
215 |
/* The filename could be the filename as in the savegame. As we need |
6a220d58c0ce
(svn r7520) -Fix(r7348): memleak due to unconditionally overwriting the filename, name and info of a GRFConfig in IsGoodGRFConfigList.
rubidium
parents:
5347
diff
changeset
|
216 |
* to load the GRF here, we need the correct filename, so overwrite that |
6a220d58c0ce
(svn r7520) -Fix(r7348): memleak due to unconditionally overwriting the filename, name and info of a GRFConfig in IsGoodGRFConfigList.
rubidium
parents:
5347
diff
changeset
|
217 |
* in any case and set the name and info when it is not set already. |
6a220d58c0ce
(svn r7520) -Fix(r7348): memleak due to unconditionally overwriting the filename, name and info of a GRFConfig in IsGoodGRFConfigList.
rubidium
parents:
5347
diff
changeset
|
218 |
* When the GCF_COPY flag is set, it is certain that the filename is |
6a220d58c0ce
(svn r7520) -Fix(r7348): memleak due to unconditionally overwriting the filename, name and info of a GRFConfig in IsGoodGRFConfigList.
rubidium
parents:
5347
diff
changeset
|
219 |
* already a local one, so there is no need to replace it. */ |
6a220d58c0ce
(svn r7520) -Fix(r7348): memleak due to unconditionally overwriting the filename, name and info of a GRFConfig in IsGoodGRFConfigList.
rubidium
parents:
5347
diff
changeset
|
220 |
if (!HASBIT(c->flags, GCF_COPY)) { |
6a220d58c0ce
(svn r7520) -Fix(r7348): memleak due to unconditionally overwriting the filename, name and info of a GRFConfig in IsGoodGRFConfigList.
rubidium
parents:
5347
diff
changeset
|
221 |
free(c->filename); |
6a220d58c0ce
(svn r7520) -Fix(r7348): memleak due to unconditionally overwriting the filename, name and info of a GRFConfig in IsGoodGRFConfigList.
rubidium
parents:
5347
diff
changeset
|
222 |
c->filename = strdup(f->filename); |
6a220d58c0ce
(svn r7520) -Fix(r7348): memleak due to unconditionally overwriting the filename, name and info of a GRFConfig in IsGoodGRFConfigList.
rubidium
parents:
5347
diff
changeset
|
223 |
if (c->name == NULL) c->name = strdup(f->name); |
6a220d58c0ce
(svn r7520) -Fix(r7348): memleak due to unconditionally overwriting the filename, name and info of a GRFConfig in IsGoodGRFConfigList.
rubidium
parents:
5347
diff
changeset
|
224 |
if (c->info == NULL) c->info = strdup(f->info); |
6a220d58c0ce
(svn r7520) -Fix(r7348): memleak due to unconditionally overwriting the filename, name and info of a GRFConfig in IsGoodGRFConfigList.
rubidium
parents:
5347
diff
changeset
|
225 |
} |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
226 |
} |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
227 |
} |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
228 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
229 |
return res; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
230 |
} |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
231 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
232 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
233 |
extern bool FiosIsValidFile(const char *path, const struct dirent *ent, struct stat *sb); |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
234 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
235 |
/* Scan a path for NewGRFs */ |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
236 |
static uint ScanPath(const char *path) |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
237 |
{ |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
238 |
uint num = 0; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
239 |
struct stat sb; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
240 |
struct dirent *dirent; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
241 |
DIR *dir; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
242 |
GRFConfig *c; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
243 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
244 |
if ((dir = opendir(path)) == NULL) return 0; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
245 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
246 |
while ((dirent = readdir(dir)) != NULL) { |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
247 |
const char *d_name = FS2OTTD(dirent->d_name); |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
248 |
char filename[MAX_PATH]; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
249 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
250 |
if (!FiosIsValidFile(path, dirent, &sb)) continue; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
251 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
252 |
snprintf(filename, lengthof(filename), "%s" PATHSEP "%s", path, d_name); |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
253 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
254 |
if (sb.st_mode & S_IFDIR) { |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
255 |
/* Directory */ |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
256 |
if (strcmp(d_name, ".") == 0 || strcmp(d_name, "..") == 0) continue; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
257 |
num += ScanPath(filename); |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
258 |
} else if (sb.st_mode & S_IFREG) { |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
259 |
/* File */ |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
260 |
char *ext = strrchr(filename, '.'); |
5296
6a4aaa66eed3
(svn r7449) -Codechange: Rename _path to _paths as it is technically more correct, but mainly because
Darkvater
parents:
5234
diff
changeset
|
261 |
char *file = filename + strlen(_paths.data_dir) + 1; // Crop base path |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
262 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
263 |
/* If no extension or extension isn't .grf, skip the file */ |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
264 |
if (ext == NULL) continue; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
265 |
if (strcasecmp(ext, ".grf") != 0) continue; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
266 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
267 |
c = calloc(1, sizeof(*c)); |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
268 |
c->filename = strdup(file); |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
269 |
|
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
|
270 |
if (FillGRFDetails(c, false)) { |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
271 |
if (_all_grfs == NULL) { |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
272 |
_all_grfs = c; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
273 |
} else { |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
274 |
/* Insert file into list at a position determined by its |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
275 |
* name, so the list is sorted as we go along */ |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
276 |
GRFConfig **pd, *d; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
277 |
for (pd = &_all_grfs; (d = *pd) != NULL; pd = &d->next) { |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
278 |
if (strcasecmp(c->name, d->name) <= 0) break; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
279 |
} |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
280 |
c->next = d; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
281 |
*pd = c; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
282 |
} |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
283 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
284 |
num++; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
285 |
} else { |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
286 |
/* File couldn't be opened, or is either not a NewGRF or is a |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
287 |
* 'system' NewGRF, so forget about it. */ |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
288 |
free(c->filename); |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
289 |
free(c->name); |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
290 |
free(c->info); |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
291 |
free(c); |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
292 |
} |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
293 |
} |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
294 |
} |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
295 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
296 |
closedir(dir); |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
297 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
298 |
return num; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
299 |
} |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
300 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
301 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
302 |
/* Scan for all NewGRFs */ |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
303 |
void ScanNewGRFFiles(void) |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
304 |
{ |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
305 |
uint num; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
306 |
|
5347
18836f961808
(svn r7518) -Codechange: more NULL pointer resets after free.
Darkvater
parents:
5346
diff
changeset
|
307 |
ClearGRFConfigList(&_all_grfs); |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
308 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5554
diff
changeset
|
309 |
DEBUG(grf, 1, "Scanning for NewGRFs"); |
5296
6a4aaa66eed3
(svn r7449) -Codechange: Rename _path to _paths as it is technically more correct, but mainly because
Darkvater
parents:
5234
diff
changeset
|
310 |
num = ScanPath(_paths.data_dir); |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5554
diff
changeset
|
311 |
DEBUG(grf, 1, "Scan complete, found %d files", num); |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
312 |
} |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
313 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
314 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
315 |
/* Find a NewGRF in the scanned list */ |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
316 |
const GRFConfig *FindGRFConfig(uint32 grfid, uint8 *md5sum) |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
317 |
{ |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
318 |
GRFConfig *c; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
319 |
static const uint8 blanksum[sizeof(c->md5sum)] = { 0 }; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
320 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
321 |
for (c = _all_grfs; c != NULL; c = c->next) { |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
322 |
if (c->grfid == grfid) { |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
323 |
if (memcmp(blanksum, c->md5sum, sizeof(c->md5sum)) == 0) CalcGRFMD5Sum(c); |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
324 |
if (memcmp(md5sum, c->md5sum, sizeof(c->md5sum)) == 0) return c; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
325 |
} |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
326 |
} |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
327 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
328 |
return NULL; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
329 |
} |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
330 |
|
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
|
331 |
/** Structure for UnknownGRFs; this is a lightweight variant of GRFConfig */ |
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
|
332 |
typedef struct UnknownGRF UnknownGRF; |
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
|
333 |
struct UnknownGRF { |
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
|
334 |
UnknownGRF *next; |
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
|
335 |
uint32 grfid; |
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
|
336 |
uint8 md5sum[16]; |
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
|
337 |
char name[NETWORK_GRF_NAME_LENGTH]; |
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
|
338 |
}; |
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
|
339 |
|
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
|
340 |
/** |
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
|
341 |
* Finds the name of a NewGRF in the list of names for unknown GRFs. An |
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
|
342 |
* unknown GRF is a GRF where the .grf is not found during scanning. |
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
|
343 |
* |
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
|
344 |
* The names are resolved via UDP calls to servers that should know the name, |
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
|
345 |
* though the replies may not come. This leaves "<Unknown>" as name, though |
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
|
346 |
* that shouldn't matter _very_ much as they need GRF crawler or so to look |
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
|
347 |
* up the GRF anyway and that works better with the GRF ID. |
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
|
348 |
* |
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
|
349 |
* @param grfid the GRF ID part of the 'unique' GRF identifier |
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
|
350 |
* @param md5sum the MD5 checksum part of the 'unique' GRF identifier |
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
|
351 |
* @param create whether to create a new GRFConfig if the GRFConfig did not |
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
|
352 |
* exist in the fake list of GRFConfigs. |
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
|
353 |
* @return the GRFConfig with the given GRF ID and MD5 checksum or NULL when |
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
|
354 |
* it does not exist and create is false. This value must NEVER be |
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
|
355 |
* freed by the caller. |
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
|
356 |
*/ |
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
|
357 |
char *FindUnknownGRFName(uint32 grfid, uint8 *md5sum, bool create) |
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
|
358 |
{ |
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
|
359 |
UnknownGRF *grf; |
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
|
360 |
static UnknownGRF *unknown_grfs = NULL; |
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
|
361 |
|
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
|
362 |
for (grf = unknown_grfs; grf != NULL; grf = grf->next) { |
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
|
363 |
if (grf->grfid == grfid) { |
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
|
364 |
if (memcmp(md5sum, grf->md5sum, sizeof(grf->md5sum)) == 0) return grf->name; |
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
|
365 |
} |
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
|
366 |
} |
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
|
367 |
|
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
|
368 |
if (!create) return NULL; |
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
|
369 |
|
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
|
370 |
grf = calloc(1, sizeof(*grf)); |
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
|
371 |
grf->grfid = grfid; |
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
|
372 |
grf->next = unknown_grfs; |
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
|
373 |
ttd_strlcpy(grf->name, UNKNOWN_GRF_NAME_PLACEHOLDER, sizeof(grf->name)); |
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
|
374 |
memcpy(grf->md5sum, md5sum, sizeof(grf->md5sum)); |
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
|
375 |
|
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
|
376 |
unknown_grfs = grf; |
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
|
377 |
return grf->name; |
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
|
378 |
} |
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
|
379 |
|
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
380 |
|
5234
91b7def5e4b2
(svn r7354) -Codechange: Remove grffile->flags and use grfconfig->flags exclusively. Update action 7/9 now that we know if GRFs are disabled.
peter1138
parents:
5229
diff
changeset
|
381 |
/* Retrieve a NewGRF from the current config by its grfid */ |
5333
8e7d68b06399
(svn r7495) -Fix (r7354): [NewGRF] Deactivate the target GRF, not the current GRF.
peter1138
parents:
5329
diff
changeset
|
382 |
GRFConfig *GetGRFConfig(uint32 grfid) |
5234
91b7def5e4b2
(svn r7354) -Codechange: Remove grffile->flags and use grfconfig->flags exclusively. Update action 7/9 now that we know if GRFs are disabled.
peter1138
parents:
5229
diff
changeset
|
383 |
{ |
91b7def5e4b2
(svn r7354) -Codechange: Remove grffile->flags and use grfconfig->flags exclusively. Update action 7/9 now that we know if GRFs are disabled.
peter1138
parents:
5229
diff
changeset
|
384 |
GRFConfig *c; |
91b7def5e4b2
(svn r7354) -Codechange: Remove grffile->flags and use grfconfig->flags exclusively. Update action 7/9 now that we know if GRFs are disabled.
peter1138
parents:
5229
diff
changeset
|
385 |
|
91b7def5e4b2
(svn r7354) -Codechange: Remove grffile->flags and use grfconfig->flags exclusively. Update action 7/9 now that we know if GRFs are disabled.
peter1138
parents:
5229
diff
changeset
|
386 |
for (c = _grfconfig; c != NULL; c = c->next) { |
91b7def5e4b2
(svn r7354) -Codechange: Remove grffile->flags and use grfconfig->flags exclusively. Update action 7/9 now that we know if GRFs are disabled.
peter1138
parents:
5229
diff
changeset
|
387 |
if (c->grfid == grfid) return c; |
91b7def5e4b2
(svn r7354) -Codechange: Remove grffile->flags and use grfconfig->flags exclusively. Update action 7/9 now that we know if GRFs are disabled.
peter1138
parents:
5229
diff
changeset
|
388 |
} |
91b7def5e4b2
(svn r7354) -Codechange: Remove grffile->flags and use grfconfig->flags exclusively. Update action 7/9 now that we know if GRFs are disabled.
peter1138
parents:
5229
diff
changeset
|
389 |
|
91b7def5e4b2
(svn r7354) -Codechange: Remove grffile->flags and use grfconfig->flags exclusively. Update action 7/9 now that we know if GRFs are disabled.
peter1138
parents:
5229
diff
changeset
|
390 |
return NULL; |
91b7def5e4b2
(svn r7354) -Codechange: Remove grffile->flags and use grfconfig->flags exclusively. Update action 7/9 now that we know if GRFs are disabled.
peter1138
parents:
5229
diff
changeset
|
391 |
} |
91b7def5e4b2
(svn r7354) -Codechange: Remove grffile->flags and use grfconfig->flags exclusively. Update action 7/9 now that we know if GRFs are disabled.
peter1138
parents:
5229
diff
changeset
|
392 |
|
91b7def5e4b2
(svn r7354) -Codechange: Remove grffile->flags and use grfconfig->flags exclusively. Update action 7/9 now that we know if GRFs are disabled.
peter1138
parents:
5229
diff
changeset
|
393 |
|
5308
bad31e174cc6
(svn r7464) -Codechange: move BuildParamList from newgrf_gui to newgrf_config and
peter1138
parents:
5296
diff
changeset
|
394 |
/* Build a space separated list of parameters, and terminate */ |
bad31e174cc6
(svn r7464) -Codechange: move BuildParamList from newgrf_gui to newgrf_config and
peter1138
parents:
5296
diff
changeset
|
395 |
char *GRFBuildParamList(char *dst, const GRFConfig *c, const char *last) |
bad31e174cc6
(svn r7464) -Codechange: move BuildParamList from newgrf_gui to newgrf_config and
peter1138
parents:
5296
diff
changeset
|
396 |
{ |
bad31e174cc6
(svn r7464) -Codechange: move BuildParamList from newgrf_gui to newgrf_config and
peter1138
parents:
5296
diff
changeset
|
397 |
uint i; |
bad31e174cc6
(svn r7464) -Codechange: move BuildParamList from newgrf_gui to newgrf_config and
peter1138
parents:
5296
diff
changeset
|
398 |
|
bad31e174cc6
(svn r7464) -Codechange: move BuildParamList from newgrf_gui to newgrf_config and
peter1138
parents:
5296
diff
changeset
|
399 |
/* Return an empty string if there are no parameters */ |
bad31e174cc6
(svn r7464) -Codechange: move BuildParamList from newgrf_gui to newgrf_config and
peter1138
parents:
5296
diff
changeset
|
400 |
if (c->num_params == 0) return strecpy(dst, "", last); |
bad31e174cc6
(svn r7464) -Codechange: move BuildParamList from newgrf_gui to newgrf_config and
peter1138
parents:
5296
diff
changeset
|
401 |
|
bad31e174cc6
(svn r7464) -Codechange: move BuildParamList from newgrf_gui to newgrf_config and
peter1138
parents:
5296
diff
changeset
|
402 |
for (i = 0; i < c->num_params; i++) { |
bad31e174cc6
(svn r7464) -Codechange: move BuildParamList from newgrf_gui to newgrf_config and
peter1138
parents:
5296
diff
changeset
|
403 |
if (i > 0) dst = strecpy(dst, " ", last); |
bad31e174cc6
(svn r7464) -Codechange: move BuildParamList from newgrf_gui to newgrf_config and
peter1138
parents:
5296
diff
changeset
|
404 |
dst += snprintf(dst, last - dst, "%d", c->param[i]); |
bad31e174cc6
(svn r7464) -Codechange: move BuildParamList from newgrf_gui to newgrf_config and
peter1138
parents:
5296
diff
changeset
|
405 |
} |
bad31e174cc6
(svn r7464) -Codechange: move BuildParamList from newgrf_gui to newgrf_config and
peter1138
parents:
5296
diff
changeset
|
406 |
return dst; |
bad31e174cc6
(svn r7464) -Codechange: move BuildParamList from newgrf_gui to newgrf_config and
peter1138
parents:
5296
diff
changeset
|
407 |
} |
bad31e174cc6
(svn r7464) -Codechange: move BuildParamList from newgrf_gui to newgrf_config and
peter1138
parents:
5296
diff
changeset
|
408 |
|
bad31e174cc6
(svn r7464) -Codechange: move BuildParamList from newgrf_gui to newgrf_config and
peter1138
parents:
5296
diff
changeset
|
409 |
|
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
410 |
static const SaveLoad _grfconfig_desc[] = { |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
411 |
SLE_STR(GRFConfig, filename, SLE_STR, 0x40), |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
412 |
SLE_VAR(GRFConfig, grfid, SLE_UINT32), |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
413 |
SLE_ARR(GRFConfig, md5sum, SLE_UINT8, 16), |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
414 |
SLE_ARR(GRFConfig, param, SLE_UINT32, 0x80), |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
415 |
SLE_VAR(GRFConfig, num_params, SLE_UINT8), |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
416 |
SLE_END() |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
417 |
}; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
418 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
419 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
420 |
static void Save_NGRF(void) |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
421 |
{ |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
422 |
GRFConfig *c; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
423 |
int index = 0; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
424 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
425 |
for (c = _grfconfig; c != NULL; c = c->next) { |
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
|
426 |
if (HASBIT(c->flags, GCF_STATIC)) continue; |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
427 |
SlSetArrayIndex(index++); |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
428 |
SlObject(c, _grfconfig_desc); |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
429 |
} |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
430 |
} |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
431 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
432 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
433 |
static void Load_NGRF(void) |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
434 |
{ |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
435 |
GRFConfig *first = NULL; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
436 |
GRFConfig **last = &first; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
437 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
438 |
while (SlIterateArray() != -1) { |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
439 |
GRFConfig *c = calloc(1, sizeof(*c)); |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
440 |
SlObject(c, _grfconfig_desc); |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
441 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
442 |
/* Append our configuration to the list */ |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
443 |
*last = c; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
444 |
last = &c->next; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
445 |
} |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
446 |
|
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
|
447 |
/* Append static NewGRF configuration */ |
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
|
448 |
CopyGRFConfigList(last, _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
|
449 |
|
5347
18836f961808
(svn r7518) -Codechange: more NULL pointer resets after free.
Darkvater
parents:
5346
diff
changeset
|
450 |
ClearGRFConfigList(&_grfconfig); |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
451 |
_grfconfig = first; |
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:
5568
diff
changeset
|
452 |
AppendStaticGRFConfigs(&_grfconfig); |
5228
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
453 |
} |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
454 |
|
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
455 |
const ChunkHandler _newgrf_chunk_handlers[] = { |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
456 |
{ 'NGRF', Save_NGRF, Load_NGRF, CH_ARRAY | CH_LAST } |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
457 |
}; |
c4a780348f66
(svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents:
diff
changeset
|
458 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5554
diff
changeset
|
459 |