diff --git a/stepmania/src/MusicBannerWheel.cpp b/stepmania/src/MusicBannerWheel.cpp index aa1a2a9a10..3317101029 100644 --- a/stepmania/src/MusicBannerWheel.cpp +++ b/stepmania/src/MusicBannerWheel.cpp @@ -64,14 +64,12 @@ MusicBannerWheel::MusicBannerWheel() if ( !PREFSMAN->m_bAutogenSteps ) { LOG->Trace( "Removing all autogen songs from wheel." ); - vector songSteps; vector pNotAutogen; for ( unsigned i = 0; i < arraySongs.size(); i++) { //ONLY get non-autogenned steps - songSteps.clear(); - arraySongs[i]->GetSteps( songSteps, GAMESTATE->GetCurrentStyle()->m_StepsType, DIFFICULTY_INVALID, -1, -1, "", false); - if ( !songSteps.empty() ) + Steps* pSteps = arraySongs[i]->GetStepsByDifficulty( GAMESTATE->GetCurrentStyle()->m_StepsType, DIFFICULTY_INVALID, false ); + if ( pSteps != NULL ) pNotAutogen.push_back( arraySongs[i] ); } arraySongs.clear(); diff --git a/stepmania/src/MusicWheel.cpp b/stepmania/src/MusicWheel.cpp index ecea6c9d8a..53851ff205 100644 --- a/stepmania/src/MusicWheel.cpp +++ b/stepmania/src/MusicWheel.cpp @@ -381,10 +381,8 @@ void MusicWheel::GetSongList(vector &arraySongs, SortOrder so, CString sP if( so!=SORT_ROULETTE && UNLOCKMAN->SongIsLocked(pSong) ) continue; - vector arraySteps; - pSong->GetSteps( arraySteps, GAMESTATE->GetCurrentStyle()->m_StepsType, DIFFICULTY_INVALID, -1, -1, "", 1 ); - - if( !arraySteps.empty() ) + // If the song has at least one steps, add it. + if( pSong->HasStepsType(GAMESTATE->GetCurrentStyle()->m_StepsType) ) arraySongs.push_back( pSong ); } diff --git a/stepmania/src/NotesLoaderBMS.cpp b/stepmania/src/NotesLoaderBMS.cpp index 6347f10adc..13af437e3e 100644 --- a/stepmania/src/NotesLoaderBMS.cpp +++ b/stepmania/src/NotesLoaderBMS.cpp @@ -983,13 +983,12 @@ void BMSLoader::SlideDuplicateDifficulties( Song &p ) * difficulties slid upwards due to (for example) having two beginner steps. * We do a second pass in Song::TidyUpData to eliminate any remaining duplicates * after this. */ - for( int i=0; i vSteps; p.GetSteps( vSteps, st, dc ); diff --git a/stepmania/src/Song.cpp b/stepmania/src/Song.cpp index 979327d3b5..3407530ffa 100644 --- a/stepmania/src/Song.cpp +++ b/stepmania/src/Song.cpp @@ -372,13 +372,12 @@ void Song::DeleteDuplicateSteps( vector &vSteps ) * on this; see BMSLoader::SlideDuplicateDifficulties.) */ void Song::AdjustDuplicateSteps() { - for( int i=0; i vSteps; this->GetSteps( vSteps, st, dc ); @@ -826,9 +825,18 @@ void Song::ReCalculateRadarValuesAndLastBeat() } } -void Song::GetSteps( vector& arrayAddTo, StepsType st, Difficulty dc, int iMeterLow, int iMeterHigh, const CString &sDescription, bool bIncludeAutoGen, int Max ) const +void Song::GetSteps( + vector& arrayAddTo, + StepsType st, + Difficulty dc, + int iMeterLow, + int iMeterHigh, + const CString &sDescription, + bool bIncludeAutoGen, + int iMaxToGet + ) const { - if( !Max ) + if( !iMaxToGet ) return; const vector& vpSteps = GetAllSteps(st); @@ -849,15 +857,32 @@ void Song::GetSteps( vector& arrayAddTo, StepsType st, Difficulty dc, in arrayAddTo.push_back( pSteps ); - if( Max != -1 ) + if( iMaxToGet != -1 ) { - --Max; - if( !Max ) + --iMaxToGet; + if( !iMaxToGet ) break; } } } +Steps* Song::GetSteps( + StepsType st, + Difficulty dc, + int iMeterLow, + int iMeterHigh, + const CString &sDescription, + bool bIncludeAutoGen + ) const +{ + vector vpSteps; + GetSteps( vpSteps, st, dc, iMeterLow, iMeterHigh, sDescription, bIncludeAutoGen, 1 ); // get max 1 + if( vpSteps.empty() ) + return NULL; + else + return vpSteps[0]; +} + Steps* Song::GetStepsByDifficulty( StepsType st, Difficulty dc, bool bIncludeAutoGen ) const { const vector& vpSteps = GetAllSteps(st); @@ -941,16 +966,12 @@ bool Song::SongCompleteForStyle( const Style *st ) const bool Song::HasStepsType( StepsType st ) const { - vector add; - GetSteps( add, st, DIFFICULTY_INVALID, -1, -1, "", true, 1 ); - return !add.empty(); + return GetSteps( st ) != NULL; } bool Song::HasStepsTypeAndDifficulty( StepsType st, Difficulty dc ) const { - vector add; - GetSteps( add, st, dc, -1, -1, "", true, 1 ); - return !add.empty(); + return GetSteps( st, dc ) != NULL; } void Song::Save() diff --git a/stepmania/src/SongManager.cpp b/stepmania/src/SongManager.cpp index 7324f92901..8a4fd68318 100644 --- a/stepmania/src/SongManager.cpp +++ b/stepmania/src/SongManager.cpp @@ -1206,7 +1206,7 @@ void SongManager::LoadAllFromProfiles() continue; } - SMLoader::LoadEdit( fn, (ProfileSlot) s ); + SMLoader::LoadEdit( fn, s ); } } diff --git a/stepmania/src/StepsUtil.cpp b/stepmania/src/StepsUtil.cpp index c2aa95e5ed..df1b5cccff 100644 --- a/stepmania/src/StepsUtil.cpp +++ b/stepmania/src/StepsUtil.cpp @@ -154,16 +154,17 @@ Steps *StepsID::ToSteps( const Song *p, bool bAllowNull, bool bUseCache ) const return it->second; } - vector vNotes; - if( dc == DIFFICULTY_EDIT ) - p->GetSteps( vNotes, st, dc, -1, -1, sDescription, true, 1 ); - else - p->GetSteps( vNotes, st, dc, -1, -1, "", true, 1 ); - Steps *ret = NULL; - if( !vNotes.empty() ) - ret = vNotes[0]; - else if( !bAllowNull ) + if( dc == DIFFICULTY_EDIT ) + { + ret = p->GetSteps( st, dc, -1, -1, sDescription, true ); + } + else + { + ret = p->GetSteps( st, dc, -1, -1, "", true ); + } + + if( !bAllowNull ) RageException::Throw( "%i, %i, \"%s\"", st, dc, sDescription.c_str() ); if( bUseCache ) diff --git a/stepmania/src/song.h b/stepmania/src/song.h index 11c863ebdb..3761ab8117 100644 --- a/stepmania/src/song.h +++ b/stepmania/src/song.h @@ -173,7 +173,24 @@ public: bool HasStepsType( StepsType st ) const; bool HasStepsTypeAndDifficulty( StepsType st, Difficulty dc ) const; const vector& GetAllSteps( StepsType st=STEPS_TYPE_INVALID ) const { return st==STEPS_TYPE_INVALID? m_vpSteps:m_vpStepsByType[st]; } - void GetSteps( vector& arrayAddTo, StepsType st = STEPS_TYPE_INVALID, Difficulty dc = DIFFICULTY_INVALID, int iMeterLow = -1, int iMeterHigh = -1, const CString &sDescription = "", bool bIncludeAutoGen = true, int Max = -1 ) const; + void GetSteps( + vector& arrayAddTo, + StepsType st = STEPS_TYPE_INVALID, + Difficulty dc = DIFFICULTY_INVALID, + int iMeterLow = -1, + int iMeterHigh = -1, + const CString &sDescription = "", + bool bIncludeAutoGen = true, + int iMaxToGet = -1 + ) const; + Steps* GetSteps( + StepsType st = STEPS_TYPE_INVALID, + Difficulty dc = DIFFICULTY_INVALID, + int iMeterLow = -1, + int iMeterHigh = -1, + const CString &sDescription = "", + bool bIncludeAutoGen = true + ) const; Steps* GetStepsByDifficulty( StepsType st, Difficulty dc, bool bIncludeAutoGen = true ) const; Steps* GetStepsByMeter( StepsType st, int iMeterLow, int iMeterHigh ) const; Steps* GetStepsByDescription( StepsType st, CString sDescription ) const;