[Scummvm-cvs-logs] SF.net SVN: scummvm:[49418] scummvm/trunk/engines/sci

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Fri Jun 4 01:37:06 CEST 2010


Revision: 49418
          http://scummvm.svn.sourceforge.net/scummvm/?rev=49418&view=rev
Author:   lordhoto
Date:     2010-06-03 23:37:05 +0000 (Thu, 03 Jun 2010)

Log Message:
-----------
Replace two uses of ::qsort by Common::sort.

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/kfile.cpp
    scummvm/trunk/engines/sci/sound/music.cpp

Modified: scummvm/trunk/engines/sci/engine/kfile.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kfile.cpp	2010-06-03 23:07:53 UTC (rev 49417)
+++ scummvm/trunk/engines/sci/engine/kfile.cpp	2010-06-03 23:37:05 UTC (rev 49418)
@@ -245,13 +245,10 @@
 	debugC(2, kDebugLevelFile, "FGets'ed \"%s\"", dest);
 }
 
-static int _savegame_index_struct_compare(const void *a, const void *b) {
-	const SavegameDesc *A = (const SavegameDesc *)a;
-	const SavegameDesc *B = (const SavegameDesc *)b;
-
-	if (B->date != A->date)
-		return B->date - A->date;
-	return B->time - A->time;
+static bool _savegame_index_struct_compare(const SavegameDesc &l, const SavegameDesc &r) {
+	if (l.date != r.date)
+		return (l.date > r.date);
+	return (l.time > r.time);
 }
 
 void listSavegames(Common::Array<SavegameDesc> &saves) {
@@ -285,7 +282,7 @@
 	}
 
 	// Sort the list by creation date of the saves
-	qsort(saves.begin(), saves.size(), sizeof(SavegameDesc), _savegame_index_struct_compare);
+	Common::sort(saves.begin(), saves.end(), _savegame_index_struct_compare);
 }
 
 bool Console::cmdListSaves(int argc, const char **argv) {

Modified: scummvm/trunk/engines/sci/sound/music.cpp
===================================================================
--- scummvm/trunk/engines/sci/sound/music.cpp	2010-06-03 23:07:53 UTC (rev 49417)
+++ scummvm/trunk/engines/sci/sound/music.cpp	2010-06-03 23:37:05 UTC (rev 49418)
@@ -165,13 +165,13 @@
 	_pMidiDrv->setReverb(reverb);
 }
 
-static int f_compare(const void *arg1, const void *arg2) {
-	return ((const MusicEntry *)arg2)->priority - ((const MusicEntry *)arg1)->priority;
+static bool musicEntryCompare(const MusicEntry *l, const MusicEntry *r) {
+	return (l->priority > r->priority);
 }
 
 void SciMusic::sortPlayList() {
-	MusicEntry ** pData = _playList.begin();
-	qsort(pData, _playList.size(), sizeof(MusicEntry *), &f_compare);
+	// Sort the play list in descending priority order
+	Common::sort(_playList.begin(), _playList.end(), musicEntryCompare);
 }
 
 void SciMusic::findUsedChannels() {


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list