diff --git a/stepmania/src/NoteTypes.h b/stepmania/src/NoteTypes.h index b8e3b442a6..5d945c97eb 100644 --- a/stepmania/src/NoteTypes.h +++ b/stepmania/src/NoteTypes.h @@ -36,13 +36,13 @@ struct HoldNoteResult * 0.0 means this HoldNote is dead * When this value hits 0.0 for the first time, m_HoldScore becomes HNS_LetGo. * If the life is > 0.0 when the HoldNote ends, then m_HoldScore becomes HNS_Held. */ - float fLife; + float fLife; /* Last index where fLife was greater than 0. If the tap was missed, this will * be the first index of the hold. */ int iLastHeldRow; - bool bHeld; - bool bActive; + bool bHeld; // Was button held during last update? + bool bActive; // Is life > 0 && overlaps current beat // XML XNode* CreateNode() const; diff --git a/stepmania/src/Player.cpp b/stepmania/src/Player.cpp index 2109a74700..4712e849c7 100644 --- a/stepmania/src/Player.cpp +++ b/stepmania/src/Player.cpp @@ -741,6 +741,16 @@ void Player::Update( float fDeltaTime ) } } + // TODO: Cap the active time passed to the score keeper to the actual start time and end time of the hold. + if( tn.HoldResult.bActive ) + { + float fSecondsActiveSinceLastUpdate = fDeltaTime * GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate; + if( m_pPrimaryScoreKeeper ) + m_pPrimaryScoreKeeper->HandleHoldActiveSeconds( fSecondsActiveSinceLastUpdate ); + if( m_pSecondaryScoreKeeper ) + m_pSecondaryScoreKeeper->HandleHoldActiveSeconds( fSecondsActiveSinceLastUpdate ); + } + /* check for LetGo. If the head was missed completely, don't count an LetGo. */ if( bSteppedOnTapNote && fLife == 0 ) // the player has not pressed the button for a long time! hns = HNS_LetGo; diff --git a/stepmania/src/ScoreKeeper.h b/stepmania/src/ScoreKeeper.h index 40422fcbde..f28f1d0e94 100644 --- a/stepmania/src/ScoreKeeper.h +++ b/stepmania/src/ScoreKeeper.h @@ -55,6 +55,7 @@ public: virtual void HandleTapScore( const TapNote &tn ) = 0; virtual void HandleTapRowScore( const NoteData &nd, int iRow ) = 0; virtual void HandleHoldScore( const TapNote &tn ) = 0; + virtual void HandleHoldActiveSeconds( float fMusicSecondsHeld ) = 0; virtual void HandleTapScoreNone() = 0; protected: diff --git a/stepmania/src/ScoreKeeperGuitar.cpp b/stepmania/src/ScoreKeeperGuitar.cpp index df280f6ec2..125746e339 100644 --- a/stepmania/src/ScoreKeeperGuitar.cpp +++ b/stepmania/src/ScoreKeeperGuitar.cpp @@ -7,6 +7,7 @@ ScoreKeeperGuitar::ScoreKeeperGuitar( PlayerState *pPlayerState, PlayerStageStats *pPlayerStageStats ) : ScoreKeeperNormal(pPlayerState, pPlayerStageStats) { + m_fMusicSecondsHeldRemainder = 0; } void ScoreKeeperGuitar::AddTapScore( TapNoteScore tns ) @@ -15,10 +16,26 @@ void ScoreKeeperGuitar::AddTapScore( TapNoteScore tns ) void ScoreKeeperGuitar::AddHoldScore( HoldNoteScore hns ) { - if( hns == HNS_Held ) - AddTapScore( TNS_W1 ); - else if ( hns == HNS_LetGo ) - AddTapScore( TNS_W4 ); // required for subtractive score display to work properly +} + +void ScoreKeeperGuitar::HandleHoldActiveSeconds( float fMusicSecondsHeld ) +{ + int &iScore = m_pPlayerStageStats->m_iScore; + int &iCurMaxScore = m_pPlayerStageStats->m_iCurMaxScore; + + const float fPointsPerSecond = 25; + const float fMusicSecondsHeldPlusRemainer = m_fMusicSecondsHeldRemainder + fMusicSecondsHeld; + const float fPoints = fMusicSecondsHeldPlusRemainer * fPointsPerSecond; + const int iPoints = (int)floorf( fPoints ); + const float fPointsRemainder = fPoints - iPoints; + m_fMusicSecondsHeldRemainder = (fPointsRemainder) / fPointsPerSecond; + + if( iPoints != 0 ) + { + iScore += iPoints; + iCurMaxScore += iPoints; + MESSAGEMAN->Broadcast( Message_ScoreChangedP1 ); + } } void ScoreKeeperGuitar::AddTapRowScore( TapNoteScore tns, const NoteData &nd, int iRow ) diff --git a/stepmania/src/ScoreKeeperGuitar.h b/stepmania/src/ScoreKeeperGuitar.h index 533aaf97bd..035f3cc2a0 100644 --- a/stepmania/src/ScoreKeeperGuitar.h +++ b/stepmania/src/ScoreKeeperGuitar.h @@ -12,7 +12,10 @@ public: ScoreKeeperGuitar( PlayerState *pPlayerState, PlayerStageStats *pPlayerStageStats ); virtual void AddTapScore( TapNoteScore score ); void AddHoldScore( HoldNoteScore hns ); + void HandleHoldActiveSeconds( float fMusicSecondsHeld ); virtual void AddTapRowScore( TapNoteScore score, const NoteData &nd, int iRow ); +protected: + float m_fMusicSecondsHeldRemainder; // seconds from a hold note that have not yet been counted toward CurScore }; #endif diff --git a/stepmania/src/ScoreKeeperNormal.h b/stepmania/src/ScoreKeeperNormal.h index 5a6f57db22..c920360761 100644 --- a/stepmania/src/ScoreKeeperNormal.h +++ b/stepmania/src/ScoreKeeperNormal.h @@ -58,6 +58,7 @@ public: void HandleTapScore( const TapNote &tn ); void HandleTapRowScore( const NoteData &nd, int iRow ); void HandleHoldScore( const TapNote &tn ); + void HandleHoldActiveSeconds( float fMusicSecondsHeld ) {}; // This must be calculated using only cached radar values so that we can // do it quickly. diff --git a/stepmania/src/ScoreKeeperRave.h b/stepmania/src/ScoreKeeperRave.h index 558d07731e..026ad2db93 100644 --- a/stepmania/src/ScoreKeeperRave.h +++ b/stepmania/src/ScoreKeeperRave.h @@ -15,6 +15,7 @@ public: void HandleTapScore( const TapNote &tn ); void HandleTapRowScore( const NoteData &nd, int iRow ); void HandleHoldScore( const TapNote &tn ); + void HandleHoldActiveSeconds( float fMusicSecondsHeld ) {} void HandleTapScoreNone(); protected: