diff options
author | Darkvater <darkvater@openttd.org> | 2007-02-22 16:16:44 +0000 |
---|---|---|
committer | Darkvater <darkvater@openttd.org> | 2007-02-22 16:16:44 +0000 |
commit | 31be3c6fac70752f97b81490b3aa0f0d3d6c0764 (patch) | |
tree | 193b4d1c17fae519d21ba6f62142a9f496fe834b /src/newgrf_config.cpp | |
parent | c8343206115a50afb27743937d6c477516cbfdb2 (diff) | |
download | openttd-31be3c6fac70752f97b81490b3aa0f0d3d6c0764.tar.xz |
(svn r8844) -Revert partly (r8820, r8806): Change AppendToGRFConfigList to add the allocated GRFConfig to its list and not copy it.
Diffstat (limited to 'src/newgrf_config.cpp')
-rw-r--r-- | src/newgrf_config.cpp | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp index d6b910e05..70d5da9ec 100644 --- a/src/newgrf_config.cpp +++ b/src/newgrf_config.cpp @@ -178,13 +178,13 @@ void AppendStaticGRFConfigs(GRFConfig **dst) } /** Appends an element to a list of GRFs - * @param dst the head of the list to add to - * @param el the element that is being added (as a copy) */ -void AppendToGRFConfigList(GRFConfig **dst, const GRFConfig *el) + * @param dst the head of the list to add to */ +void AppendToGRFConfigList(GRFConfig **dst, GRFConfig *el) { GRFConfig **tail = dst; while (*tail != NULL) tail = &(*tail)->next; - CopyGRFConfigList(tail, el); + *tail = el; + RemoveDuplicatesFromGRFConfigList(*dst); } @@ -451,10 +451,9 @@ static const SaveLoad _grfconfig_desc[] = { static void Save_NGRF(void) { - GRFConfig *c; int index = 0; - for (c = _grfconfig; c != NULL; c = c->next) { + for (GRFConfig *c = _grfconfig; c != NULL; c = c->next) { if (HASBIT(c->flags, GCF_STATIC)) continue; SlSetArrayIndex(index++); SlObject(c, _grfconfig_desc); @@ -464,12 +463,11 @@ static void Save_NGRF(void) static void Load_NGRF(void) { - GRFConfig c; - memset(&c, 0, sizeof(GRFConfig)); - + ClearGRFConfigList(&_grfconfig); while (SlIterateArray() != -1) { - SlObject(&c, _grfconfig_desc); - AppendToGRFConfigList(&_grfconfig, &c); + GRFConfig *c = CallocT<GRFConfig>(1); + SlObject(c, _grfconfig_desc); + AppendToGRFConfigList(&_grfconfig, c); } /* Append static NewGRF configuration */ |