From ce407f819fafa6cd2d27c8ad56080a0ad804df14 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Mon, 15 Jan 2007 06:35:09 +0000 Subject: [PATCH] track fOverlappedTime for hold notes --- stepmania/src/NoteTypes.h | 6 +++++- stepmania/src/Player.cpp | 9 +++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/stepmania/src/NoteTypes.h b/stepmania/src/NoteTypes.h index 5d945c97eb..bbac22924f 100644 --- a/stepmania/src/NoteTypes.h +++ b/stepmania/src/NoteTypes.h @@ -27,7 +27,7 @@ struct TapNoteResult struct HoldNoteResult { - HoldNoteResult() : hns(HNS_None), fLife(1.f), iLastHeldRow(0), bHeld(false), bActive(false) { } + HoldNoteResult() : hns(HNS_None), fLife(1.f), fOverlappedTime(0), iLastHeldRow(0), bHeld(false), bActive(false) { } float GetLastHeldBeat() const; HoldNoteScore hns; @@ -38,6 +38,10 @@ struct HoldNoteResult * If the life is > 0.0 when the HoldNote ends, then m_HoldScore becomes HNS_Held. */ float fLife; + /* The number of seconds the hold note has overlapped the current beat, or 0 if it + * doesn't overlap. */ + float fOverlappedTime; + /* Last index where fLife was greater than 0. If the tap was missed, this will * be the first index of the hold. */ int iLastHeldRow; diff --git a/stepmania/src/Player.cpp b/stepmania/src/Player.cpp index 51bcfcc89b..08370e6b47 100644 --- a/stepmania/src/Player.cpp +++ b/stepmania/src/Player.cpp @@ -663,11 +663,18 @@ void Player::Update( float fDeltaTime ) if( tn.type != TapNote::hold_head ) continue; int iRow = begin->first; + int iEndRow = iRow + tn.iDuration; // set hold flags so NoteField can do intelligent drawing tn.HoldResult.bHeld = false; tn.HoldResult.bActive = false; + // If the song beat is in the range of this hold: + if( iRow <= iSongRow && iRow <= iEndRow ) + tn.HoldResult.fOverlappedTime += fDeltaTime; + else + tn.HoldResult.fOverlappedTime = 0; + HoldNoteScore hns = tn.HoldResult.hns; if( hns != HNS_None ) // if this HoldNote already has a result continue; // we don't need to update the logic for this one @@ -693,8 +700,6 @@ void Player::Update( float fDeltaTime ) bIsHoldingButton = INPUTMAPPER->IsBeingPressed( GameI, m_pPlayerState->m_mp ); } - int iEndRow = iRow + tn.iDuration; - float fLife = tn.HoldResult.fLife; if( bSteppedOnTapNote && fLife != 0 ) {