From d6ca8b3777a5fde7bf281f4e4e25b35808606a4b Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Mon, 31 Oct 2005 01:19:54 +0000 Subject: [PATCH] break out GetSongsValidForRandom --- stepmania/src/Course.cpp | 45 +++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/stepmania/src/Course.cpp b/stepmania/src/Course.cpp index 2c8716b8e8..e01ef01b9e 100644 --- a/stepmania/src/Course.cpp +++ b/stepmania/src/Course.cpp @@ -500,6 +500,29 @@ static void CourseSortSongs( SongSort sort, vector &vpPossibleSongs, Rand } } +static void GetSongsValidForRandom( vector &vpSongsOut ) +{ + const vector &vpAllSongs = SONGMAN->GetAllSongs(); + + FOREACH_CONST( Song*, vpAllSongs, song ) + { + // Ignore locked songs when choosing randomly + // TODO: Move Course initialization after UNLOCKMAN is created + if( UNLOCKMAN && UNLOCKMAN->SongIsLocked(*song) ) + continue; + + // Ignore boring tutorial songs + if( (*song)->IsTutorial() ) + continue; + + // Don't allow long songs + if( SONGMAN->GetNumStagesForSong(*song) > 1 ) + continue; + + vpSongsOut.push_back( *song ); + } +} + bool Course::GetTrailUnsorted( StepsType st, CourseDifficulty cd, Trail &trail ) const { trail.Init(); @@ -540,27 +563,7 @@ bool Course::GetTrailUnsorted( StepsType st, CourseDifficulty cd, Trail &trail ) bool bCourseDifficultyIsSignificant = (cd == DIFFICULTY_MEDIUM); vector vpAllPossibleSongs; - { - const vector &vpAllSongs = SONGMAN->GetAllSongs(); - - FOREACH_CONST( Song*, vpAllSongs, song ) - { - // Ignore locked songs when choosing randomly - // TODO: Move Course initialization after UNLOCKMAN is created - if( UNLOCKMAN && UNLOCKMAN->SongIsLocked(*song) ) - continue; - - // Ignore boring tutorial songs - if( (*song)->IsTutorial() ) - continue; - - // Don't allow long songs - if( SONGMAN->GetNumStagesForSong(*song) > 1 ) - continue; - - vpAllPossibleSongs.push_back( *song ); - } - } + GetSongsValidForRandom( vpAllPossibleSongs ); // Resolve each entry to a Song and Steps. FOREACH_CONST( CourseEntry, entries, e )