301 if (FillGRFDetails(c, false)) { |
301 if (FillGRFDetails(c, false)) { |
302 if (_all_grfs == NULL) { |
302 if (_all_grfs == NULL) { |
303 _all_grfs = c; |
303 _all_grfs = c; |
304 } else { |
304 } else { |
305 /* Insert file into list at a position determined by its |
305 /* Insert file into list at a position determined by its |
306 * name, so the list is sorted as we go along */ |
306 * name, so the list is sorted as we go along */ |
307 GRFConfig **pd, *d; |
307 GRFConfig **pd, *d; |
308 bool stop = false; |
308 bool stop = false; |
309 for (pd = &_all_grfs; (d = *pd) != NULL; pd = &d->next) { |
309 for (pd = &_all_grfs; (d = *pd) != NULL; pd = &d->next) { |
310 if (c->grfid == d->grfid && memcmp(c->md5sum, d->md5sum, sizeof(c->md5sum)) == 0) added = false; |
310 if (c->grfid == d->grfid && memcmp(c->md5sum, d->md5sum, sizeof(c->md5sum)) == 0) added = false; |
311 /* Because there can be multiple grfs with the same name, make sure we checked all grfs with the same name, |
311 /* Because there can be multiple grfs with the same name, make sure we checked all grfs with the same name, |
312 * before inserting the entry. So insert a new grf at the end of all grfs with the same name, instead of |
312 * before inserting the entry. So insert a new grf at the end of all grfs with the same name, instead of |
313 * just after the first with the same name. Avoids doubles in the list. */ |
313 * just after the first with the same name. Avoids doubles in the list. */ |
314 if (strcasecmp(c->name, d->name) <= 0) stop = true; |
314 if (strcasecmp(c->name, d->name) <= 0) { |
315 else if (stop) break; |
315 stop = true; |
|
316 } else if (stop) { |
|
317 break; |
|
318 } |
316 } |
319 } |
317 if (added) { |
320 if (added) { |
318 c->next = d; |
321 c->next = d; |
319 *pd = c; |
322 *pd = c; |
320 } |
323 } |