equal
deleted
inserted
replaced
10 #include "saveload.h" |
10 #include "saveload.h" |
11 #include "md5.h" |
11 #include "md5.h" |
12 #include "network/network_data.h" |
12 #include "network/network_data.h" |
13 #include "newgrf.h" |
13 #include "newgrf.h" |
14 #include "newgrf_config.h" |
14 #include "newgrf_config.h" |
|
15 #include "helpers.hpp" |
15 |
16 |
16 #include "fileio.h" |
17 #include "fileio.h" |
17 #include "fios.h" |
18 #include "fios.h" |
18 #include <sys/types.h> |
19 #include <sys/types.h> |
19 #include <sys/stat.h> |
20 #include <sys/stat.h> |
121 GRFConfig *c; |
122 GRFConfig *c; |
122 |
123 |
123 /* Clear destination as it will be overwritten */ |
124 /* Clear destination as it will be overwritten */ |
124 ClearGRFConfigList(dst); |
125 ClearGRFConfigList(dst); |
125 for (; src != NULL; src = src->next) { |
126 for (; src != NULL; src = src->next) { |
126 c = calloc(1, sizeof(*c)); |
127 CallocT(&c, 1); |
127 *c = *src; |
128 *c = *src; |
128 if (src->filename != NULL) c->filename = strdup(src->filename); |
129 if (src->filename != NULL) c->filename = strdup(src->filename); |
129 if (src->name != NULL) c->name = strdup(src->name); |
130 if (src->name != NULL) c->name = strdup(src->name); |
130 if (src->info != NULL) c->info = strdup(src->info); |
131 if (src->info != NULL) c->info = strdup(src->info); |
131 |
132 |
267 |
268 |
268 /* If no extension or extension isn't .grf, skip the file */ |
269 /* If no extension or extension isn't .grf, skip the file */ |
269 if (ext == NULL) continue; |
270 if (ext == NULL) continue; |
270 if (strcasecmp(ext, ".grf") != 0) continue; |
271 if (strcasecmp(ext, ".grf") != 0) continue; |
271 |
272 |
272 c = calloc(1, sizeof(*c)); |
273 CallocT(&c, 1); |
273 c->filename = strdup(file); |
274 c->filename = strdup(file); |
274 |
275 |
275 if (FillGRFDetails(c, false)) { |
276 if (FillGRFDetails(c, false)) { |
276 if (_all_grfs == NULL) { |
277 if (_all_grfs == NULL) { |
277 _all_grfs = c; |
278 _all_grfs = c; |
372 } |
373 } |
373 } |
374 } |
374 |
375 |
375 if (!create) return NULL; |
376 if (!create) return NULL; |
376 |
377 |
377 grf = calloc(1, sizeof(*grf)); |
378 CallocT(&grf, 1); |
378 grf->grfid = grfid; |
379 grf->grfid = grfid; |
379 grf->next = unknown_grfs; |
380 grf->next = unknown_grfs; |
380 ttd_strlcpy(grf->name, UNKNOWN_GRF_NAME_PLACEHOLDER, sizeof(grf->name)); |
381 ttd_strlcpy(grf->name, UNKNOWN_GRF_NAME_PLACEHOLDER, sizeof(grf->name)); |
381 memcpy(grf->md5sum, md5sum, sizeof(grf->md5sum)); |
382 memcpy(grf->md5sum, md5sum, sizeof(grf->md5sum)); |
382 |
383 |
443 { |
444 { |
444 GRFConfig *first = NULL; |
445 GRFConfig *first = NULL; |
445 GRFConfig **last = &first; |
446 GRFConfig **last = &first; |
446 |
447 |
447 while (SlIterateArray() != -1) { |
448 while (SlIterateArray() != -1) { |
448 GRFConfig *c = calloc(1, sizeof(*c)); |
449 GRFConfig *c; |
|
450 CallocT(&c, 1); |
449 SlObject(c, _grfconfig_desc); |
451 SlObject(c, _grfconfig_desc); |
450 |
452 |
451 /* Append our configuration to the list */ |
453 /* Append our configuration to the list */ |
452 *last = c; |
454 *last = c; |
453 last = &c->next; |
455 last = &c->next; |
459 ClearGRFConfigList(&_grfconfig); |
461 ClearGRFConfigList(&_grfconfig); |
460 _grfconfig = first; |
462 _grfconfig = first; |
461 AppendStaticGRFConfigs(&_grfconfig); |
463 AppendStaticGRFConfigs(&_grfconfig); |
462 } |
464 } |
463 |
465 |
464 const ChunkHandler _newgrf_chunk_handlers[] = { |
466 extern const ChunkHandler _newgrf_chunk_handlers[] = { |
465 { 'NGRF', Save_NGRF, Load_NGRF, CH_ARRAY | CH_LAST } |
467 { 'NGRF', Save_NGRF, Load_NGRF, CH_ARRAY | CH_LAST } |
466 }; |
468 }; |
467 |
469 |
468 |
470 |