CopyRange const fix.

Add To4s, From4s.
This commit is contained in:
Glenn Maynard
2003-10-04 04:05:29 +00:00
parent 7d4ef141dc
commit 45fcce6e07
2 changed files with 21 additions and 7 deletions
+18 -6
View File
@@ -73,15 +73,16 @@ void NoteData::ClearAll()
/* Copy a range from pFrom to this. (Note that this does *not* overlay; /* Copy a range from pFrom to this. (Note that this does *not* overlay;
* all data in the range is overwritten.) */ * 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 ); ASSERT( pFrom->m_iNumTracks == m_iNumTracks );
if( iToIndexBegin == -1 ) if( iToIndexBegin == -1 )
iToIndexBegin = 0; iToIndexBegin = 0;
pFrom->ConvertHoldNotesTo4s(); NoteData From, To;
this->ConvertHoldNotesTo4s(); From.To4s( *pFrom );
To.To4s( *this );
// copy recorded TapNotes // copy recorded TapNotes
int f = iFromIndexBegin, t = iToIndexBegin; int f = iFromIndexBegin, t = iToIndexBegin;
@@ -89,13 +90,12 @@ void NoteData::CopyRange( NoteData* pFrom, int iFromIndexBegin, int iFromIndexEn
while( f<=iFromIndexEnd ) while( f<=iFromIndexEnd )
{ {
for( int c=0; c<m_iNumTracks; c++ ) for( int c=0; c<m_iNumTracks; c++ )
SetTapNote(c, t, pFrom->GetTapNote(c, f)); To.SetTapNote(c, t, From.GetTapNote(c, f));
f++; f++;
t++; t++;
} }
pFrom->Convert4sToHoldNotes(); this->From4s( To );
this->Convert4sToHoldNotes();
} }
void NoteData::Config( const NoteData &From ) void NoteData::Config( const NoteData &From )
@@ -378,6 +378,18 @@ void NoteData::From2sAnd3s( const NoteData &out )
Convert2sAnd3sToHoldNotes(); Convert2sAnd3sToHoldNotes();
} }
void NoteData::To4s( const NoteData &out )
{
CopyAll( &out );
ConvertHoldNotesTo4s();
}
void NoteData::From4s( const NoteData &out )
{
CopyAll( &out );
Convert4sToHoldNotes();
}
/* "104444001" == /* "104444001" ==
* "102000301" * "102000301"
* *
+3 -1
View File
@@ -57,7 +57,7 @@ public:
void ClearRange( int iNoteIndexBegin, int iNoteIndexEnd ); void ClearRange( int iNoteIndexBegin, int iNoteIndexEnd );
void ClearAll(); 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 ); void CopyAll( const NoteData* pFrom );
inline bool IsRowEmpty( int index ) const inline bool IsRowEmpty( int index ) const
@@ -135,6 +135,8 @@ public:
void Convert4sToHoldNotes(); void Convert4sToHoldNotes();
void ConvertHoldNotesTo4s(); 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 // True if no notes in row that aren't true in the mask
bool RowPassesValidMask( int row, bool bValidMask[] ); bool RowPassesValidMask( int row, bool bValidMask[] );