diff --git a/stepmania/src/Course.cpp b/stepmania/src/Course.cpp index 890963a6d9..c5072b0568 100644 --- a/stepmania/src/Course.cpp +++ b/stepmania/src/Course.cpp @@ -454,6 +454,23 @@ bool Course::IsPlayableIn( NotesType nt ) const } +static vector GetFilteredBestSongs( NotesType nt ) +{ + vector vSongsByMostPlayed = SONGMAN->GetBestSongs(); + // filter out songs that don't have both medium and hard steps and long ver sons + for( int j=vSongsByMostPlayed.size()-1; j>=0; j-- ) + { + Song* pSong = vSongsByMostPlayed[j]; + if( pSong->m_fMusicLengthSeconds > PREFSMAN->m_fLongVerSongSeconds || + pSong->m_fMusicLengthSeconds > PREFSMAN->m_fMarathonVerSongSeconds || + !pSong->GetNotes(nt, DIFFICULTY_MEDIUM, PREFSMAN->m_bAutogenMissingTypes) || + !pSong->GetNotes(nt, DIFFICULTY_HARD, PREFSMAN->m_bAutogenMissingTypes) ) + vSongsByMostPlayed.erase( vSongsByMostPlayed.begin()+j ); + } + + return vSongsByMostPlayed; +} + void Course::GetCourseInfo( NotesType nt, vector &ci, int Difficult ) const { vector entries = m_entries; @@ -469,18 +486,9 @@ void Course::GetCourseInfo( NotesType nt, vector &ci, int Difficul random_shuffle( entries.begin(), entries.end(), rnd ); } - vector vSongsByMostPlayed = SONGMAN->GetBestSongs(); - // filter out songs that don't have both medium and hard steps and long ver sons - for( int j=vSongsByMostPlayed.size()-1; j>=0; j-- ) - { - Song* pSong = vSongsByMostPlayed[j]; - if( pSong->m_fMusicLengthSeconds > PREFSMAN->m_fLongVerSongSeconds || - pSong->m_fMusicLengthSeconds > PREFSMAN->m_fMarathonVerSongSeconds || - !pSong->GetNotes(nt, DIFFICULTY_MEDIUM, PREFSMAN->m_bAutogenMissingTypes) || - !pSong->GetNotes(nt, DIFFICULTY_HARD, PREFSMAN->m_bAutogenMissingTypes) ) - vSongsByMostPlayed.erase( vSongsByMostPlayed.begin()+j ); - } - + /* This can take some time, so don't fill it out unless we need it. */ + bool bMostPlayedSet = false; + vector vSongsByMostPlayed; vector AllSongsShuffled = SONGMAN->GetAllSongs(); random_shuffle( AllSongsShuffled.begin(), AllSongsShuffled.end(), rnd ); @@ -544,6 +552,12 @@ void Course::GetCourseInfo( NotesType nt, vector &ci, int Difficul case Entry::best: case Entry::worst: { + if( !bMostPlayedSet ) + { + bMostPlayedSet = true; + vSongsByMostPlayed = GetFilteredBestSongs( nt ); + } + if( e.players_index >= (int)vSongsByMostPlayed.size() ) break;