(svn r13522) -Codechange: Replace the qsort of the highscore with one of the internal sorters
authorskidd13
Sun, 15 Jun 2008 16:11:25 +0000
changeset 10968 8f9c4121e43b
parent 10967 fb9a80b89ea4
child 10969 e5fd50b81dc7
(svn r13522) -Codechange: Replace the qsort of the highscore with one of the internal sorters
src/players.cpp
--- a/src/players.cpp	Sun Jun 15 15:48:33 2008 +0000
+++ b/src/players.cpp	Sun Jun 15 16:11:25 2008 +0000
@@ -28,6 +28,7 @@
 #include "vehicle_func.h"
 #include "sound_func.h"
 #include "core/alloc_func.hpp"
+#include "core/sort_func.hpp"
 #include "autoreplace_func.h"
 #include "autoreplace_gui.h"
 #include "string_func.h"
@@ -1021,12 +1022,9 @@
 }
 
 /** Sort all players given their performance */
-static int CDECL HighScoreSorter(const void *a, const void *b)
+static int CDECL HighScoreSorter(const Player* const *a, const Player* const *b)
 {
-	const Player *pa = *(const Player* const*)a;
-	const Player *pb = *(const Player* const*)b;
-
-	return pb->old_economy[0].performance_history - pa->old_economy[0].performance_history;
+	return (*b)->old_economy[0].performance_history - (*a)->old_economy[0].performance_history;
 }
 
 /* Save the highscores in a network game when it has ended */
@@ -1040,7 +1038,8 @@
 
 	/* Sort all active players with the highest score first */
 	FOR_ALL_PLAYERS(p) if (p->is_active) pl[count++] = p;
-	qsort((Player*)pl, count, sizeof(pl[0]), HighScoreSorter);
+
+	GSortT(pl, count, &HighScoreSorter);
 
 	{
 		uint i;