diff options
-rw-r--r-- | engines/sci/engine/kfile.cpp | 13 | ||||
-rw-r--r-- | engines/sci/sound/music.cpp | 8 |
2 files changed, 9 insertions, 12 deletions
diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp index ba8714366f..18b1e02eba 100644 --- a/engines/sci/engine/kfile.cpp +++ b/engines/sci/engine/kfile.cpp @@ -245,13 +245,10 @@ static void fgets_wrapper(EngineState *s, char *dest, int maxsize, int handle) { 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 @@ void listSavegames(Common::Array<SavegameDesc> &saves) { } // 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) { diff --git a/engines/sci/sound/music.cpp b/engines/sci/sound/music.cpp index e1300373e7..f0356be709 100644 --- a/engines/sci/sound/music.cpp +++ b/engines/sci/sound/music.cpp @@ -165,13 +165,13 @@ void SciMusic::setReverb(byte reverb) { _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() { |