From 9735755e0045613630f7033afcc7c1b5ae8eafe3 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 22 Jan 2005 18:51:51 +0000 Subject: [PATCH] Add MAX_NOTE_ROW, indicating the maximum row that we can represent. We can actually go much higher; I set this to 1<<30 instead of 1<<31 so we don't overflow when eg. adding one beat or one measure in some algorithms. The advantage of this over "999999" is it won't break if ROWS_PER_BEAT is changed to a large value. Also, since this value will typically be much larger than any actual row, it'll quickly show up any algorithms that aren't iterating properly. An advantage over older code using 999999 is that we don't have to manually clamp the value to a reasonable range; FOREACH_NONEMPTY_ROW_IN_TRACK_RANGE, etc. don't care. An advantage of this over using -1 as a sentinel is that we don't have to carefully check and fill in the value in every function using it. --- stepmania/src/NoteDataUtil.h | 46 +++++++++++++-------------- stepmania/src/NoteDataWithScoring.cpp | 10 +++--- stepmania/src/NoteTypes.h | 1 + 3 files changed, 29 insertions(+), 28 deletions(-) diff --git a/stepmania/src/NoteDataUtil.h b/stepmania/src/NoteDataUtil.h index b980bce1ae..28aa35713e 100644 --- a/stepmania/src/NoteDataUtil.h +++ b/stepmania/src/NoteDataUtil.h @@ -32,21 +32,21 @@ namespace NoteDataUtil void GetRadarValues( const NoteData &in, float fSongSeconds, RadarValues& out ); - void RemoveHoldNotes( NoteData &inout, int iStartIndex = 0, int iEndIndex = 999999 ); - void RemoveSimultaneousNotes( NoteData &inout, int iMaxSimultaneous, int iStartIndex = 0, int iEndIndex = 999999 ); - void RemoveJumps( NoteData &inout, int iStartIndex = 0, int iEndIndex = 999999 ); - void RemoveHands( NoteData &inout, int iStartIndex = 0, int iEndIndex = 999999 ); - void RemoveQuads( NoteData &inout, int iStartIndex = 0, int iEndIndex = 999999 ); - void RemoveMines( NoteData &inout, int iStartIndex = 0, int iEndIndex = 999999 ); + void RemoveHoldNotes( NoteData &inout, int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ); + void RemoveSimultaneousNotes( NoteData &inout, int iMaxSimultaneous, int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ); + void RemoveJumps( NoteData &inout, int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ); + void RemoveHands( NoteData &inout, int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ); + void RemoveQuads( NoteData &inout, int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ); + void RemoveMines( NoteData &inout, int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ); void RemoveAllButOneTap( NoteData &inout, int row ); enum TrackMapping { left, right, mirror, shuffle, super_shuffle, stomp, NUM_TRACK_MAPPINGS }; - void Turn( NoteData &inout, StepsType st, TrackMapping tt, int iStartIndex = 0, int iEndIndex = 999999 ); - void Little( NoteData &inout, int iStartIndex = 0, int iEndIndex = 999999 ); - void Wide( NoteData &inout, int iStartIndex = 0, int iEndIndex = 999999 ); - void Big( NoteData &inout, int iStartIndex = 0, int iEndIndex = 999999 ); - void Quick( NoteData &inout, int iStartIndex = 0, int iEndIndex = 999999 ); - void BMRize( NoteData &inout, int iStartIndex = 0, int iEndIndex = 999999 ); - void Skippy( NoteData &inout, int iStartIndex = 0, int iEndIndex = 999999 ); + void Turn( NoteData &inout, StepsType st, TrackMapping tt, int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ); + void Little( NoteData &inout, int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ); + void Wide( NoteData &inout, int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ); + void Big( NoteData &inout, int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ); + void Quick( NoteData &inout, int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ); + void BMRize( NoteData &inout, int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ); + void Skippy( NoteData &inout, int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ); void InsertIntelligentTaps( NoteData &in, int iWindowSizeRows, @@ -54,14 +54,14 @@ namespace NoteDataUtil int iWindowStrideRows, bool bSkippy, int iStartIndex = 0, - int iEndIndex = 999999 ); - void AddMines( NoteData &inout, int iStartIndex = 0, int iEndIndex = 999999 ); - void Echo( NoteData &inout, int iStartIndex = 0, int iEndIndex = 999999 ); - void Stomp( NoteData &inout, StepsType st, int iStartIndex = 0, int iEndIndex = 999999 ); - void Planted( NoteData &inout, int iStartIndex = 0, int iEndIndex = 999999 ); - void Floored( NoteData &inout, int iStartIndex = 0, int iEndIndex = 999999 ); - void Twister( NoteData &inout, int iStartIndex = 0, int iEndIndex = 999999 ); - void ConvertTapsToHolds( NoteData &inout, int iSimultaneousHolds, int iStartIndex = 0, int iEndIndex = 999999 ); + int iEndIndex = MAX_NOTE_ROW ); + void AddMines( NoteData &inout, int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ); + void Echo( NoteData &inout, int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ); + void Stomp( NoteData &inout, StepsType st, int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ); + void Planted( NoteData &inout, int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ); + void Floored( NoteData &inout, int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ); + void Twister( NoteData &inout, int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ); + void ConvertTapsToHolds( NoteData &inout, int iSimultaneousHolds, int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ); // change all TAP_ADDITIONs to TAP_TAPs void ConvertAdditionsToRegular( NoteData &inout ); @@ -90,11 +90,11 @@ namespace NoteDataUtil bool RowPassesValidMask( NoteData &inout, int row, const bool bValidMask[] ); void TransformNoteData( NoteData &nd, const AttackArray &aa, StepsType st, Song* pSong ); - void TransformNoteData( NoteData &nd, const PlayerOptions &po, StepsType st, int iStartIndex = 0, int iEndIndex = 999999 ); + void TransformNoteData( NoteData &nd, const PlayerOptions &po, StepsType st, int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ); void AddTapAttacks( NoteData &nd, Song* pSong ); // void Scale( NoteData &nd, float fScale ); - void ScaleRegion( NoteData &nd, float fScale, int iStartIndex = 0, int iEndIndex = 999999 ); + void ScaleRegion( NoteData &nd, float fScale, int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ); inline void Scale( NoteData &nd, float fScale ) { NoteDataUtil::ScaleRegion(nd, fScale); } // If iRowsToShift > 0, add blank rows. If iRowsToShift < 0, delete rows diff --git a/stepmania/src/NoteDataWithScoring.cpp b/stepmania/src/NoteDataWithScoring.cpp index a742650732..86abb5daef 100644 --- a/stepmania/src/NoteDataWithScoring.cpp +++ b/stepmania/src/NoteDataWithScoring.cpp @@ -6,7 +6,7 @@ namespace { -int GetNumTapNotesWithScore( const NoteData &in, TapNoteScore tns, int iStartIndex = 0, int iEndIndex = 999999 ) +int GetNumTapNotesWithScore( const NoteData &in, TapNoteScore tns, int iStartIndex = 0, int iEndIndex = MAX_NOTE_ROW ) { int iNumSuccessfulTapNotes = 0; for( int t=0; t