176 CopyGRFConfigList(tail, _grfconfig_static); |
176 CopyGRFConfigList(tail, _grfconfig_static); |
177 RemoveDuplicatesFromGRFConfigList(*dst); |
177 RemoveDuplicatesFromGRFConfigList(*dst); |
178 } |
178 } |
179 |
179 |
180 /** Appends an element to a list of GRFs |
180 /** Appends an element to a list of GRFs |
181 * @param dst the head of the list to add to |
181 * @param dst the head of the list to add to */ |
182 * @param el the element that is being added (as a copy) */ |
182 void AppendToGRFConfigList(GRFConfig **dst, GRFConfig *el) |
183 void AppendToGRFConfigList(GRFConfig **dst, const GRFConfig *el) |
|
184 { |
183 { |
185 GRFConfig **tail = dst; |
184 GRFConfig **tail = dst; |
186 while (*tail != NULL) tail = &(*tail)->next; |
185 while (*tail != NULL) tail = &(*tail)->next; |
187 CopyGRFConfigList(tail, el); |
186 *tail = el; |
|
187 |
188 RemoveDuplicatesFromGRFConfigList(*dst); |
188 RemoveDuplicatesFromGRFConfigList(*dst); |
189 } |
189 } |
190 |
190 |
191 |
191 |
192 /* Reset the current GRF Config to either blank or newgame settings */ |
192 /* Reset the current GRF Config to either blank or newgame settings */ |
449 }; |
449 }; |
450 |
450 |
451 |
451 |
452 static void Save_NGRF(void) |
452 static void Save_NGRF(void) |
453 { |
453 { |
454 GRFConfig *c; |
|
455 int index = 0; |
454 int index = 0; |
456 |
455 |
457 for (c = _grfconfig; c != NULL; c = c->next) { |
456 for (GRFConfig *c = _grfconfig; c != NULL; c = c->next) { |
458 if (HASBIT(c->flags, GCF_STATIC)) continue; |
457 if (HASBIT(c->flags, GCF_STATIC)) continue; |
459 SlSetArrayIndex(index++); |
458 SlSetArrayIndex(index++); |
460 SlObject(c, _grfconfig_desc); |
459 SlObject(c, _grfconfig_desc); |
461 } |
460 } |
462 } |
461 } |
463 |
462 |
464 |
463 |
465 static void Load_NGRF(void) |
464 static void Load_NGRF(void) |
466 { |
465 { |
467 GRFConfig c; |
466 ClearGRFConfigList(&_grfconfig); |
468 memset(&c, 0, sizeof(GRFConfig)); |
|
469 |
|
470 while (SlIterateArray() != -1) { |
467 while (SlIterateArray() != -1) { |
471 SlObject(&c, _grfconfig_desc); |
468 GRFConfig *c = CallocT<GRFConfig>(1); |
472 AppendToGRFConfigList(&_grfconfig, &c); |
469 SlObject(c, _grfconfig_desc); |
|
470 AppendToGRFConfigList(&_grfconfig, c); |
473 } |
471 } |
474 |
472 |
475 /* Append static NewGRF configuration */ |
473 /* Append static NewGRF configuration */ |
476 AppendStaticGRFConfigs(&_grfconfig); |
474 AppendStaticGRFConfigs(&_grfconfig); |
477 } |
475 } |