From be307e76bd09ccc5a933b0cb9ca4f5f64355fb9b Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 21 Dec 2003 02:21:30 +0000 Subject: [PATCH] optimize --- stepmania/src/Song.cpp | 13 ++++++++++--- stepmania/src/song.h | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/stepmania/src/Song.cpp b/stepmania/src/Song.cpp index b1f4232810..a781ba41fe 100644 --- a/stepmania/src/Song.cpp +++ b/stepmania/src/Song.cpp @@ -818,10 +818,13 @@ void Song::ReCalculateRadarValuesAndLastBeat() } } -void Song::GetSteps( vector& arrayAddTo, StepsType nt, Difficulty dc, int iMeterLow, int iMeterHigh, CString sDescription, bool bIncludeAutoGen ) const +void Song::GetSteps( vector& arrayAddTo, StepsType nt, Difficulty dc, int iMeterLow, int iMeterHigh, const CString &sDescription, bool bIncludeAutoGen, int Max ) const { for( unsigned i=0; im_StepsType != nt ) continue; if( dc != DIFFICULTY_INVALID && dc != m_apNotes[i]->GetDifficulty() ) continue; @@ -833,6 +836,10 @@ void Song::GetSteps( vector& arrayAddTo, StepsType nt, Difficulty dc, in continue; if( !bIncludeAutoGen && m_apNotes[i]->IsAutogen() ) continue; + + if( Max != -1 ) + --Max; + arrayAddTo.push_back( m_apNotes[i] ); } } @@ -840,7 +847,7 @@ void Song::GetSteps( vector& arrayAddTo, StepsType nt, Difficulty dc, in Steps* Song::GetStepsByDifficulty( StepsType nt, Difficulty dc, bool bIncludeAutoGen ) const { vector vNotes; - GetSteps( vNotes, nt, dc, -1, -1, "", bIncludeAutoGen ); + GetSteps( vNotes, nt, dc, -1, -1, "", bIncludeAutoGen, 1 ); if( vNotes.size() == 0 ) return NULL; else @@ -850,7 +857,7 @@ Steps* Song::GetStepsByDifficulty( StepsType nt, Difficulty dc, bool bIncludeAut Steps* Song::GetStepsByMeter( StepsType nt, int iMeterLow, int iMeterHigh, bool bIncludeAutoGen ) const { vector vNotes; - GetSteps( vNotes, nt, DIFFICULTY_INVALID, iMeterLow, iMeterHigh, "", bIncludeAutoGen ); + GetSteps( vNotes, nt, DIFFICULTY_INVALID, iMeterLow, iMeterHigh, "", bIncludeAutoGen, 1 ); if( vNotes.size() == 0 ) return NULL; else diff --git a/stepmania/src/song.h b/stepmania/src/song.h index c863d57cd2..89c3f9df50 100644 --- a/stepmania/src/song.h +++ b/stepmania/src/song.h @@ -178,7 +178,7 @@ public: bool SongHasNotesType( StepsType nt ) const; bool SongHasNotesTypeAndDifficulty( StepsType nt, Difficulty dc ) const; const vector& GetAllSteps() const { return m_apNotes; } - void GetSteps( vector& arrayAddTo, StepsType nt, Difficulty dc = DIFFICULTY_INVALID, int iMeterLow = -1, int iMeterHigh = -1, CString sDescription = "", bool bIncludeAutoGen = true ) const; + void GetSteps( vector& arrayAddTo, StepsType nt, Difficulty dc = DIFFICULTY_INVALID, int iMeterLow = -1, int iMeterHigh = -1, const CString &sDescription = "", bool bIncludeAutoGen = true, int Max = -1 ) const; Steps* GetStepsByDifficulty( StepsType nt, Difficulty dc, bool bIncludeAutoGen = true ) const; Steps* GetStepsByMeter( StepsType nt, int iMeterLow, int iMeterHigh, bool bIncludeAutoGen = true ) const; Steps* GetStepsByDescription( StepsType nt, CString sDescription, bool bIncludeAutoGen = true ) const;