275 if (FillGRFDetails(c, false)) { |
275 if (FillGRFDetails(c, false)) { |
276 if (_all_grfs == NULL) { |
276 if (_all_grfs == NULL) { |
277 _all_grfs = c; |
277 _all_grfs = c; |
278 } else { |
278 } else { |
279 /* Insert file into list at a position determined by its |
279 /* Insert file into list at a position determined by its |
280 * name, so the list is sorted as we go along */ |
280 * name, so the list is sorted as we go along */ |
281 GRFConfig **pd, *d; |
281 GRFConfig **pd, *d; |
282 bool stop = false; |
282 bool stop = false; |
283 for (pd = &_all_grfs; (d = *pd) != NULL; pd = &d->next) { |
283 for (pd = &_all_grfs; (d = *pd) != NULL; pd = &d->next) { |
284 if (c->grfid == d->grfid && memcmp(c->md5sum, d->md5sum, sizeof(c->md5sum)) == 0) added = false; |
284 if (c->grfid == d->grfid && memcmp(c->md5sum, d->md5sum, sizeof(c->md5sum)) == 0) added = false; |
285 /* Because there can be multiple grfs with the same name, make sure we checked all grfs with the same name, |
285 /* Because there can be multiple grfs with the same name, make sure we checked all grfs with the same name, |
286 * before inserting the entry. So insert a new grf at the end of all grfs with the same name, instead of |
286 * before inserting the entry. So insert a new grf at the end of all grfs with the same name, instead of |
287 * just after the first with the same name. Avoids doubles in the list. */ |
287 * just after the first with the same name. Avoids doubles in the list. */ |
288 if (strcasecmp(c->name, d->name) <= 0) stop = true; |
288 if (strcasecmp(c->name, d->name) <= 0) { |
289 else if (stop) break; |
289 stop = true; |
|
290 } else if (stop) { |
|
291 break; |
|
292 } |
290 } |
293 } |
291 if (added) { |
294 if (added) { |
292 c->next = d; |
295 c->next = d; |
293 *pd = c; |
296 *pd = c; |
294 } |
297 } |