diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index 539261e8bf..2967f79480 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -204,6 +204,7 @@ void GameState::Reset() } m_bTemporaryEventMode = false; + m_bStatsCommitted = false; LIGHTSMAN->SetLightsMode( LIGHTSMODE_ATTRACT ); @@ -232,7 +233,12 @@ void GameState::JoinPlayer( PlayerNumber pn ) * * optional: CancelStage() - gameplay aborted (Back pressed), undo BeginStage and back up * + * CommitStageStats() - gameplay is finished + * Saves STATSMAN->m_CurStageStats to the profiles, so profile information + * is up-to-date for Evaluation. + * * FinishStage() - gameplay and evaluation is finished + * Clears data which was stored by CommitStageStats. * * EndGame() - the game is finished * @@ -416,6 +422,16 @@ void GameState::CancelStage() m_iNumStagesOfThisSong = 0; } +void GameState::CommitStageStats() +{ + /* Don't commit stats twice. */ + if( m_bStatsCommitted || m_bDemonstrationOrJukebox ) + return; + m_bStatsCommitted = true; + + STATSMAN->CommitStatsToProfiles(); +} + /* Called by ScreenSelectMusic (etc). Increment the stage counter if we just played a * song. Might be called more than once. */ void GameState::FinishStage() @@ -425,6 +441,11 @@ void GameState::FinishStage() if( m_iNumStagesOfThisSong == 0 ) return; + /* If we havn't committed stats yet, do so. */ + CommitStageStats(); + + m_bStatsCommitted = false; + // Increment the stage counter. ASSERT( m_iNumStagesOfThisSong >= 1 && m_iNumStagesOfThisSong <= 3 ); const int iOldStageIndex = m_iCurrentStageIndex; @@ -438,8 +459,6 @@ void GameState::FinishStage() if( m_bDemonstrationOrJukebox ) return; - STATSMAN->CommitStatsToProfiles(); - if( GAMESTATE->GetEventMode() ) { const int iSaveProfileEvery = 3; diff --git a/stepmania/src/GameState.h b/stepmania/src/GameState.h index c4e484423d..5a9943589d 100644 --- a/stepmania/src/GameState.h +++ b/stepmania/src/GameState.h @@ -110,6 +110,7 @@ public: int GetStageIndex() const; void BeginStage(); void CancelStage(); + void CommitStageStats(); void FinishStage(); int GetNumStagesLeft() const; bool IsFinalStage() const; @@ -187,6 +188,9 @@ public: void ResetStageStatistics(); // Call this when it's time to play a new stage. + // True if CommitStageStats() has been called and FinishStage() hasn't. + bool m_bStatsCommitted; + // // Options stuff diff --git a/stepmania/src/ScreenEvaluation.cpp b/stepmania/src/ScreenEvaluation.cpp index eb2df02eb6..eab23b97ca 100644 --- a/stepmania/src/ScreenEvaluation.cpp +++ b/stepmania/src/ScreenEvaluation.cpp @@ -180,6 +180,10 @@ void ScreenEvaluation::Init() { LOG->Trace( "ScreenEvaluation::Init()" ); + /* Commit stats to the profile, so any profile stats displayed on this screen + * include the last game. */ + GAMESTATE->CommitStageStats(); + Screen::Init(); LIGHTSMAN->SetLightsMode( LIGHTSMODE_MENU );