From e23275084d28c59cd8c5cb8fd702fe3360226490 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sun, 24 Feb 2008 07:43:55 +0000 Subject: [PATCH] fix workout goal not working correctly when CurStageIndex > 0 --- stepmania/src/GameState.cpp | 11 +++++------ stepmania/src/WorkoutGraph.cpp | 17 +++++++---------- stepmania/src/WorkoutGraph.h | 4 ++-- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index 608d24ab94..faf4ec2edf 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -794,9 +794,8 @@ void GameState::Update( float fDelta ) if( WORKOUTMAN->m_pCurWorkout != NULL && !m_bWorkoutGoalComplete ) { - const StageStats &ssAccum = STATSMAN->GetAccumPlayedStageStats(); const StageStats &ssCurrent = STATSMAN->m_CurStageStats; - bool bGoalComplete = ssAccum.m_fGameplaySeconds + ssCurrent.m_fGameplaySeconds > WORKOUTMAN->m_pCurWorkout->m_iMinutes*60; + bool bGoalComplete = ssCurrent.m_fGameplaySeconds > WORKOUTMAN->m_pCurWorkout->m_iMinutes*60; if( bGoalComplete ) { MESSAGEMAN->Broadcast( "WorkoutGoalComplete" ); @@ -1898,9 +1897,7 @@ Premium GameState::GetPremium() const float GameState::GetGoalPercentComplete( PlayerNumber pn ) { const Profile *pProfile = PROFILEMAN->GetProfile(pn); - const StageStats &ssAccum = STATSMAN->GetAccumPlayedStageStats(); const StageStats &ssCurrent = STATSMAN->m_CurStageStats; - const PlayerStageStats &pssAccum = ssAccum.m_player[pn]; const PlayerStageStats &pssCurrent = ssCurrent.m_player[pn]; float fActual = 0; @@ -1908,11 +1905,11 @@ float GameState::GetGoalPercentComplete( PlayerNumber pn ) switch( pProfile->m_GoalType ) { case GoalType_Calories: - fActual = pssAccum.m_fCaloriesBurned + pssCurrent.m_fCaloriesBurned; + fActual = pssCurrent.m_fCaloriesBurned; fGoal = (float)pProfile->m_iGoalCalories; break; case GoalType_Time: - fActual = ssAccum.m_fGameplaySeconds + ssCurrent.m_fGameplaySeconds; + fActual = ssCurrent.m_fGameplaySeconds; fGoal = (float)pProfile->m_iGoalSeconds; break; case GoalType_None: @@ -2247,6 +2244,7 @@ public: { p->m_bJukeboxUsesModifiers = BArg(1); return 0; } + DEFINE_METHOD( GetWorkoutGoalComplete, m_bWorkoutGoalComplete ) LunaGameState() { @@ -2329,6 +2327,7 @@ public: ADD_METHOD( GetStageSeed ); ADD_METHOD( SaveLocalData ); ADD_METHOD( SetJukeboxUsesModifiers ); + ADD_METHOD( GetWorkoutGoalComplete ); } }; diff --git a/stepmania/src/WorkoutGraph.cpp b/stepmania/src/WorkoutGraph.cpp index f0e0dc7f19..9b732021fa 100644 --- a/stepmania/src/WorkoutGraph.cpp +++ b/stepmania/src/WorkoutGraph.cpp @@ -41,12 +41,12 @@ void WorkoutGraph::LoadFromNode( const XNode* pNode ) Load(); } -void WorkoutGraph::SetFromGameState() +void WorkoutGraph::SetFromCurrentWorkout() { - SetFromGameStateInternal( STATSMAN->m_CurStageStats.m_vpPlayedSongs.size() ); + SetInternal( 0 ); } -void WorkoutGraph::SetFromGameStateInternal( int iNumSongsToShowForCurrentStage ) +void WorkoutGraph::SetInternal( int iMinSongsPlayed ) { ASSERT( WORKOUTMAN->m_pCurWorkout ); @@ -57,11 +57,8 @@ void WorkoutGraph::SetFromGameStateInternal( int iNumSongsToShowForCurrentStage } m_vpBars.clear(); - int iTotalSongsPlayed = - STATSMAN->GetAccumPlayedStageStats().m_vpPlayedSongs.size() + - iNumSongsToShowForCurrentStage; int iWorkoutEstimatedSongs = WORKOUTMAN->m_pCurWorkout->GetEstimatedNumSongs(); - int iNumSongsToShow = max( iTotalSongsPlayed, iWorkoutEstimatedSongs ); + int iNumSongsToShow = max( iMinSongsPlayed, iWorkoutEstimatedSongs ); vector viMeters; WORKOUTMAN->m_pCurWorkout->GetEstimatedMeters( iNumSongsToShow, viMeters ); @@ -105,7 +102,7 @@ void WorkoutGraph::SetFromGameStateInternal( int iNumSongsToShowForCurrentStage void WorkoutGraph::SetFromGameStateAndHighlightSong( int iSongIndex ) { - SetFromGameStateInternal( iSongIndex+1 ); + SetInternal( iSongIndex+1 ); FOREACH( Sprite*, m_vpBars, spr ) (*spr)->StopEffect(); @@ -123,12 +120,12 @@ void WorkoutGraph::SetFromGameStateAndHighlightSong( int iSongIndex ) class LunaWorkoutGraph: public Luna { public: - static int SetFromGameState( T* p, lua_State *L ) { p->SetFromGameState(); return 0; } + static int SetFromCurrentWorkout( T* p, lua_State *L ) { p->SetFromCurrentWorkout(); return 0; } static int SetFromGameStateAndHighlightSong( T* p, lua_State *L ) { p->SetFromGameStateAndHighlightSong(IArg(1)); return 0; } LunaWorkoutGraph() { - ADD_METHOD( SetFromGameState ); + ADD_METHOD( SetFromCurrentWorkout ); ADD_METHOD( SetFromGameStateAndHighlightSong ); } }; diff --git a/stepmania/src/WorkoutGraph.h b/stepmania/src/WorkoutGraph.h index 2a76618cbe..bc193ad3ea 100644 --- a/stepmania/src/WorkoutGraph.h +++ b/stepmania/src/WorkoutGraph.h @@ -16,14 +16,14 @@ public: void Load(); void LoadFromNode( const XNode* pNode ); - void SetFromGameState(); + void SetFromCurrentWorkout(); void SetFromGameStateAndHighlightSong( int iSongIndex ); // Lua void PushSelf( lua_State *L ); protected: - void SetFromGameStateInternal( int iNumSongsToShowForCurrentStage ); + void SetInternal( int iNumSongsToShowForCurrentStage ); void HighlightSong( int iSongIndex ); Sprite m_sprEmpty;