From 692a52673e68cea51cf5b626f8317ee627c5cec8 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Mon, 31 Oct 2005 00:54:52 +0000 Subject: [PATCH] Too-big commit in one chunk makes code review impossible--please break things apart better. Trying to figure out what just happened ... --- stepmania/src/Course.cpp | 51 ++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/stepmania/src/Course.cpp b/stepmania/src/Course.cpp index a22c5ddb12..ba5dec6cd2 100644 --- a/stepmania/src/Course.cpp +++ b/stepmania/src/Course.cpp @@ -473,6 +473,33 @@ bool Course::GetTrailSorted( StepsType st, CourseDifficulty cd, Trail &trail ) c return true; } +// TODO: Move Course initialization after PROFILEMAN is created +static void CourseSortSongs( SongSort sort, vector &vpPossibleSongs, RandomGen &rnd ) +{ + switch( sort ) + { + default: + ASSERT(0); + case SongSort_Randomize: + random_shuffle( vpPossibleSongs.begin(), vpPossibleSongs.end(), rnd ); + break; + case SongSort_MostPlays: + if( PROFILEMAN ) + SongUtil::SortSongPointerArrayByNumPlays( vpPossibleSongs, PROFILEMAN->GetMachineProfile(), true ); // descending + break; + case SongSort_FewestPlays: + if( PROFILEMAN ) + SongUtil::SortSongPointerArrayByNumPlays( vpPossibleSongs, PROFILEMAN->GetMachineProfile(), false ); // ascending + break; + case SongSort_TopGrades: + SongUtil::SortSongPointerArrayByGrades( vpPossibleSongs, true ); // descending + break; + case SongSort_LowestGrades: + SongUtil::SortSongPointerArrayByGrades( vpPossibleSongs, false ); // ascending + break; + } +} + bool Course::GetTrailUnsorted( StepsType st, CourseDifficulty cd, Trail &trail ) const { trail.Init(); @@ -580,29 +607,7 @@ bool Course::GetTrailUnsorted( StepsType st, CourseDifficulty cd, Trail &trail ) if( vpPossibleSongs.empty() ) continue; - // TODO: Move Course initialization after PROFILEMAN is created - switch( e->songSort ) - { - default: - ASSERT(0); - case SongSort_Randomize: - random_shuffle( vpPossibleSongs.begin(), vpPossibleSongs.end(), rnd ); - break; - case SongSort_MostPlays: - if( PROFILEMAN ) - SongUtil::SortSongPointerArrayByNumPlays( vpPossibleSongs, PROFILEMAN->GetMachineProfile(), true ); // descending - break; - case SongSort_FewestPlays: - if( PROFILEMAN ) - SongUtil::SortSongPointerArrayByNumPlays( vpPossibleSongs, PROFILEMAN->GetMachineProfile(), false ); // ascending - break; - case SongSort_TopGrades: - SongUtil::SortSongPointerArrayByGrades( vpPossibleSongs, true ); // descending - break; - case SongSort_LowestGrades: - SongUtil::SortSongPointerArrayByGrades( vpPossibleSongs, false ); // ascending - break; - } + CourseSortSongs( e->songSort, vpPossibleSongs, rnd ); if( e->iChooseIndex < int(vpPossibleSongs.size()) ) {