From 763791eb717fefd3997ce4f825a2ddba07a7012f Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 22 Feb 2003 22:04:44 +0000 Subject: [PATCH] only set up the popularity contest if we actually need it; it's still a little slow --- stepmania/src/Course.cpp | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/stepmania/src/Course.cpp b/stepmania/src/Course.cpp index 4906a7501f..5c69400120 100644 --- a/stepmania/src/Course.cpp +++ b/stepmania/src/Course.cpp @@ -305,22 +305,7 @@ void Course::GetStageInfo( if( m_bRandomize ) random_shuffle( entries.begin(), entries.end() ); - - // Sorting is slow, so do this outside the for loop. - vector vSongsByMostPlayed = SONGMAN->GetAllSongs(); - SortSongPointerArrayByMostPlayed( vSongsByMostPlayed ); - - // 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) || - !pSong->GetNotes(nt, DIFFICULTY_HARD) ) - vSongsByMostPlayed.erase( vSongsByMostPlayed.begin()+j ); - } - + vector vSongsByMostPlayed; for( unsigned i=0; iGetAllSongs(); + SortSongPointerArrayByMostPlayed( vSongsByMostPlayed ); + + // 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) || + !pSong->GetNotes(nt, DIFFICULTY_HARD) ) + vSongsByMostPlayed.erase( vSongsByMostPlayed.begin()+j ); + } + } + if( e.players_index >= (int)vSongsByMostPlayed.size() ) break;