From 5604e312f688629a11288930464bc7c719e1e49e Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 26 Mar 2003 19:34:59 +0000 Subject: [PATCH] Store tap offsets. This lets us derive the order notes were hit in; hopefully ScoreKeeper can be made a little more generic. --- stepmania/src/NoteDataWithScoring.cpp | 53 ++++++++++++++++++++++++--- stepmania/src/NoteDataWithScoring.h | 10 ++++- stepmania/src/Player.cpp | 22 +++++------ stepmania/src/Player.h | 2 +- 4 files changed, 68 insertions(+), 19 deletions(-) diff --git a/stepmania/src/NoteDataWithScoring.cpp b/stepmania/src/NoteDataWithScoring.cpp index 29fa61d9ff..280794e573 100644 --- a/stepmania/src/NoteDataWithScoring.cpp +++ b/stepmania/src/NoteDataWithScoring.cpp @@ -97,14 +97,44 @@ int NoteDataWithScoring::GetNumHoldNotesWithScore( HoldNoteScore hns, const floa return iNumSuccessfulHolds; } -bool NoteDataWithScoring::IsRowComplete( int index, TapNoteScore minGrade ) const +/* Return the minimum tap score of a row. If the row isn't complete (not all + * taps have been hit), return TNS_NONE or TNS_MISS. */ +TapNoteScore NoteDataWithScoring::MinTapNoteScore(unsigned row) const { + TapNoteScore score = TNS_MARVELOUS; for( int t=0; t= NOTE_TYPE_12TH ) + if( !IsRowEmpty(r) && MinTapNoteScore(r) >= TNS_GREAT && GetNoteType(r) >= NOTE_TYPE_12TH ) iNumChaosNotesCompleted++; } @@ -212,6 +242,19 @@ void NoteDataWithScoring::SetTapNoteScore(unsigned track, unsigned row, TapNoteS m_TapNoteScores[track][row] = tns; } +float NoteDataWithScoring::GetTapNoteOffset(unsigned track, unsigned row) const +{ + if(row >= m_TapNoteOffset[track].size()) + return 0; + return m_TapNoteOffset[track][row]; +} + +void NoteDataWithScoring::SetTapNoteOffset(unsigned track, unsigned row, float offset) +{ + extend(m_TapNoteOffset[track], 0.f, row); + m_TapNoteOffset[track][row] = offset; +} + HoldNoteScore NoteDataWithScoring::GetHoldNoteScore(unsigned h) const { if(h >= m_HoldNoteScores.size()) diff --git a/stepmania/src/NoteDataWithScoring.h b/stepmania/src/NoteDataWithScoring.h index 25ac478ad6..9633d5fefd 100644 --- a/stepmania/src/NoteDataWithScoring.h +++ b/stepmania/src/NoteDataWithScoring.h @@ -20,6 +20,11 @@ class NoteDataWithScoring : public NoteData vector m_TapNoteScores[MAX_NOTE_TRACKS]; vector m_HoldNoteScores; + /* Offset, in seconds, for each tap grade. Negative numbers mean the note + * was hit early; positive numbers mean it was hit late. These values are + * only meaningful for graded taps (m_TapNoteScores >= TNS_BOO). */ + vector m_TapNoteOffset[MAX_NOTE_TRACKS]; + /* 1.0 means this HoldNote has full life. * 0.0 means this HoldNote is dead * When this value hits 0.0 for the first time, m_HoldScore becomes HSS_NG. @@ -37,12 +42,15 @@ public: TapNoteScore GetTapNoteScore(unsigned track, unsigned row) const; void SetTapNoteScore(unsigned track, unsigned row, TapNoteScore tns); + float GetTapNoteOffset(unsigned track, unsigned row) const; + void SetTapNoteOffset(unsigned track, unsigned row, float offset); HoldNoteScore GetHoldNoteScore(unsigned h) const; void SetHoldNoteScore(unsigned h, HoldNoteScore hns); float GetHoldNoteLife(unsigned h) const; void SetHoldNoteLife(unsigned h, float f); - bool IsRowComplete( int index, TapNoteScore minGrade = TNS_GREAT ) const; + TapNoteScore MinTapNoteScore(unsigned row) const; + TapNoteScore LastTapNoteScore(unsigned row) const; float GetActualRadarValue( RadarCategory rv, float fSongSeconds ) const; float GetActualStreamRadarValue( float fSongSeconds ) const; diff --git a/stepmania/src/Player.cpp b/stepmania/src/Player.cpp index 37fb5e2a01..ecaa218791 100644 --- a/stepmania/src/Player.cpp +++ b/stepmania/src/Player.cpp @@ -393,12 +393,13 @@ void Player::Step( int col ) LOG->Trace("(%2d/%2d)Note offset: %f, Score: %i", m_iOffsetSample, SAMPLE_COUNT, fNoteOffset, score); SetTapNoteScore(col, iIndexOverlappingNote, score); + SetTapNoteOffset(col, iIndexOverlappingNote, fNoteOffset); - if (score>=TNS_GREAT ) + if ( score >= TNS_GREAT ) HandleAutosync(fNoteOffset); - if (score > TNS_NONE && IsRowComplete(iIndexOverlappingNote, TNS_BOO) ) - OnRowDestroyed( score, iIndexOverlappingNote ); + if (score > TNS_NONE && MinTapNoteScore(iIndexOverlappingNote) >= TNS_BOO ) + OnRowDestroyed( iIndexOverlappingNote ); } if( !bDestroyedNote ) @@ -426,18 +427,15 @@ void Player::HandleAutosync(float fNoteOffset) m_iOffsetSample = 0; } -void Player::OnRowDestroyed( TapNoteScore lastScore, int iIndexThatWasSteppedOn ) + +void Player::OnRowDestroyed( int iIndexThatWasSteppedOn ) { LOG->Trace( "Player::OnRowDestroyed" ); - // find the minimum score of the row - TapNoteScore score = TNS_MARVELOUS; - for( int t=0; t= TNS_BOO ) - score = min( score, tns ); - } + /* Find the minimum score of the row. This will never be TNS_NONE, since this + * function is only called when a row is completed. */ +// TapNoteScore score = MinTapNoteScore(iIndexThatWasSteppedOn); + TapNoteScore score = LastTapNoteScore(iIndexThatWasSteppedOn); /* If the whole row was hit with perfects or greats, remove the row * from the NoteField, so it disappears. */ diff --git a/stepmania/src/Player.h b/stepmania/src/Player.h index d6b6324a22..a4a34e9247 100644 --- a/stepmania/src/Player.h +++ b/stepmania/src/Player.h @@ -53,7 +53,7 @@ public: protected: int UpdateTapNotesMissedOlderThan( float fMissIfOlderThanThisBeat ); - void OnRowDestroyed( TapNoteScore lastScore, int iStepIndex ); + void OnRowDestroyed( int iStepIndex ); void HandleTapRowScore( TapNoteScore scoreOfLastTap, int iNumTapsInRow ); void HandleHoldScore( HoldNoteScore holdScore, TapNoteScore tapScore ); void HandleAutosync(float fNoteOffset);