From 064d3f22304c46d8994ed49ac83ebf6a7211ffe1 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 12 Oct 2002 22:04:44 +0000 Subject: [PATCH] Pass the initial tap note score to ChangeLife for hold notes; it's needed to handle Oni penalties correctly. (not actually doing that yet) --- stepmania/src/LifeMeter.h | 6 +++++- stepmania/src/LifeMeterBar.cpp | 2 +- stepmania/src/LifeMeterBar.h | 2 +- stepmania/src/LifeMeterBattery.cpp | 2 +- stepmania/src/LifeMeterBattery.h | 2 +- stepmania/src/Player.cpp | 25 +++++++++++++++---------- 6 files changed, 24 insertions(+), 15 deletions(-) diff --git a/stepmania/src/LifeMeter.h b/stepmania/src/LifeMeter.h index bb4cc11176..8748c444fb 100644 --- a/stepmania/src/LifeMeter.h +++ b/stepmania/src/LifeMeter.h @@ -28,8 +28,12 @@ public: virtual void Update( float fDeltaTime ) { ActorFrame::Update(fDeltaTime); }; virtual void SongEnded() {}; + /* Change life after receiving a tap note grade. This *is* called for + * the head of hold notes. */ virtual void ChangeLife( TapNoteScore score ) = 0; - virtual void ChangeLife( HoldNoteScore score ) = 0; + /* Change life after receiving a hold note grade. tscore is the score + * received for the initial tap note. */ + virtual void ChangeLife( HoldNoteScore score, TapNoteScore tscore ) = 0; virtual void OnDancePointsChange() = 0; // look in GAMESTATE and update the display virtual bool IsInDanger() = 0; virtual bool IsHot() = 0; diff --git a/stepmania/src/LifeMeterBar.cpp b/stepmania/src/LifeMeterBar.cpp index f75da86e27..8e0aa2ca71 100644 --- a/stepmania/src/LifeMeterBar.cpp +++ b/stepmania/src/LifeMeterBar.cpp @@ -320,7 +320,7 @@ void LifeMeterBar::ChangeLife( TapNoteScore score ) m_fLifeVelocity += fDeltaLife; } -void LifeMeterBar::ChangeLife( HoldNoteScore score ) +void LifeMeterBar::ChangeLife( HoldNoteScore score, TapNoteScore tscore ) { } diff --git a/stepmania/src/LifeMeterBar.h b/stepmania/src/LifeMeterBar.h index fd31b0b6e8..a930873ee0 100644 --- a/stepmania/src/LifeMeterBar.h +++ b/stepmania/src/LifeMeterBar.h @@ -28,7 +28,7 @@ public: virtual void DrawPrimitives(); virtual void ChangeLife( TapNoteScore score ); - virtual void ChangeLife( HoldNoteScore score ); + virtual void ChangeLife( HoldNoteScore score, TapNoteScore tscore ); virtual void AfterLifeChanged(); virtual void OnDancePointsChange() {}; // this life meter doesn't care virtual bool IsInDanger(); diff --git a/stepmania/src/LifeMeterBattery.cpp b/stepmania/src/LifeMeterBattery.cpp index 79b1479b74..c3356c6672 100644 --- a/stepmania/src/LifeMeterBattery.cpp +++ b/stepmania/src/LifeMeterBattery.cpp @@ -126,7 +126,7 @@ void LifeMeterBattery::ChangeLife( TapNoteScore score ) m_bFailedEarlier = true; } -void LifeMeterBattery::ChangeLife( HoldNoteScore score ) +void LifeMeterBattery::ChangeLife( HoldNoteScore score, TapNoteScore tscore ) { switch( score ) { diff --git a/stepmania/src/LifeMeterBattery.h b/stepmania/src/LifeMeterBattery.h index 954b17f0fd..a59f41bec7 100644 --- a/stepmania/src/LifeMeterBattery.h +++ b/stepmania/src/LifeMeterBattery.h @@ -28,7 +28,7 @@ public: virtual void SongEnded(); virtual void ChangeLife( TapNoteScore score ); - virtual void ChangeLife( HoldNoteScore score ); + virtual void ChangeLife( HoldNoteScore score, TapNoteScore tscore ); virtual void OnDancePointsChange(); // look in GAMESTATE and update the display virtual bool IsInDanger(); virtual bool IsHot(); diff --git a/stepmania/src/Player.cpp b/stepmania/src/Player.cpp index 7f20ced14a..4b392f0ade 100644 --- a/stepmania/src/Player.cpp +++ b/stepmania/src/Player.cpp @@ -212,12 +212,13 @@ void Player::Update( float fDeltaTime ) const StyleInput StyleI( m_PlayerNumber, hn.m_iTrack ); const GameInput GameI = GAMESTATE->GetCurrentStyleDef()->StyleInputToGameInput( StyleI ); + // if they got a bad score or haven't stepped on the corresponding tap yet + const TapNoteScore tns = m_TapNoteScores[hn.m_iTrack][iHoldStartIndex]; + if( hn.m_fStartBeat < fSongBeat && fSongBeat < hn.m_fEndBeat ) // if the song beat is in the range of this hold { - const bool bIsHoldingButton = INPUTMAPPER->IsButtonDown( GameI ) || PREFSMAN->m_bAutoPlay || GAMESTATE->m_bDemonstration; - // if they got a bad score or haven't stepped on the corresponding tap yet - const TapNoteScore tns = m_TapNoteScores[hn.m_iTrack][iHoldStartIndex]; const bool bSteppedOnTapNote = tns != TNS_NONE && tns != TNS_MISS; // did they step on the start of this hold? + const bool bIsHoldingButton = INPUTMAPPER->IsButtonDown( GameI ) || PREFSMAN->m_bAutoPlay || GAMESTATE->m_bDemonstration; m_NoteField.m_bIsHoldingHoldNote[i] = bIsHoldingButton && bSteppedOnTapNote; // set host flag so NoteField can do intelligent drawing @@ -250,7 +251,7 @@ void Player::Update( float fDeltaTime ) if( fLife == 0 ) // the player has not pressed the button for a long time! { hns = HNS_NG; - HandleNoteScore( hns ); + HandleNoteScore( hns, tns ); m_HoldJudgement[hn.m_iTrack].SetHoldJudgement( HNS_NG ); m_NoteField.m_HoldNoteScores[i] = HNS_NG; // update the NoteField display } @@ -261,7 +262,7 @@ void Player::Update( float fDeltaTime ) // At this point fLife > 0, or else we would have marked it NG above fLife = 1; hns = HNS_OK; - HandleNoteScore( hns ); + HandleNoteScore( hns, tns ); m_GhostArrowRow.TapNote( StyleI.col, TNS_PERFECT, true ); // bright ghost flash m_HoldJudgement[hn.m_iTrack].SetHoldJudgement( HNS_OK ); m_NoteField.m_fHoldNoteLife[i] = fLife; // update the NoteField display @@ -665,7 +666,7 @@ void Player::HandleNoteScore( TapNoteScore score, int iNumTapsInRow ) m_pScore->SetScore( fScore ); } -void Player::HandleNoteScore( HoldNoteScore score ) +void Player::HandleNoteScore( HoldNoteScore score, TapNoteScore TapNoteScore ) { // don't accumulate points if AutoPlay is on. if( PREFSMAN->m_bAutoPlay && !GAMESTATE->m_bDemonstration ) @@ -675,10 +676,14 @@ void Player::HandleNoteScore( HoldNoteScore score ) GAMESTATE->m_iActualDancePoints[m_PlayerNumber] += HoldNoteScoreToDancePoints( score ); GAMESTATE->m_HoldNoteScores[m_PlayerNumber][score] ++; - if( m_pLifeMeter ) - m_pLifeMeter->ChangeLife( score ); - if( m_pLifeMeter ) - m_pLifeMeter->OnDancePointsChange(); // refresh Oni life meter + if( m_pLifeMeter ) { + if( score == HNS_NG ) { + m_pLifeMeter->ChangeLife( score, TapNoteScore ); + + // refresh Oni life meter + m_pLifeMeter->OnDancePointsChange(); + } + } } float Player::GetMaxBeatDifference()