diff --git a/stepmania/src/Song.cpp b/stepmania/src/Song.cpp index 32e2e50e41..1ba6d540d3 100644 --- a/stepmania/src/Song.cpp +++ b/stepmania/src/Song.cpp @@ -351,7 +351,7 @@ static CString RemoveInitialWhitespace( CString s ) } /* This is called within TidyUpData, before autogen notes are added. */ -static void DeleteDuplicateSteps( Song *song, vector &vSteps ) +void Song::DeleteDuplicateSteps( vector &vSteps ) { /* vSteps have the same StepsType and Difficulty. Delete them if they have the * same m_sDescription, m_iMeter and SMNoteData. */ @@ -379,16 +379,16 @@ static void DeleteDuplicateSteps( Song *song, vector &vSteps ) continue; LOG->Trace("Removed %p duplicate steps in song \"%s\" with description \"%s\" and meter \"%i\"", - s2, song->GetSongDir().c_str(), s1->GetDescription().c_str(), s1->GetMeter() ); + s2, this->GetSongDir().c_str(), s1->GetDescription().c_str(), s1->GetMeter() ); /* Don't use RemoveSteps; autogen notes havn't yet been created and it'll * create them. */ - for( int k=song->m_vpSteps.size()-1; k>=0; k-- ) + for( int k=this->m_vpSteps.size()-1; k>=0; k-- ) { - if( song->m_vpSteps[k] == s2 ) + if( this->m_vpSteps[k] == s2 ) { - delete song->m_vpSteps[k]; - song->m_vpSteps.erase( song->m_vpSteps.begin()+k ); + delete this->m_vpSteps[k]; + this->m_vpSteps.erase( this->m_vpSteps.begin()+k ); break; } } @@ -416,7 +416,7 @@ void Song::AdjustDuplicateSteps() /* Delete steps that are completely identical. This happened due to a * bug in an earlier version. */ - DeleteDuplicateSteps( this, vSteps ); + DeleteDuplicateSteps( vSteps ); CHECKPOINT; StepsUtil::SortNotesArrayByDifficulty( vSteps ); @@ -871,11 +871,11 @@ void Song::GetSteps( vector& arrayAddTo, StepsType st, Difficulty dc, in if( st != STEPS_TYPE_LIGHTS_CABINET && !PREFSMAN->m_bAutogenSteps ) bIncludeAutoGen = false; + if( !Max ) + return; + for( unsigned i=0; im_StepsType != st ) @@ -886,13 +886,17 @@ void Song::GetSteps( vector& arrayAddTo, StepsType st, Difficulty dc, in continue; if( iMeterHigh != -1 && iMeterHigh < pSteps->GetMeter() ) continue; - if( sDescription != "" && sDescription != pSteps->GetDescription() ) + if( sDescription.size() && sDescription != pSteps->GetDescription() ) continue; if( !bIncludeAutoGen && pSteps->IsAutogen() ) continue; if( Max != -1 ) + { --Max; + if( !Max ) + break; + } arrayAddTo.push_back( pSteps ); } diff --git a/stepmania/src/song.h b/stepmania/src/song.h index 5b2f47b818..c28d95b9dc 100644 --- a/stepmania/src/song.h +++ b/stepmania/src/song.h @@ -200,6 +200,7 @@ public: private: void AdjustDuplicateSteps(); // part of TidyUpData + void DeleteDuplicateSteps( vector &vSteps ); CString GetUniqueSongDescription( StepsType st ); };