rename: MaxRow -> NumRows
fix some off-by-1 row errors
This commit is contained in:
+21
-21
@@ -127,7 +127,7 @@ void NoteData::CopyAll( const NoteData* pFrom )
|
||||
bool NoteData::IsRowEmpty( int index ) const
|
||||
{
|
||||
/* If this is out of range, we don't have any notes there, so all tracks are empty. */
|
||||
if( index < 0 || index >= GetMaxRow() )
|
||||
if( index < 0 || index >= GetNumRows() )
|
||||
return true;
|
||||
|
||||
for( int t=0; t<m_iNumTracks; t++ )
|
||||
@@ -140,8 +140,8 @@ bool NoteData::IsRangeEmpty( int track, int iIndexBegin, int iIndexEnd ) const
|
||||
{
|
||||
ASSERT( track<m_iNumTracks );
|
||||
|
||||
CLAMP( iIndexBegin, 0, GetMaxRow() );
|
||||
CLAMP( iIndexEnd, 0, GetMaxRow() );
|
||||
CLAMP( iIndexBegin, 0, GetNumRows()-1 );
|
||||
CLAMP( iIndexEnd, 0, GetNumRows()-1 );
|
||||
|
||||
for( int i=iIndexBegin; i<=iIndexEnd; i++ )
|
||||
if( GetTapNoteX(track,i) != TAP_EMPTY )
|
||||
@@ -168,7 +168,7 @@ void NoteData::GetTapNonEmptyTracks( int index, set<int>& addTo ) const
|
||||
int NoteData::GetFirstNonEmptyTrack( int index ) const
|
||||
{
|
||||
/* If this is out of range, we don't have any notes there, so all tracks are empty. */
|
||||
if( index < 0 || index >= GetMaxRow() )
|
||||
if( index < 0 || index >= GetNumRows() )
|
||||
return 0;
|
||||
|
||||
for( int t=0; t<m_iNumTracks; t++ )
|
||||
@@ -180,7 +180,7 @@ int NoteData::GetFirstNonEmptyTrack( int index ) const
|
||||
int NoteData::GetNumTracksWithTap( int index ) const
|
||||
{
|
||||
/* If this is out of range, we don't have any notes there, so all tracks are empty. */
|
||||
if( index < 0 || index >= GetMaxRow() )
|
||||
if( index < 0 || index >= GetNumRows() )
|
||||
return 0;
|
||||
|
||||
int iNum = 0;
|
||||
@@ -196,7 +196,7 @@ int NoteData::GetNumTracksWithTap( int index ) const
|
||||
int NoteData::GetNumTracksWithTapOrHoldHead( int index ) const
|
||||
{
|
||||
/* If this is out of range, we don't have any notes there, so all tracks are empty. */
|
||||
if( index < 0 || index >= GetMaxRow() )
|
||||
if( index < 0 || index >= GetNumRows() )
|
||||
return 0;
|
||||
|
||||
int iNum = 0;
|
||||
@@ -212,7 +212,7 @@ int NoteData::GetNumTracksWithTapOrHoldHead( int index ) const
|
||||
int NoteData::GetFirstTrackWithTap( int index ) const
|
||||
{
|
||||
/* If this is out of range, we don't have any notes there, so all tracks are empty. */
|
||||
if( index < 0 || index >= GetMaxRow() )
|
||||
if( index < 0 || index >= GetNumRows() )
|
||||
return -1;
|
||||
|
||||
for( int t=0; t<m_iNumTracks; t++ )
|
||||
@@ -227,7 +227,7 @@ int NoteData::GetFirstTrackWithTap( int index ) const
|
||||
int NoteData::GetFirstTrackWithTapOrHoldHead( int index ) const
|
||||
{
|
||||
/* If this is out of range, we don't have any notes there, so all tracks are empty. */
|
||||
if( index < 0 || index >= GetMaxRow() )
|
||||
if( index < 0 || index >= GetNumRows() )
|
||||
return -1;
|
||||
|
||||
for( int t=0; t<m_iNumTracks; t++ )
|
||||
@@ -328,10 +328,10 @@ void NoteData::PruneUnusedAttacksFromMap()
|
||||
// Add all used AttackNote values to a map.
|
||||
map<TapNote,int> mapAttackToNothing;
|
||||
|
||||
int max_row = GetMaxRow();
|
||||
int num_rows = GetNumRows();
|
||||
for( int t=0; t<m_iNumTracks; t++ )
|
||||
{
|
||||
for( int r=0; r<=max_row; r++ )
|
||||
for( int r=0; r<num_rows; r++ )
|
||||
{
|
||||
TapNote tn = GetTapNote(t, r);
|
||||
if( IsTapAttack( tn ) )
|
||||
@@ -432,14 +432,14 @@ int NoteData::GetNumTapNotes( float fStartBeat, float fEndBeat ) const
|
||||
int iNumNotes = 0;
|
||||
|
||||
if( fEndBeat == -1 )
|
||||
fEndBeat = GetMaxBeat();
|
||||
fEndBeat = GetNumBeats();
|
||||
|
||||
int iStartIndex = BeatToNoteRow( fStartBeat );
|
||||
int iEndIndex = BeatToNoteRow( fEndBeat );
|
||||
|
||||
/* Clamp to known-good ranges. */
|
||||
iStartIndex = max( iStartIndex, 0 );
|
||||
iEndIndex = min( iEndIndex, GetMaxRow()-1 );
|
||||
iEndIndex = min( iEndIndex, GetNumRows()-1 );
|
||||
|
||||
for( int t=0; t<m_iNumTracks; t++ )
|
||||
{
|
||||
@@ -458,7 +458,7 @@ int NoteData::GetNumRowsWithTap( float fStartBeat, float fEndBeat ) const
|
||||
{
|
||||
int iNumNotes = 0;
|
||||
|
||||
if(fEndBeat == -1) fEndBeat = GetMaxBeat();
|
||||
if(fEndBeat == -1) fEndBeat = GetNumBeats();
|
||||
int iStartIndex = BeatToNoteRow( fStartBeat );
|
||||
int iEndIndex = BeatToNoteRow( fEndBeat );
|
||||
|
||||
@@ -474,14 +474,14 @@ int NoteData::GetNumMines( float fStartBeat, float fEndBeat ) const
|
||||
int iNumMines = 0;
|
||||
|
||||
if( fEndBeat == -1 )
|
||||
fEndBeat = GetMaxBeat();
|
||||
fEndBeat = GetNumBeats();
|
||||
|
||||
int iStartIndex = BeatToNoteRow( fStartBeat );
|
||||
int iEndIndex = BeatToNoteRow( fEndBeat );
|
||||
|
||||
/* Clamp to known-good ranges. */
|
||||
iStartIndex = max( iStartIndex, 0 );
|
||||
iEndIndex = min( iEndIndex, GetMaxRow()-1 );
|
||||
iEndIndex = min( iEndIndex, GetNumRows()-1 );
|
||||
|
||||
for( int t=0; t<m_iNumTracks; t++ )
|
||||
{
|
||||
@@ -497,7 +497,7 @@ int NoteData::GetNumRowsWithTapOrHoldHead( float fStartBeat, float fEndBeat ) co
|
||||
{
|
||||
int iNumNotes = 0;
|
||||
|
||||
if(fEndBeat == -1) fEndBeat = GetMaxBeat();
|
||||
if(fEndBeat == -1) fEndBeat = GetNumBeats();
|
||||
int iStartIndex = BeatToNoteRow( fStartBeat );
|
||||
int iEndIndex = BeatToNoteRow( fEndBeat );
|
||||
|
||||
@@ -545,14 +545,14 @@ int NoteData::GetNumHands( float fStartBeat, float fEndBeat ) const
|
||||
* Otherwise, every row of hold notes counts, so three simultaneous hold
|
||||
* notes will count as hundreds of "hands". */
|
||||
if( fEndBeat == -1 )
|
||||
fEndBeat = GetMaxBeat();
|
||||
fEndBeat = GetNumBeats();
|
||||
|
||||
int iStartIndex = BeatToNoteRow( fStartBeat );
|
||||
int iEndIndex = BeatToNoteRow( fEndBeat );
|
||||
|
||||
/* Clamp to known-good ranges. */
|
||||
iStartIndex = max( iStartIndex, 0 );
|
||||
iEndIndex = min( iEndIndex, GetMaxRow()-1 );
|
||||
iEndIndex = min( iEndIndex, GetNumRows()-1 );
|
||||
|
||||
int iNum = 0;
|
||||
for( int i=iStartIndex; i<=iEndIndex; i++ )
|
||||
@@ -569,14 +569,14 @@ int NoteData::GetNumHands( float fStartBeat, float fEndBeat ) const
|
||||
int NoteData::GetNumN( int MinTaps, float fStartBeat, float fEndBeat ) const
|
||||
{
|
||||
if( fEndBeat == -1 )
|
||||
fEndBeat = GetMaxBeat();
|
||||
fEndBeat = GetNumBeats();
|
||||
|
||||
int iStartIndex = BeatToNoteRow( fStartBeat );
|
||||
int iEndIndex = BeatToNoteRow( fEndBeat );
|
||||
|
||||
/* Clamp to known-good ranges. */
|
||||
iStartIndex = max( iStartIndex, 0 );
|
||||
iEndIndex = min( iEndIndex, GetMaxRow()-1 );
|
||||
iEndIndex = min( iEndIndex, GetNumRows()-1 );
|
||||
|
||||
int iNum = 0;
|
||||
for( int i=iStartIndex; i<=iEndIndex; i++ )
|
||||
@@ -598,7 +598,7 @@ int NoteData::GetNumN( int MinTaps, float fStartBeat, float fEndBeat ) const
|
||||
int NoteData::GetNumHoldNotes( float fStartBeat, float fEndBeat ) const
|
||||
{
|
||||
if( fEndBeat == -1 )
|
||||
fEndBeat = GetMaxBeat();
|
||||
fEndBeat = GetNumBeats();
|
||||
int iStartIndex = BeatToNoteRow( fStartBeat );
|
||||
int iEndIndex = BeatToNoteRow( fEndBeat );
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
void ReserveRows( int row );
|
||||
|
||||
/* GetTapNote is called a lot. This one doesn't do any bounds checking,
|
||||
* which is much faster. Be sure that 0 <= row < GetMaxRow(). */
|
||||
* which is much faster. Be sure that 0 <= row < GetNumRows(). */
|
||||
inline TapNote GetTapNoteX(unsigned track, int row) const
|
||||
{
|
||||
return m_TapNotes[track][row];
|
||||
@@ -100,10 +100,10 @@ public:
|
||||
//
|
||||
// statistics
|
||||
//
|
||||
/* Return the highest beat/row that might contain notes. (Use GetLastBeat if you need
|
||||
* accuracy.) */
|
||||
float GetMaxBeat() const { return NoteRowToBeat(GetMaxRow()); }
|
||||
int GetMaxRow() const { return int(m_TapNotes[0].size()); }
|
||||
/* Return the number of beats/rows that might contain notes. Use
|
||||
* GetLast* if you need to know the location of the last note. */
|
||||
float GetNumBeats() const { return NoteRowToBeat(GetNumRows()); }
|
||||
int GetNumRows() const { return int(m_TapNotes[0].size()); }
|
||||
|
||||
float GetFirstBeat() const; // return the beat number of the first note
|
||||
int GetFirstRow() const;
|
||||
|
||||
@@ -346,8 +346,8 @@ void NoteDataUtil::LoadOverlapped( const NoteData &input, NoteData &out, int iNe
|
||||
|
||||
const int ShiftThreshold = BeatToNoteRow(1);
|
||||
|
||||
const int iLastRow = in.GetMaxRow();
|
||||
for( int row = 0; row < iLastRow; ++row )
|
||||
const int iNumRows = in.GetNumRows();
|
||||
for( int row = 0; row < iNumRows; ++row )
|
||||
{
|
||||
for ( int i = 0; i < in.GetNumTracks(); i++ )
|
||||
{
|
||||
@@ -393,7 +393,7 @@ void NoteDataUtil::LoadTransformedLights( const NoteData &in, NoteData &out, int
|
||||
out.Config(in);
|
||||
out.SetNumTracks( iNewNumTracks );
|
||||
|
||||
for( int r=0; r < Original.GetMaxRow(); ++r )
|
||||
for( int r=0; r < Original.GetNumRows(); ++r )
|
||||
{
|
||||
if( Original.IsRowEmpty( r ) )
|
||||
continue;
|
||||
@@ -775,14 +775,14 @@ void NoteDataUtil::Turn( NoteData &in, StepsType st, TrackMapping tt, float fSta
|
||||
GetTrackMapping( st, tt, in.GetNumTracks(), iTakeFromTrack );
|
||||
|
||||
if( fEndBeat == -1 )
|
||||
fEndBeat = in.GetMaxBeat();
|
||||
fEndBeat = in.GetNumBeats();
|
||||
|
||||
int iStartIndex = BeatToNoteRow( fStartBeat );
|
||||
int iEndIndex = BeatToNoteRow( fEndBeat );
|
||||
|
||||
/* Clamp to known-good ranges. */
|
||||
iStartIndex = max( iStartIndex, 0 );
|
||||
iEndIndex = min( iEndIndex, in.GetMaxRow()-1 );
|
||||
iEndIndex = min( iEndIndex, in.GetNumRows()-1 );
|
||||
|
||||
/* XXX: We could do this without an extra temporary NoteData: calculate
|
||||
* a list of "swaps". For example, the 4-track mapping 1 0 2 3 is swaps
|
||||
@@ -1514,7 +1514,7 @@ void NoteDataUtil::FixImpossibleRows( NoteData &in, StepsType st )
|
||||
return;
|
||||
|
||||
// each row must pass at least one valid mask
|
||||
for( int r=0; r<=in.GetMaxRow(); r++ )
|
||||
for( int r=0; r<in.GetNumRows(); r++ )
|
||||
{
|
||||
// only check rows with jumps
|
||||
if( in.GetNumTapNonEmptyTracks(r) < 2 )
|
||||
|
||||
@@ -24,7 +24,7 @@ int NoteDataWithScoring::GetNumTapNotesWithScore( TapNoteScore tns, const float
|
||||
int iNumSuccessfulTapNotes = 0;
|
||||
|
||||
if(fEndBeat == -1)
|
||||
fEndBeat = GetMaxBeat()+1;
|
||||
fEndBeat = GetNumBeats()+1;
|
||||
|
||||
unsigned iStartIndex = BeatToNoteRow( fStartBeat );
|
||||
unsigned iEndIndex = BeatToNoteRow( fEndBeat );
|
||||
@@ -44,13 +44,13 @@ int NoteDataWithScoring::GetNumTapNotesWithScore( TapNoteScore tns, const float
|
||||
int NoteDataWithScoring::GetNumNWithScore( TapNoteScore tns, int MinTaps, const float fStartBeat, float fEndBeat ) const
|
||||
{
|
||||
if( fEndBeat == -1 )
|
||||
fEndBeat = GetMaxBeat();
|
||||
fEndBeat = GetNumBeats();
|
||||
|
||||
int iStartIndex = BeatToNoteRow( fStartBeat );
|
||||
int iEndIndex = BeatToNoteRow( fEndBeat );
|
||||
|
||||
iStartIndex = max( iStartIndex, 0 );
|
||||
iEndIndex = min( iEndIndex, GetMaxRow()-1 );
|
||||
iEndIndex = min( iEndIndex, GetNumRows()-1 );
|
||||
|
||||
int iNumSuccessfulDoubles = 0;
|
||||
for( int i=iStartIndex; i<=iEndIndex; i++ )
|
||||
@@ -80,7 +80,7 @@ int NoteDataWithScoring::GetNumHoldNotesWithScore( HoldNoteScore hns, const floa
|
||||
int iNumSuccessfulHolds = 0;
|
||||
|
||||
if(fEndBeat == -1)
|
||||
fEndBeat = GetMaxBeat();
|
||||
fEndBeat = GetNumBeats();
|
||||
|
||||
int iStartIndex = BeatToNoteRow( fStartBeat );
|
||||
int iEndIndex = BeatToNoteRow( fEndBeat );
|
||||
@@ -99,13 +99,13 @@ int NoteDataWithScoring::GetNumHoldNotesWithScore( HoldNoteScore hns, const floa
|
||||
int NoteDataWithScoring::GetSuccessfulMines( float fStartBeat, float fEndBeat ) const
|
||||
{
|
||||
if( fEndBeat == -1 )
|
||||
fEndBeat = GetMaxBeat();
|
||||
fEndBeat = GetNumBeats();
|
||||
|
||||
int iStartIndex = BeatToNoteRow( fStartBeat );
|
||||
int iEndIndex = BeatToNoteRow( fEndBeat );
|
||||
|
||||
iStartIndex = max( iStartIndex, 0 );
|
||||
iEndIndex = min( iEndIndex, GetMaxRow()-1 );
|
||||
iEndIndex = min( iEndIndex, GetNumRows()-1 );
|
||||
|
||||
int iNumSuccessfulMinesNotes = 0;
|
||||
for( int i=iStartIndex; i<=iEndIndex; i++ )
|
||||
@@ -124,14 +124,14 @@ int NoteDataWithScoring::GetSuccessfulMines( float fStartBeat, float fEndBeat )
|
||||
int NoteDataWithScoring::GetSuccessfulHands( float fStartBeat, float fEndBeat ) const
|
||||
{
|
||||
if( fEndBeat == -1 )
|
||||
fEndBeat = GetMaxBeat();
|
||||
fEndBeat = GetNumBeats();
|
||||
|
||||
int iStartIndex = BeatToNoteRow( fStartBeat );
|
||||
int iEndIndex = BeatToNoteRow( fEndBeat );
|
||||
|
||||
/* Clamp to known-good ranges. */
|
||||
iStartIndex = max( iStartIndex, 0 );
|
||||
iEndIndex = min( iEndIndex, GetMaxRow()-1 );
|
||||
iEndIndex = min( iEndIndex, GetNumRows()-1 );
|
||||
|
||||
int iNum = 0;
|
||||
for( int i=iStartIndex; i<=iEndIndex; i++ )
|
||||
|
||||
@@ -473,7 +473,7 @@ void PlayerMinus::ApplyWaitingTransforms()
|
||||
|
||||
float fStartBeat, fEndBeat;
|
||||
mod.GetAttackBeats( GAMESTATE->m_pCurSong, m_PlayerNumber, fStartBeat, fEndBeat );
|
||||
fEndBeat = min( fEndBeat, GetMaxBeat() );
|
||||
fEndBeat = min( fEndBeat, GetNumBeats() );
|
||||
|
||||
LOG->Trace( "Applying transform '%s' from %f to %f to '%s'", mod.sModifier.c_str(), fStartBeat, fEndBeat,
|
||||
GAMESTATE->m_pCurSong->GetTranslitMainTitle().c_str() );
|
||||
|
||||
Reference in New Issue
Block a user