diff --git a/stepmania/src/BPMDisplay.cpp b/stepmania/src/BPMDisplay.cpp index e2d86ba3b1..582a62bca5 100644 --- a/stepmania/src/BPMDisplay.cpp +++ b/stepmania/src/BPMDisplay.cpp @@ -178,23 +178,22 @@ void BPMDisplay::SetBPM( const Song* pSong ) void BPMDisplay::SetBPM( const Course* pCourse ) { ASSERT( pCourse ); - vector vSongs; - vector vNotes; - vector vsModifiers; - pCourse->GetStageInfo( vSongs, vNotes, vsModifiers, GAMESTATE->GetCurrentStyleDef()->m_NotesType ); - ASSERT( vSongs.size() ); + vector ci; + pCourse->GetCourseInfo( GAMESTATE->GetCurrentStyleDef()->m_NotesType, ci ); + + ASSERT( ci.size() ); vector BPMS; - for( unsigned i = 0; i < vSongs.size(); ++i ) + for( unsigned i = 0; i < ci.size(); ++i ) { - if( pCourse->IsMysterySong(i) ) + if( ci[i].Random ) { BPMS.push_back( -1 ); continue; } - Song *pSong = vSongs[i]; + Song *pSong = ci[i].Song; ASSERT( pSong ); switch( pSong->m_DisplayBPMType ) { diff --git a/stepmania/src/Course.cpp b/stepmania/src/Course.cpp index ff0505dac9..f456c9ba5b 100644 --- a/stepmania/src/Course.cpp +++ b/stepmania/src/Course.cpp @@ -370,82 +370,98 @@ void Course::AutogenNonstopFromGroup( CString sGroupName, vector &apSongs */ bool Course::HasDifficult( NotesType nt ) const { - if( ContainsAnyMysterySongs() ) - { - for( unsigned i=0; im_bDifficultCourses; - vector vSongs, vHardSongs; - vector vNotes, vHardNotes; - vector vsIgnore; + vector Normal, Hard; GAMESTATE->m_bDifficultCourses = false; - GetStageInfo( vSongs, vNotes, vsIgnore, nt ); + GetCourseInfo( nt, Normal ); GAMESTATE->m_bDifficultCourses = true; - GetStageInfo( vHardSongs, vHardNotes, vsIgnore, nt ); + GetCourseInfo( nt, Hard ); GAMESTATE->m_bDifficultCourses = OldDifficulty; - if( vSongs.size() != vHardSongs.size() ) + if( Normal.size() != Hard.size() ) return true; /* it changed */ - for( unsigned i=0; i vSongs; - vector vNotes; - vector vsModifiers; - GetStageInfo( vSongs, vNotes, vsModifiers, nt); - - return vNotes.size() > 0; + vector ci; + GetCourseInfo( nt, ci ); + return ci.size() > 0; } -void Course::GetStageInfo( - vector& vSongsOut, - vector& vNotesOut, - vector& vsModifiersOut, +bool Course::GetFirstStageInfo( + Song*& pSongOut, + Notes*& pNotesOut, + CString& sModifiersOut, NotesType nt ) const +{ + vector ci; + GetCourseInfo( nt, ci ); + + if( ci.empty() ) + return false; + + pSongOut = ci[0].Song; + pNotesOut = ci[0].Notes; + sModifiersOut = ci[0].Modifiers; + return true; +} + +void Course::GetCourseInfo( NotesType nt, vector &ci ) const { vector entries = m_entries; if( m_bRandomize ) random_shuffle( entries.begin(), entries.end() ); - vector vSongsByMostPlayed; + 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 ); + } vector AllSongsShuffled = SONGMAN->GetAllSongs(); random_shuffle( AllSongsShuffled.begin(), AllSongsShuffled.end() ); int CurSong = 0; /* Current offset into AllSongsShuffled */ + ci.clear(); + 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, PREFSMAN->m_bAutogenMissingTypes) || - !pSong->GetNotes(nt, DIFFICULTY_HARD, PREFSMAN->m_bAutogenMissingTypes) ) - vSongsByMostPlayed.erase( vSongsByMostPlayed.begin()+j ); - } - } - if( e.players_index >= (int)vSongsByMostPlayed.size() ) break; @@ -567,36 +563,13 @@ void Course::GetStageInfo( } } - vSongsOut.push_back( pSong ); - vNotesOut.push_back( pNotes ); - vsModifiersOut.push_back( e.modifiers ); + Info cinfo; + cinfo.Song = pSong; + cinfo.Notes = pNotes; + cinfo.Modifiers = e.modifiers; + cinfo.Random = ( e.type == Entry::random || e.type == Entry::random_within_group ); + ci.push_back( cinfo ); } - - -} - -bool Course::GetFirstStageInfo( - Song*& pSongOut, - Notes*& pNotesOut, - CString& sModifiersOut, - NotesType nt ) const -{ - vector vSongs; - vector vNotes; - vector vsModifiers; - - GetStageInfo( - vSongs, - vNotes, - vsModifiers, - nt ); - if( vSongs.empty() ) - return false; - - pSongOut = vSongs[0]; - pNotesOut = vNotes[0]; - sModifiersOut = vsModifiers[0]; - return true; } RageColor Course::GetColor() const @@ -610,18 +583,6 @@ RageColor Course::GetColor() const return RageColor(0,1,0,1); // green } -bool Course::IsMysterySong( int stage ) const -{ - switch( m_entries[stage].type ) - { - case Entry::fixed: return false; - case Entry::random: return true; - case Entry::random_within_group: return true; - case Entry::best: return false; - case Entry::worst: return false; - default: ASSERT(0); return true; - } -} Difficulty Course::GetDifficulty( int stage ) const { @@ -646,31 +607,18 @@ void Course::GetMeterRange( int stage, int& iMeterLowOut, int& iMeterHighOut ) c } } -bool Course::ContainsAnyMysterySongs() const -{ - for( unsigned i=0; i vSongsOut; - vector vNotesOut; - vector vsModifiersOut; - GetStageInfo( - vSongsOut, - vNotesOut, - vsModifiersOut, - NOTES_TYPE_DANCE_SINGLE ); // doesn't matter + vector ci; + GetCourseInfo( NOTES_TYPE_DANCE_SINGLE, ci ); fSecondsOut = 0; - for( unsigned i=0; im_fMusicLengthSeconds; + for( unsigned i=0; im_fMusicLengthSeconds; + } return true; } diff --git a/stepmania/src/Course.h b/stepmania/src/Course.h index 73177b1b88..5dfd26b2b3 100644 --- a/stepmania/src/Course.h +++ b/stepmania/src/Course.h @@ -59,10 +59,23 @@ public: bool m_bDifficult; // only make something difficult once int m_iLives; // -1 means use bar life meter + struct Info + { + Info(): Song(NULL), Notes(NULL), Random(false) { } + Song* Song; + Notes* Notes; + CString Modifiers; + bool Random; + /* Corresponding entry in m_entries: */ + int CourseIndex; + }; + // Dereferences course_entries and returns only the playable Songs and Notes + void GetCourseInfo( NotesType nt, vector &ci ) const; + int GetEstimatedNumStages() const { return m_entries.size(); } bool HasDifficult( NotesType nt ) const; bool IsPlayableIn( NotesType nt ) const; - void GetStageInfo( // Derefrences course_entries and returns only the playable Songs and Notes + void GetStageInfo( vector& vSongsOut, vector& vNotesOut, vector& vsModifiersOut, @@ -73,10 +86,8 @@ public: CString& sModifiersOut, NotesType nt ) const; RageColor GetColor() const; - bool IsMysterySong( int stage ) const; Difficulty GetDifficulty( int stage ) const; void GetMeterRange( int stage, int& iMeterLowOut, int& iMeterHighOut ) const; - bool ContainsAnyMysterySongs() const; bool GetTotalSeconds( float& fSecondsOut ) const; bool IsNonstop() const { return !m_bRepeat && m_iLives <= 0; } // use bar life meter diff --git a/stepmania/src/CourseContentsList.cpp b/stepmania/src/CourseContentsList.cpp index 174f76d85f..ed7fb7c6f1 100644 --- a/stepmania/src/CourseContentsList.cpp +++ b/stepmania/src/CourseContentsList.cpp @@ -54,32 +54,27 @@ void CourseContentsList::SetFromCourse( Course* pCourse ) m_iNumContents = 0; - vector vSongs; - vector vNotes; - vector vsModifiers; - pCourse->GetStageInfo( vSongs, vNotes, vsModifiers, GAMESTATE->GetCurrentStyleDef()->m_NotesType ); + vector ci; + pCourse->GetCourseInfo( GAMESTATE->GetCurrentStyleDef()->m_NotesType, ci ); - for( int i=0; iIsMysterySong(i) ) + if( ci[i].Random ) { Difficulty dc = pCourse->GetDifficulty(i); int iMeterLow, iMeterHigh; pCourse->GetMeterRange(i, iMeterLow, iMeterHigh); if( dc == DIFFICULTY_INVALID ) - display.LoadFromMeterRange( m_iNumContents+1, iMeterLow, iMeterHigh, vsModifiers[i] ); + display.LoadFromMeterRange( m_iNumContents+1, iMeterLow, iMeterHigh, ci[i].Modifiers ); else - display.LoadFromDifficulty( m_iNumContents+1, dc, vsModifiers[i] ); + display.LoadFromDifficulty( m_iNumContents+1, dc, ci[i].Modifiers ); } else { - Song* pSong = vSongs[i]; - Notes* pNotes = vNotes[i]; - CString sModifiers = vsModifiers[i]; - display.LoadFromSongAndNotes( m_iNumContents+1, pSong, pNotes, vsModifiers[i] ); + display.LoadFromSongAndNotes( m_iNumContents+1, ci[i].Song, ci[i].Notes, ci[i].Modifiers ); } m_iNumContents ++; diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index fc78a0abde..52be5b34e8 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -145,12 +145,17 @@ ScreenGameplay::ScreenGameplay( bool bDemonstration ) : Screen("ScreenGameplay") // if( GAMESTATE->IsCourseMode() ) { - Course* pCourse = GAMESTATE->m_pCurCourse; - pCourse->GetStageInfo( m_apSongsQueue, m_apNotesQueue[0], m_asModifiersQueue[0], GAMESTATE->GetCurrentStyleDef()->m_NotesType ); - for( int p=1; p ci; + GAMESTATE->m_pCurCourse->GetCourseInfo( GAMESTATE->GetCurrentStyleDef()->m_NotesType, ci ); + for( int p=0; p