From 46ace22b79e81e61c29c6e47e239e80e2dd99d1f Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 22 Jan 2005 02:10:54 +0000 Subject: [PATCH] continue merging NoteDataWithScoring stuff --- stepmania/src/NoteDataWithScoring.cpp | 60 +++++++-------------------- stepmania/src/NoteDataWithScoring.h | 10 +---- stepmania/src/NoteTypes.h | 2 +- stepmania/src/Player.cpp | 31 ++++++++------ 4 files changed, 38 insertions(+), 65 deletions(-) diff --git a/stepmania/src/NoteDataWithScoring.cpp b/stepmania/src/NoteDataWithScoring.cpp index 89a8909ca1..c4da86c947 100644 --- a/stepmania/src/NoteDataWithScoring.cpp +++ b/stepmania/src/NoteDataWithScoring.cpp @@ -12,9 +12,6 @@ NoteDataWithScoring::NoteDataWithScoring() void NoteDataWithScoring::Init() { NoteData::Init(); - - for( int t=0; t= tns ) + const TapNote &tn = GetTapNote(t, r); + if( tn.result.tns >= tns ) iNumSuccessfulTapNotes++; } } @@ -58,12 +56,13 @@ int NoteDataWithScoring::GetNumNWithScore( TapNoteScore tns, int MinTaps, const TapNoteScore minTapNoteScore = TNS_MARVELOUS; for( int t=0; t= MinTaps && minTapNoteScore >= tns ) @@ -110,7 +109,8 @@ int NoteDataWithScoring::GetSuccessfulMines( float fStartBeat, float fEndBeat ) { for( int t=0; tGetTapNote(t,i).type == TapNote::mine && GetTapNoteScore(t, i) != TNS_HIT_MINE ) + const TapNote &tn = GetTapNote(t,i); + if( tn.type == TapNote::mine && tn.result.tns != TNS_HIT_MINE ) iNumSuccessfulMinesNotes++; } } @@ -145,7 +145,7 @@ int NoteDataWithScoring::GetSuccessfulHands( float fStartBeat, float fEndBeat ) continue; if( tn.type == TapNote::mine ) // mines don't count continue; - if( GetTapNoteScore(t, i) <= TNS_BOO ) + if( tn.result.tns <= TNS_BOO ) Missed = true; } @@ -186,10 +186,10 @@ TapNoteScore NoteDataWithScoring::MinTapNoteScore(unsigned row) const { /* Don't coun, or else the score * will always be TNS_NONE. */ - TapNote tn = GetTapNote(t, row); + const TapNote &tn = GetTapNote(t, row); if( tn.type == TapNote::empty || tn.type == TapNote::mine) continue; - score = min( score, GetTapNoteScore(t, row) ); + score = min( score, tn.result.tns ); } return score; @@ -203,6 +203,7 @@ bool NoteDataWithScoring::IsRowCompletelyJudged(unsigned row) const /* Return the last tap score of a row: the grade of the tap that completed * the row. If the row has no tap notes, return -1. If any tap notes aren't * graded (any tap is TNS_NONE) or are missed (TNS_MISS), return it. */ +/* XXX: this will fill in many empty tap notes due to excess GetTapnote calls */ int NoteDataWithScoring::LastTapNoteScoreTrack(unsigned row) const { float scoretime = -9999; @@ -210,16 +211,17 @@ int NoteDataWithScoring::LastTapNoteScoreTrack(unsigned row) const for( int t=0; t &v, T val, unsigned pos) } } -TapNoteScore NoteDataWithScoring::GetTapNoteScore(unsigned track, unsigned row) const -{ - if(row >= m_TapNoteScores[track].size()) - return TNS_NONE; - return m_TapNoteScores[track][row].tns; -} - -void NoteDataWithScoring::SetTapNoteScore(unsigned track, unsigned row, TapNoteScore tns) -{ - extend(m_TapNoteScores[track], TapNoteResult(), row); - TapNoteResult tnr = m_TapNoteScores[track][row]; - tnr.tns = tns; - m_TapNoteScores[track][row] = tnr; -} - -float NoteDataWithScoring::GetTapNoteOffset(unsigned track, unsigned row) const -{ - if(row >= m_TapNoteScores[track].size()) - return 0; - return m_TapNoteScores[track][row].fTapNoteOffset; -} - -void NoteDataWithScoring::SetTapNoteOffset(unsigned track, unsigned row, float offset) -{ - extend(m_TapNoteScores[track], TapNoteResult(), row); - TapNoteResult tnr = m_TapNoteScores[track][row]; - tnr.fTapNoteOffset = offset; - m_TapNoteScores[track][row] = tnr; -} - /* * (c) 2001-2004 Chris Danford, Glenn Maynard * All rights reserved. diff --git a/stepmania/src/NoteDataWithScoring.h b/stepmania/src/NoteDataWithScoring.h index 73760c6012..587b1ab5b0 100644 --- a/stepmania/src/NoteDataWithScoring.h +++ b/stepmania/src/NoteDataWithScoring.h @@ -17,9 +17,6 @@ struct RowTrack: public pair class NoteDataWithScoring : public NoteData { - // maintain this extra data in addition to the NoteData - vector m_TapNoteScores[MAX_NOTE_TRACKS]; - public: NoteDataWithScoring(); void Init(); @@ -30,19 +27,16 @@ public: int GetNumHoldNotesWithScore( HoldNoteScore hns, const float fStartBeat = 0, const float fEndBeat = -1 ) const; int GetSuccessfulMines( const float fStartBeat = 0, const float fEndBeat = -1 ) const; int GetSuccessfulHands( const float fStartBeat = 0, const float fEndBeat = -1 ) const; - 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); bool IsRowCompletelyJudged(unsigned row) const; TapNoteScore MinTapNoteScore(unsigned row) const; - int LastTapNoteScoreTrack(unsigned row) const; TapNoteScore LastTapNoteScore(unsigned row) const; void GetActualRadarValues( PlayerNumber pn, float fSongSeconds, RadarValues& out ) const; private: + int LastTapNoteScoreTrack(unsigned row) const; + float GetActualStreamRadarValue( float fSongSeconds, PlayerNumber pn ) const; float GetActualVoltageRadarValue( float fSongSeconds, PlayerNumber pn ) const; float GetActualAirRadarValue( float fSongSeconds, PlayerNumber pn ) const; diff --git a/stepmania/src/NoteTypes.h b/stepmania/src/NoteTypes.h index 35d4fd0d6a..2a8cb2b183 100644 --- a/stepmania/src/NoteTypes.h +++ b/stepmania/src/NoteTypes.h @@ -111,7 +111,7 @@ struct TapNote /* This data is only used and manipulated by NoteDataWithScoring. It's only in * here for the sake of efficiency. */ - + TapNoteResult result; }; const unsigned MAX_NUM_ATTACKS = 2*2*2; // 3 bits to hold the attack index currently diff --git a/stepmania/src/Player.cpp b/stepmania/src/Player.cpp index 76f0b8b802..28a025d54d 100644 --- a/stepmania/src/Player.cpp +++ b/stepmania/src/Player.cpp @@ -371,7 +371,7 @@ void Player::Update( float fDeltaTime ) const GameInput GameI = GAMESTATE->GetCurrentStyle()->StyleInputToGameInput( StyleI ); // if they got a bad score or haven't stepped on the corresponding tap yet - const TapNoteScore tns = m_NoteData.GetTapNoteScore( hn.iTrack, hn.iStartRow ); + const TapNoteScore tns = m_NoteData.GetTapNote( hn.iTrack, hn.iStartRow ).result.tns; const bool bSteppedOnTapNote = tns != TNS_NONE && tns != TNS_MISS; // did they step on the start of this hold? float fLife = hn.result.fLife; @@ -641,9 +641,10 @@ int Player::GetClosestNoteDirectional( int col, int iStartRow, int iMaxRowsAhead /* Is iRow the row we want? */ do { - if( m_NoteData.GetTapNote(col, iRow).type == TapNote::empty ) + TapNote tn = m_NoteData.GetTapNote(col, iRow); + if( tn.type == TapNote::empty ) break; - if( !bAllowGraded && m_NoteData.GetTapNoteScore(col, iRow) != TNS_NONE ) + if( !bAllowGraded && tn.result.tns != TNS_NONE ) break; return iRow; } while(0); @@ -947,10 +948,12 @@ void Player::Step( int col, RageTimer tm ) score, col, fStepSeconds, fCurrentMusicSeconds, fMusicSeconds, fNoteOffset ); // LOG->Trace("Note offset: %f (fSecondsFromPerfect = %f), Score: %i", fNoteOffset, fSecondsFromPerfect, score); - m_NoteData.SetTapNoteScore(col, iIndexOverlappingNote, score); + tn.result.tns = score; if( score != TNS_NONE ) - m_NoteData.SetTapNoteOffset(col, iIndexOverlappingNote, -fNoteOffset); + tn.result.fTapNoteOffset = -fNoteOffset; + + m_NoteData.SetTapNote( col, iIndexOverlappingNote, tn ); if( m_pPlayerState->m_PlayerController == PC_HUMAN && score >= TNS_GREAT ) @@ -1129,19 +1132,23 @@ void Player::UpdateTapNotesMissedOlderThan( float fMissIfOlderThanSeconds ) { /* XXX: cleaner to pick the things we do want to apply misses to, instead of * the things we don't? */ - switch( m_NoteData.GetTapNote(t, r).type ) + TapNote tn = m_NoteData.GetTapNote(t, r); + switch( tn.type ) { case TapNote::empty: case TapNote::attack: case TapNote::mine: continue; /* no note here */ } - if( m_NoteData.GetTapNoteScore(t, r) != TNS_NONE ) /* note here is already hit */ + if( tn.result.tns != TNS_NONE ) /* note here is already hit */ continue; - + + tn.result.tns = TNS_MISS; + // A normal note. Penalize for not stepping on it. MissedNoteOnThisRow = true; - m_NoteData.SetTapNoteScore( t, r, TNS_MISS ); + + m_NoteData.SetTapNote( t, r, tn ); if( m_pPlayerStageStats ) { @@ -1174,9 +1181,9 @@ void Player::CrossedRow( int iNoteRow ) { for( int t=0; t