summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2007-09-13 18:26:18 +0000
committertruelight <truelight@openttd.org>2007-09-13 18:26:18 +0000
commit122cc9e1a47cd7a0e7ad12ad5d61359138b1d57e (patch)
tree57ed313459cf2555a7e2ff9715c89a4de425d0e7 /src
parente5452205634d47d61039208c2d2fa6457b3f32bf (diff)
downloadopenttd-122cc9e1a47cd7a0e7ad12ad5d61359138b1d57e.tar.xz
(svn r11096) -Fix: when 2 different GRF-files had the same name (e.g.: ""), the double-entry checker didn't always work correctly, resulting in multiple entries of the same grf in the list
Diffstat (limited to 'src')
-rw-r--r--src/newgrf_config.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp
index 49a90d0da..2e30841b4 100644
--- a/src/newgrf_config.cpp
+++ b/src/newgrf_config.cpp
@@ -315,9 +315,14 @@ static uint ScanPath(const char *path, int basepath_length)
/* Insert file into list at a position determined by its
* name, so the list is sorted as we go along */
GRFConfig **pd, *d;
+ bool stop = false;
for (pd = &_all_grfs; (d = *pd) != NULL; pd = &d->next) {
if (c->grfid == d->grfid && memcmp(c->md5sum, d->md5sum, sizeof(c->md5sum)) == 0) added = false;
- if (strcasecmp(c->name, d->name) <= 0) break;
+ /* Because there can be multiple grfs with the same name, make sure we checked all grfs with the same name,
+ * before inserting the entry. So insert a new grf at the end of all grfs with the same name, instead of
+ * just after the first with the same name. Avoids doubles in the list. */
+ if (strcasecmp(c->name, d->name) <= 0) stop = true;
+ else if (stop) break;
}
if (added) {
c->next = d;