diff --git a/stepmania/src/NoteDataWithScoring.cpp b/stepmania/src/NoteDataWithScoring.cpp index 6e1a365ffd..9254ca3364 100644 --- a/stepmania/src/NoteDataWithScoring.cpp +++ b/stepmania/src/NoteDataWithScoring.cpp @@ -1,23 +1,27 @@ #include "global.h" #include "NoteDataWithScoring.h" +#include "NoteData.h" #include "StageStats.h" -int NoteDataWithScoring::GetNumTapNotesWithScore( TapNoteScore tns, const float fStartBeat, float fEndBeat ) const +namespace +{ + +int GetNumTapNotesWithScore( const NoteData &in, TapNoteScore tns, const float fStartBeat = 0, float fEndBeat = -1 ) { int iNumSuccessfulTapNotes = 0; if( fEndBeat == -1 ) - fEndBeat = GetLastBeat(); + fEndBeat = in.GetLastBeat(); int iStartIndex = BeatToNoteRow( fStartBeat ); int iEndIndex = BeatToNoteRow( fEndBeat ); - iEndIndex = min( iEndIndex, GetLastRow() ); + iEndIndex = min( iEndIndex, in.GetLastRow() ); - for( int t=0; t= tns ) iNumSuccessfulTapNotes++; } @@ -26,25 +30,25 @@ int NoteDataWithScoring::GetNumTapNotesWithScore( TapNoteScore tns, const float return iNumSuccessfulTapNotes; } -int NoteDataWithScoring::GetNumNWithScore( TapNoteScore tns, int MinTaps, const float fStartBeat, float fEndBeat ) const +int GetNumNWithScore( const NoteData &in, TapNoteScore tns, int MinTaps, const float fStartBeat = 0, float fEndBeat = -1 ) { if( fEndBeat == -1 ) - fEndBeat = GetLastBeat(); + fEndBeat = in.GetLastBeat(); int iStartIndex = BeatToNoteRow( fStartBeat ); int iEndIndex = BeatToNoteRow( fEndBeat ); iStartIndex = max( iStartIndex, 0 ); - iEndIndex = min( iEndIndex, GetLastRow() ); + iEndIndex = min( iEndIndex, in.GetLastRow() ); int iNumSuccessfulDoubles = 0; for( int i=iStartIndex; i<=iEndIndex; i++ ) { int iNumNotesThisIndex = 0; TapNoteScore minTapNoteScore = TNS_MARVELOUS; - for( int t=0; t hn.iStartRow || hn.iEndRow > iEndIndex ) continue; if( hn.result.hns == hns ) @@ -81,23 +85,23 @@ int NoteDataWithScoring::GetNumHoldNotesWithScore( HoldNoteScore hns, const floa return iNumSuccessfulHolds; } -int NoteDataWithScoring::GetSuccessfulMines( float fStartBeat, float fEndBeat ) const +int GetSuccessfulMines( const NoteData &in, float fStartBeat = 0, float fEndBeat = -1 ) { if( fEndBeat == -1 ) - fEndBeat = GetLastBeat(); + fEndBeat = in.GetLastBeat(); int iStartIndex = BeatToNoteRow( fStartBeat ); int iEndIndex = BeatToNoteRow( fEndBeat ); iStartIndex = max( iStartIndex, 0 ); - iEndIndex = min( iEndIndex, GetLastRow() ); + iEndIndex = min( iEndIndex, in.GetLastRow() ); int iNumSuccessfulMinesNotes = 0; for( int i=iStartIndex; i<=iEndIndex; i++ ) { - for( int t=0; t= TNS_MISS; -} - /* 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 +int LastTapNoteScoreTrack( const NoteData &in, unsigned iRow ) { float scoretime = -9999; int best_track = -1; - for( int t=0; t= TNS_MISS; } /* From aaroninjapan.com (http://www.aaroninjapan.com/ddr2.html) @@ -238,40 +245,20 @@ TapNoteScore NoteDataWithScoring::LastTapNoteScore(unsigned row) const * No idea what it actually could be, though. */ -void NoteDataWithScoring::GetActualRadarValues( PlayerNumber pn, float fSongSeconds, RadarValues& out ) const +namespace { - // The for loop and the assert are used to ensure that all fields of - // RadarValue get set in here. - FOREACH_RadarCategory( rc ) - { - switch( rc ) - { - case RADAR_STREAM: out[rc] = GetActualStreamRadarValue( fSongSeconds, pn ); break; - case RADAR_VOLTAGE: out[rc] = GetActualVoltageRadarValue( fSongSeconds, pn ); break; - case RADAR_AIR: out[rc] = GetActualAirRadarValue( fSongSeconds, pn ); break; - case RADAR_FREEZE: out[rc] = GetActualFreezeRadarValue( fSongSeconds, pn ); break; - case RADAR_CHAOS: out[rc] = GetActualChaosRadarValue( fSongSeconds, pn ); break; - case RADAR_NUM_TAPS_AND_HOLDS: out[rc] = (float) GetNumNWithScore( TNS_GOOD, 1 ); break; - case RADAR_NUM_JUMPS: out[rc] = (float) GetNumNWithScore( TNS_GOOD, 2 ); break; - case RADAR_NUM_HOLDS: out[rc] = (float) GetNumHoldNotesWithScore( HNS_OK ); break; - case RADAR_NUM_MINES: out[rc] = (float) GetSuccessfulMines(); break; - case RADAR_NUM_HANDS: out[rc] = (float) GetSuccessfulHands(); break; - default: ASSERT(0); - } - } -} -float NoteDataWithScoring::GetActualStreamRadarValue( float fSongSeconds, PlayerNumber pn ) const +float GetActualStreamRadarValue( const NoteData &in, float fSongSeconds, PlayerNumber pn ) { - int iTotalSteps = GetNumTapNotes(); + int iTotalSteps = in.GetNumTapNotes(); if( iTotalSteps == 0 ) return 1.0f; - const int Perfects = GetNumTapNotesWithScore(TNS_PERFECT); + const int Perfects = GetNumTapNotesWithScore( in, TNS_PERFECT); return clamp( float(Perfects)/iTotalSteps, 0.0f, 1.0f ); } -float NoteDataWithScoring::GetActualVoltageRadarValue( float fSongSeconds, PlayerNumber pn ) const +float GetActualVoltageRadarValue( const NoteData &in, float fSongSeconds, PlayerNumber pn ) { /* g_CurStageStats.iMaxCombo is unrelated to GetNumTapNotes: m_bComboContinuesBetweenSongs * might be on, and the way combo is counted varies depending on the mode and score @@ -282,18 +269,18 @@ float NoteDataWithScoring::GetActualVoltageRadarValue( float fSongSeconds, Playe return clamp( fComboPercent, 0.0f, 1.0f ); } -float NoteDataWithScoring::GetActualAirRadarValue( float fSongSeconds, PlayerNumber pn ) const +float GetActualAirRadarValue( const NoteData &in, float fSongSeconds, PlayerNumber pn ) { - const int iTotalDoubles = GetNumDoubles(); + const int iTotalDoubles = in.GetNumDoubles(); if( iTotalDoubles == 0 ) return 1.0f; // no jumps in song // number of doubles - const int iNumDoubles = GetNumNWithScore( TNS_PERFECT, 2 ); + const int iNumDoubles = GetNumNWithScore( in, TNS_PERFECT, 2 ); return clamp( (float)iNumDoubles / iTotalDoubles, 0.0f, 1.0f ); } -float NoteDataWithScoring::GetActualChaosRadarValue( float fSongSeconds, PlayerNumber pn ) const +float GetActualChaosRadarValue( const NoteData &in, float fSongSeconds, PlayerNumber pn ) { const int iPossibleDP = g_CurStageStats.m_player[pn].iPossibleDancePoints; if ( iPossibleDP == 0 ) @@ -303,17 +290,43 @@ float NoteDataWithScoring::GetActualChaosRadarValue( float fSongSeconds, PlayerN return clamp( float(ActualDP)/iPossibleDP, 0.0f, 1.0f ); } -float NoteDataWithScoring::GetActualFreezeRadarValue( float fSongSeconds, PlayerNumber pn ) const +float GetActualFreezeRadarValue( const NoteData &in, float fSongSeconds, PlayerNumber pn ) { // number of hold steps - const int iTotalHolds = GetNumHoldNotes(); + const int iTotalHolds = in.GetNumHoldNotes(); if( iTotalHolds == 0 ) return 1.0f; - const int ActualHolds = GetNumHoldNotesWithScore(HNS_OK); + const int ActualHolds = GetNumHoldNotesWithScore( in, HNS_OK ); return clamp( float(ActualHolds) / iTotalHolds, 0.0f, 1.0f ); } +} + + +void NoteDataWithScoring::GetActualRadarValues( const NoteData &in, PlayerNumber pn, float fSongSeconds, RadarValues& out ) +{ + // The for loop and the assert are used to ensure that all fields of + // RadarValue get set in here. + FOREACH_RadarCategory( rc ) + { + switch( rc ) + { + case RADAR_STREAM: out[rc] = GetActualStreamRadarValue( in, fSongSeconds, pn ); break; + case RADAR_VOLTAGE: out[rc] = GetActualVoltageRadarValue( in, fSongSeconds, pn ); break; + case RADAR_AIR: out[rc] = GetActualAirRadarValue( in, fSongSeconds, pn ); break; + case RADAR_FREEZE: out[rc] = GetActualFreezeRadarValue( in, fSongSeconds, pn ); break; + case RADAR_CHAOS: out[rc] = GetActualChaosRadarValue( in, fSongSeconds, pn ); break; + case RADAR_NUM_TAPS_AND_HOLDS: out[rc] = (float) GetNumNWithScore( in, TNS_GOOD, 1 ); break; + case RADAR_NUM_JUMPS: out[rc] = (float) GetNumNWithScore( in, TNS_GOOD, 2 ); break; + case RADAR_NUM_HOLDS: out[rc] = (float) GetNumHoldNotesWithScore( in, HNS_OK ); break; + case RADAR_NUM_MINES: out[rc] = (float) GetSuccessfulMines( in ); break; + case RADAR_NUM_HANDS: out[rc] = (float) GetSuccessfulHands( in ); break; + default: ASSERT(0); + } + } +} + /* * (c) 2001-2004 Chris Danford, Glenn Maynard * All rights reserved. diff --git a/stepmania/src/NoteDataWithScoring.h b/stepmania/src/NoteDataWithScoring.h index 1ced504e84..34033ecfe9 100644 --- a/stepmania/src/NoteDataWithScoring.h +++ b/stepmania/src/NoteDataWithScoring.h @@ -4,36 +4,18 @@ #define NOTEDATAWITHSCORING_H #include "GameConstantsAndTypes.h" -#include "NoteData.h" #include "PlayerNumber.h" #include struct RadarValues; - -class NoteDataWithScoring : public NoteData +class NoteData; +namespace NoteDataWithScoring { -public: - bool IsRowCompletelyJudged( unsigned iRow ) const; - TapNoteScore MinTapNoteScore( unsigned iRow ) const; - TapNoteScore LastTapNoteScore( unsigned iRow ) const; + bool IsRowCompletelyJudged( const NoteData &in, unsigned iRow ); + TapNoteScore MinTapNoteScore( const NoteData &in, unsigned iRow ); + TapNoteScore LastTapNoteScore( const NoteData &in, unsigned iRow ); - void GetActualRadarValues( PlayerNumber pn, float fSongSeconds, RadarValues& out ) const; - -private: - int LastTapNoteScoreTrack( unsigned iRow ) const; - - // statistics - int GetNumTapNotesWithScore( TapNoteScore tns, const float fStartBeat = 0, const float fEndBeat = -1 ) const; - int GetNumNWithScore( TapNoteScore tns, int iMinTaps, const float fStartBeat = 0, const float fEndBeat = -1 ) const; - 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; - - float GetActualStreamRadarValue( float fSongSeconds, PlayerNumber pn ) const; - float GetActualVoltageRadarValue( float fSongSeconds, PlayerNumber pn ) const; - float GetActualAirRadarValue( float fSongSeconds, PlayerNumber pn ) const; - float GetActualFreezeRadarValue( float fSongSeconds, PlayerNumber pn ) const; - float GetActualChaosRadarValue( float fSongSeconds, PlayerNumber pn ) const; + void GetActualRadarValues( const NoteData &in, PlayerNumber pn, float fSongSeconds, RadarValues& out ); }; #endif diff --git a/stepmania/src/Player.cpp b/stepmania/src/Player.cpp index 963ddf6223..1dc869e5c8 100644 --- a/stepmania/src/Player.cpp +++ b/stepmania/src/Player.cpp @@ -945,7 +945,7 @@ void Player::Step( int col, RageTimer tm ) case TapNote::tap: case TapNote::hold_head: // don't the row if this note is a mine or tap attack - if( m_NoteData.IsRowCompletelyJudged(iIndexOverlappingNote) ) + if( NoteDataWithScoring::IsRowCompletelyJudged( m_NoteData, iIndexOverlappingNote ) ) OnRowCompletelyJudged( iIndexOverlappingNote ); } @@ -1026,8 +1026,8 @@ void Player::OnRowCompletelyJudged( int iIndexThatWasSteppedOn ) * the 2nd step of the jump, it sets another column's timer then AND's the jump * columns with the "was pressed recently" columns to see whether or not you hit * all the columns of the jump. -Chris */ -// TapNoteScore score = MinTapNoteScore(iIndexThatWasSteppedOn); - TapNoteScore score = m_NoteData.LastTapNoteScore( iIndexThatWasSteppedOn ); +// TapNoteScore score = NoteDataWithScoring::MinTapNoteScore( m_NoteData, iIndexThatWasSteppedOn ); + TapNoteScore score = NoteDataWithScoring::LastTapNoteScore( m_NoteData, iIndexThatWasSteppedOn ); ASSERT(score != TNS_NONE); ASSERT(score != TNS_HIT_MINE); @@ -1229,7 +1229,7 @@ void Player::RandomizeNotes( int iNoteRow ) void Player::HandleTapRowScore( unsigned row ) { - TapNoteScore scoreOfLastTap = m_NoteData.LastTapNoteScore(row); + TapNoteScore scoreOfLastTap = NoteDataWithScoring::LastTapNoteScore( m_NoteData, row ); int iNumTapsInRow = m_NoteData.GetNumTracksWithTapOrHoldHead(row); ASSERT(iNumTapsInRow > 0); diff --git a/stepmania/src/Player.h b/stepmania/src/Player.h index 936507d0d6..bda0728d87 100644 --- a/stepmania/src/Player.h +++ b/stepmania/src/Player.h @@ -56,7 +56,7 @@ public: void CacheAllUsedNoteSkins( bool bDeleteUnused ) { m_pNoteField->CacheAllUsedNoteSkins(bDeleteUnused); } - NoteDataWithScoring m_NoteData; + NoteData m_NoteData; protected: void UpdateTapNotesMissedOlderThan( float fMissIfOlderThanThisBeat ); diff --git a/stepmania/src/ScreenEdit.h b/stepmania/src/ScreenEdit.h index 2b64bc7b40..c301ec9bd8 100644 --- a/stepmania/src/ScreenEdit.h +++ b/stepmania/src/ScreenEdit.h @@ -151,7 +151,7 @@ protected: Steps* m_pSteps; NoteField m_NoteFieldEdit; - NoteDataWithScoring m_NoteDataEdit; + NoteData m_NoteDataEdit; SnapDisplay m_SnapDisplay; AutoActor m_sprOverlay; @@ -177,7 +177,7 @@ protected: // for MODE_RECORD NoteField m_NoteFieldRecord; - NoteDataWithScoring m_NoteDataRecord; + NoteData m_NoteDataRecord; // for MODE_PLAY void SetupCourseAttacks(); diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index 78bb6974c3..f5d467950b 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -2014,7 +2014,7 @@ void ScreenGameplay::SongFinished() NoteDataUtil::GetRadarValues( m_Player[p].m_NoteData, GAMESTATE->m_pCurSong->m_fMusicLengthSeconds, v ); g_CurStageStats.m_player[p].radarPossible += v; - m_Player[p].m_NoteData.GetActualRadarValues( p, GAMESTATE->m_pCurSong->m_fMusicLengthSeconds, v ); + NoteDataWithScoring::GetActualRadarValues( m_Player[p].m_NoteData, p, GAMESTATE->m_pCurSong->m_fMusicLengthSeconds, v ); g_CurStageStats.m_player[p].radarActual += v; }