equal
deleted
inserted
replaced
404 |
404 |
405 /* Sort the linked list using quicksort. |
405 /* Sort the linked list using quicksort. |
406 * For that we first have to make an array, the qsort and |
406 * For that we first have to make an array, the qsort and |
407 * then remake the linked list. */ |
407 * then remake the linked list. */ |
408 GRFConfig **to_sort = MallocT<GRFConfig*>(num); |
408 GRFConfig **to_sort = MallocT<GRFConfig*>(num); |
409 if (to_sort == NULL) return; // No memory, then don't sort |
|
410 |
409 |
411 uint i = 0; |
410 uint i = 0; |
412 for (GRFConfig *p = _all_grfs; p != NULL; p = p->next, i++) { |
411 for (GRFConfig *p = _all_grfs; p != NULL; p = p->next, i++) { |
413 to_sort[i] = p; |
412 to_sort[i] = p; |
414 } |
413 } |
420 for (i = 1; i < num; i++) { |
419 for (i = 1; i < num; i++) { |
421 to_sort[i - 1]->next = to_sort[i]; |
420 to_sort[i - 1]->next = to_sort[i]; |
422 } |
421 } |
423 to_sort[num - 1]->next = NULL; |
422 to_sort[num - 1]->next = NULL; |
424 _all_grfs = to_sort[0]; |
423 _all_grfs = to_sort[0]; |
|
424 |
|
425 free(to_sort); |
425 } |
426 } |
426 |
427 |
427 |
428 |
428 /* Find a NewGRF in the scanned list, if md5sum is NULL, we don't care about it*/ |
429 /* Find a NewGRF in the scanned list, if md5sum is NULL, we don't care about it*/ |
429 const GRFConfig *FindGRFConfig(uint32 grfid, const uint8 *md5sum) |
430 const GRFConfig *FindGRFConfig(uint32 grfid, const uint8 *md5sum) |