summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-09-13 17:36:50 +0000
committerrubidium <rubidium@openttd.org>2009-09-13 17:36:50 +0000
commit53cc397607222c9c1a8b56c545c5050dbc306b41 (patch)
tree7636a3a59c47081ec7e47d02f23c8a6b04e133f9
parentba97964af831d902a241cc681bae90b051243568 (diff)
downloadopenttd-53cc397607222c9c1a8b56c545c5050dbc306b41.tar.xz
(svn r17524) -Codechange: use QSortT instead of qsort for sorting NewGRFs
-rw-r--r--src/newgrf_config.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp
index 6894b65be..07c2e432b 100644
--- a/src/newgrf_config.cpp
+++ b/src/newgrf_config.cpp
@@ -10,6 +10,7 @@
/** @file newgrf_config.cpp Finding NewGRFs and configuring them. */
#include "stdafx.h"
+#include "core/sort_func.hpp"
#include "debug.h"
#include "3rdparty/md5/md5.h"
#include "newgrf.h"
@@ -349,10 +350,10 @@ bool GRFFileScanner::AddFile(const char *filename, size_t basepath_length)
* @param p2 the second GRFConfig *
* @return the same strcmp would return for the name of the NewGRF.
*/
-static int CDECL GRFSorter(const void *p1, const void *p2)
+static int CDECL GRFSorter(GRFConfig * const *p1, GRFConfig * const *p2)
{
- const GRFConfig *c1 = *(const GRFConfig **)p1;
- const GRFConfig *c2 = *(const GRFConfig **)p2;
+ const GRFConfig *c1 = *p1;
+ const GRFConfig *c2 = *p2;
return strcasecmp(c1->name != NULL ? c1->name : c1->filename,
c2->name != NULL ? c2->name : c2->filename);
@@ -370,7 +371,7 @@ void ScanNewGRFFiles()
if (num == 0 || _all_grfs == NULL) return;
/* Sort the linked list using quicksort.
- * For that we first have to make an array, the qsort and
+ * For that we first have to make an array, then sort and
* then remake the linked list. */
GRFConfig **to_sort = MallocT<GRFConfig*>(num);
@@ -381,7 +382,7 @@ void ScanNewGRFFiles()
/* Number of files is not necessarily right */
num = i;
- qsort(to_sort, num, sizeof(GRFConfig*), GRFSorter);
+ QSortT(to_sort, num, &GRFSorter);
for (i = 1; i < num; i++) {
to_sort[i - 1]->next = to_sort[i];