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 )