diff --git a/stepmania/src/NoteData.cpp b/stepmania/src/NoteData.cpp index 3d9677268c..d4dae09f33 100644 --- a/stepmania/src/NoteData.cpp +++ b/stepmania/src/NoteData.cpp @@ -788,6 +788,24 @@ bool NoteData::GetNextTapNoteRowForTrack( int track, int &rowInOut ) const return true; } +bool NoteData::GetPrevTapNoteRowForTrack( int track, int &rowInOut ) const +{ + const TrackMap &mapTrack = m_TapNotes[track]; + + /* Find the first note >= rowInOut. */ + TrackMap::const_iterator iter = mapTrack.lower_bound( rowInOut ); + + /* If we're at the beginning, we can't move back any more. */ + if( iter == mapTrack.begin() ) + return false; + + /* Move back by one. */ + --iter; + ASSERT( iter->first < rowInOut ); + rowInOut = iter->first; + return true; +} + bool NoteData::GetNextTapNoteRowForAllTracks( int &rowInOut ) const { int iClosestNextRow = 999999; diff --git a/stepmania/src/NoteData.h b/stepmania/src/NoteData.h index 761b75aa07..24c19bf22e 100644 --- a/stepmania/src/NoteData.h +++ b/stepmania/src/NoteData.h @@ -67,6 +67,7 @@ public: // index > afterRow. bool GetNextTapNoteRowForTrack( int track, int &rowInOut ) const; bool GetNextTapNoteRowForAllTracks( int &rowInOut ) const; + bool GetPrevTapNoteRowForTrack( int track, int &rowInOut ) const; void MoveTapNoteTrack( int dest, int src ); void SetTapNote( int track, int row, const TapNote& tn );