From 45fcce6e07c7952f5d557243c867b60c75f749fa Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 4 Oct 2003 04:05:29 +0000 Subject: [PATCH] CopyRange const fix. Add To4s, From4s. --- stepmania/src/NoteData.cpp | 24 ++++++++++++++++++------ stepmania/src/NoteData.h | 4 +++- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/stepmania/src/NoteData.cpp b/stepmania/src/NoteData.cpp index a70f91163e..3d060799f0 100644 --- a/stepmania/src/NoteData.cpp +++ b/stepmania/src/NoteData.cpp @@ -73,15 +73,16 @@ void NoteData::ClearAll() /* Copy a range from pFrom to this. (Note that this does *not* overlay; * all data in the range is overwritten.) */ -void NoteData::CopyRange( NoteData* pFrom, int iFromIndexBegin, int iFromIndexEnd, int iToIndexBegin ) +void NoteData::CopyRange( const NoteData* pFrom, int iFromIndexBegin, int iFromIndexEnd, int iToIndexBegin ) { ASSERT( pFrom->m_iNumTracks == m_iNumTracks ); if( iToIndexBegin == -1 ) iToIndexBegin = 0; - pFrom->ConvertHoldNotesTo4s(); - this->ConvertHoldNotesTo4s(); + NoteData From, To; + From.To4s( *pFrom ); + To.To4s( *this ); // copy recorded TapNotes int f = iFromIndexBegin, t = iToIndexBegin; @@ -89,13 +90,12 @@ void NoteData::CopyRange( NoteData* pFrom, int iFromIndexBegin, int iFromIndexEn while( f<=iFromIndexEnd ) { for( int c=0; cGetTapNote(c, f)); + To.SetTapNote(c, t, From.GetTapNote(c, f)); f++; t++; } - pFrom->Convert4sToHoldNotes(); - this->Convert4sToHoldNotes(); + this->From4s( To ); } void NoteData::Config( const NoteData &From ) @@ -378,6 +378,18 @@ void NoteData::From2sAnd3s( const NoteData &out ) Convert2sAnd3sToHoldNotes(); } +void NoteData::To4s( const NoteData &out ) +{ + CopyAll( &out ); + ConvertHoldNotesTo4s(); +} + +void NoteData::From4s( const NoteData &out ) +{ + CopyAll( &out ); + Convert4sToHoldNotes(); +} + /* "104444001" == * "102000301" * diff --git a/stepmania/src/NoteData.h b/stepmania/src/NoteData.h index 65176c5967..043396c6b8 100644 --- a/stepmania/src/NoteData.h +++ b/stepmania/src/NoteData.h @@ -57,7 +57,7 @@ public: void ClearRange( int iNoteIndexBegin, int iNoteIndexEnd ); void ClearAll(); - void CopyRange( NoteData* pFrom, int iFromIndexBegin, int iFromIndexEnd, int iToIndexBegin = -1 ); + void CopyRange( const NoteData* pFrom, int iFromIndexBegin, int iFromIndexEnd, int iToIndexBegin = -1 ); void CopyAll( const NoteData* pFrom ); inline bool IsRowEmpty( int index ) const @@ -135,6 +135,8 @@ public: void Convert4sToHoldNotes(); void ConvertHoldNotesTo4s(); + void To4s( const NoteData &out ); + void From4s( const NoteData &out ); // True if no notes in row that aren't true in the mask bool RowPassesValidMask( int row, bool bValidMask[] );