diff --git a/stepmania/src/ComboGraph.cpp b/stepmania/src/ComboGraph.cpp index 64dd4eda5d..ce8d27b488 100644 --- a/stepmania/src/ComboGraph.cpp +++ b/stepmania/src/ComboGraph.cpp @@ -17,7 +17,7 @@ void ComboGraph::Load( const CString& sScreen, const CString& sElement, const St ASSERT( m_SubActors.size() == 0 ); const float fFirstSecond = 0; - const float fLastSecond = s.GetTotalPossibleMusicLengthSeconds(); + const float fLastSecond = s.GetTotalPossibleStepsSeconds(); /* Find the largest combo. */ int MaxComboSize = 0; diff --git a/stepmania/src/GraphDisplay.cpp b/stepmania/src/GraphDisplay.cpp index 3b31e86ebb..4a2ca52152 100644 --- a/stepmania/src/GraphDisplay.cpp +++ b/stepmania/src/GraphDisplay.cpp @@ -43,7 +43,7 @@ void GraphDisplay::LoadFromStageStats( const StageStats &ss, const PlayerStageSt { memcpy( m_LastValues, m_CurValues, sizeof(m_CurValues) ); m_Position = 0; - pss.GetLifeRecord( m_DestValues, VALUE_RESOLUTION, ss.GetTotalPossibleMusicLengthSeconds() ); + pss.GetLifeRecord( m_DestValues, VALUE_RESOLUTION, ss.GetTotalPossibleStepsSeconds() ); for( unsigned i=0; im_CurStageStats.fGameplaySeconds); + float fSecs = m_fLifeTotalGainedSeconds - (m_fLifeTotalLostSeconds + STATSMAN->m_CurStageStats.fStepsSeconds); return fSecs; } diff --git a/stepmania/src/Player.cpp b/stepmania/src/Player.cpp index 284adc28ad..481b9e8b84 100644 --- a/stepmania/src/Player.cpp +++ b/stepmania/src/Player.cpp @@ -1458,7 +1458,7 @@ void Player::HandleTapRowScore( unsigned row ) * GAMESTATE->m_fMusicSeconds. Use fGameplaySeconds instead. */ if( m_pPlayerStageStats ) - m_pPlayerStageStats->UpdateComboList( STATSMAN->m_CurStageStats.fGameplaySeconds, false ); + m_pPlayerStageStats->UpdateComboList( STATSMAN->m_CurStageStats.fStepsSeconds, false ); // TODO: Remove use of PlayerNumber. PlayerNumber pn = m_pPlayerState->m_PlayerNumber; @@ -1476,7 +1476,7 @@ void Player::HandleTapRowScore( unsigned row ) } if( life != -1 ) if( m_pPlayerStageStats ) - m_pPlayerStageStats->SetLifeRecordAt( life, STATSMAN->m_CurStageStats.fGameplaySeconds ); + m_pPlayerStageStats->SetLifeRecordAt( life, STATSMAN->m_CurStageStats.fStepsSeconds ); if( m_pScoreDisplay ) { diff --git a/stepmania/src/PlayerStageStats.cpp b/stepmania/src/PlayerStageStats.cpp index 6703d8101b..252ff8abe2 100644 --- a/stepmania/src/PlayerStageStats.cpp +++ b/stepmania/src/PlayerStageStats.cpp @@ -229,21 +229,21 @@ float PlayerStageStats::GetCurMaxPercentDancePoints() const return fCurMaxPercentDancePoints; } -void PlayerStageStats::SetLifeRecordAt( float fLife, float fSecond ) +void PlayerStageStats::SetLifeRecordAt( float fLife, float fStepsSecond ) { // Don't save life stats in endless courses, or could run OOM in a few hours. if( GAMESTATE->m_pCurCourse && GAMESTATE->m_pCurCourse->IsEndless() ) return; - if( fSecond < 0 ) + if( fStepsSecond < 0 ) return; - fFirstSecond = min( fSecond, fFirstSecond ); - fLastSecond = max( fSecond, fLastSecond ); + fFirstSecond = min( fStepsSecond, fFirstSecond ); + fLastSecond = max( fStepsSecond, fLastSecond ); //LOG->Trace( "fLastSecond = %f", fLastSecond ); // fSecond will always be greater than any value already in the map. - fLifeRecord[fSecond] = fLife; + fLifeRecord[fStepsSecond] = fLife; // // Memory optimization: @@ -269,13 +269,13 @@ void PlayerStageStats::SetLifeRecordAt( float fLife, float fSecond ) fLifeRecord.erase(B); } -float PlayerStageStats::GetLifeRecordAt( float fSecond ) const +float PlayerStageStats::GetLifeRecordAt( float fStepsSecond ) const { if( fLifeRecord.empty() ) return 0; /* Find the first element whose key is greater than k. */ - map::const_iterator it = fLifeRecord.upper_bound( fSecond ); + map::const_iterator it = fLifeRecord.upper_bound( fStepsSecond ); /* Find the last element whose key is less than or equal to k. */ if( it != fLifeRecord.begin() ) @@ -285,13 +285,13 @@ float PlayerStageStats::GetLifeRecordAt( float fSecond ) const } -float PlayerStageStats::GetLifeRecordLerpAt( float fSecond ) const +float PlayerStageStats::GetLifeRecordLerpAt( float fStepsSecond ) const { if( fLifeRecord.empty() ) return 0; /* Find the first element whose key is greater than k. */ - map::const_iterator later = fLifeRecord.upper_bound( fSecond ); + map::const_iterator later = fLifeRecord.upper_bound( fStepsSecond ); /* Find the last element whose key is less than or equal to k. */ map::const_iterator earlier = later; @@ -305,15 +305,15 @@ float PlayerStageStats::GetLifeRecordLerpAt( float fSecond ) const return earlier->second; /* earlier <= pos <= later */ - return SCALE( fSecond, earlier->first, later->first, earlier->second, later->second ); + return SCALE( fStepsSecond, earlier->first, later->first, earlier->second, later->second ); } -void PlayerStageStats::GetLifeRecord( float *fLifeOut, int iNumSamples, float fEndSecond ) const +void PlayerStageStats::GetLifeRecord( float *fLifeOut, int iNumSamples, float fStepsEndSecond ) const { for( int i = 0; i < iNumSamples; ++i ) { - float from = SCALE( i, 0, (float)iNumSamples, 0.0f, fEndSecond ); + float from = SCALE( i, 0, (float)iNumSamples, 0.0f, fStepsEndSecond ); fLifeOut[i] = GetLifeRecordLerpAt( from ); } } diff --git a/stepmania/src/PlayerStageStats.h b/stepmania/src/PlayerStageStats.h index 9b02a1afe4..822f0a0117 100644 --- a/stepmania/src/PlayerStageStats.h +++ b/stepmania/src/PlayerStageStats.h @@ -58,10 +58,10 @@ struct PlayerStageStats float fCaloriesBurned; map fLifeRecord; - void SetLifeRecordAt( float fLife, float fSecond ); - void GetLifeRecord( float *fLifeOut, int iNumSamples, float fEndSecond ) const; - float GetLifeRecordAt( float fSecond ) const; - float GetLifeRecordLerpAt( float fSecond ) const; + void SetLifeRecordAt( float fLife, float fStepsSecond ); + void GetLifeRecord( float *fLifeOut, int iNumSamples, float fStepsEndSecond ) const; + float GetLifeRecordAt( float fStepsSecond ) const; + float GetLifeRecordLerpAt( float fStepsSecond ) const; struct Combo_t { diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index d1f2c2f0a8..036053bd8c 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -1447,6 +1447,8 @@ void ScreenGameplay::Update( float fDeltaTime ) // update fGameplaySeconds STATSMAN->m_CurStageStats.fGameplaySeconds += fDeltaTime; + if( GAMESTATE->m_fSongBeat >= GAMESTATE->m_pCurSong->m_fFirstBeat && GAMESTATE->m_fSongBeat < GAMESTATE->m_pCurSong->m_fLastBeat ) + STATSMAN->m_CurStageStats.fStepsSeconds += fDeltaTime; // // Check for end of song diff --git a/stepmania/src/StageStats.cpp b/stepmania/src/StageStats.cpp index fa3e4b2f71..be9ad88a56 100644 --- a/stepmania/src/StageStats.cpp +++ b/stepmania/src/StageStats.cpp @@ -13,6 +13,7 @@ StageStats::StageStats() vpPossibleSongs.clear(); StageType = STAGE_INVALID; fGameplaySeconds = 0; + fStepsSeconds = 0; } void StageStats::Init() @@ -62,6 +63,7 @@ void StageStats::AddStats( const StageStats& other ) StageType = STAGE_INVALID; // meaningless fGameplaySeconds += other.fGameplaySeconds; + fStepsSeconds += other.fStepsSeconds; FOREACH_PlayerNumber( p ) m_player[p].AddStats( other.m_player[p] ); @@ -91,12 +93,11 @@ bool StageStats::AllFailedEarlier() const return true; } -float StageStats::GetTotalPossibleMusicLengthSeconds() const +float StageStats::GetTotalPossibleStepsSeconds() const { float fSecs = 0; FOREACH_CONST( Song*, vpPossibleSongs, s ) - fSecs += (*s)->m_fMusicLengthSeconds; - + fSecs += (*s)->GetElapsedTimeFromBeat( (*s)->m_fLastBeat ) - (*s)->GetElapsedTimeFromBeat( (*s)->m_fFirstBeat ); return fSecs; } diff --git a/stepmania/src/StageStats.h b/stepmania/src/StageStats.h index 73306004af..3d338261d1 100644 --- a/stepmania/src/StageStats.h +++ b/stepmania/src/StageStats.h @@ -30,9 +30,14 @@ struct StageStats vector vpPlayedSongs; vector vpPossibleSongs; enum { STAGE_INVALID, STAGE_NORMAL, STAGE_EXTRA, STAGE_EXTRA2 } StageType; - float fGameplaySeconds; // how many seconds before gameplay ended. Updated by Gameplay, not scaled by music rate. - float GetTotalPossibleMusicLengthSeconds() const; // TODO: Scale this by the music rate + // TODO: These are updated in ScreenGameplay::Update based on fDelta. + // They should be made more accurate. + float fGameplaySeconds; // how many seconds before gameplay ended. Updated by Gameplay, not scaled by music rate. + float fStepsSeconds; // this is <= fGameplaySeconds unless the song has steps past the end + + // Total number of seconds between first beat and last beat for every song. + float GetTotalPossibleStepsSeconds() const; // TODO: Scale this by the music rate PlayerStageStats m_player[NUM_PLAYERS]; diff --git a/stepmania/src/song.h b/stepmania/src/song.h index 5a96321862..4f9b6de4a9 100644 --- a/stepmania/src/song.h +++ b/stepmania/src/song.h @@ -120,8 +120,8 @@ public: CString m_sMusicFile; float m_fMusicLengthSeconds; - float m_fFirstBeat; - float m_fLastBeat; + float m_fFirstBeat; // beat of first note + float m_fLastBeat; // beat of last note float m_fMusicSampleStartSeconds; float m_fMusicSampleLengthSeconds; enum { DISPLAY_ACTUAL, DISPLAY_SPECIFIED, DISPLAY_RANDOM } m_DisplayBPMType;