From f72b8b15d43bc8acf7b9c242f6851ff52d674820 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sun, 29 Aug 2004 19:10:25 +0000 Subject: [PATCH] fix "current combo on ScreenEnding shows the previous saved value, not the current value" --- stepmania/src/GameState.cpp | 72 +++++++++++++++++++++------------- stepmania/src/ScreenEnding.cpp | 4 ++ 2 files changed, 48 insertions(+), 28 deletions(-) diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index 135cce5d3a..f51f3acb57 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -327,48 +327,26 @@ void GameState::EndGame() /* Finish the final stage. */ FinishStage(); - // Update profile stats + + // Update totalPlaySeconds stat int iPlaySeconds = max( 0, (int) m_timeGameStarted.PeekDeltaTime() ); Profile* pMachineProfile = PROFILEMAN->GetMachineProfile(); - - int iGameplaySeconds = 0; - for( unsigned i=0; im_iTotalPlaySeconds += iPlaySeconds; - pMachineProfile->m_iTotalGameplaySeconds += iGameplaySeconds; pMachineProfile->m_iTotalPlays++; - pMachineProfile->m_iCurrentCombo = 0; - CHECKPOINT; FOREACH_HumanPlayer( p ) { - CHECKPOINT; - Profile* pPlayerProfile = PROFILEMAN->GetProfile( p ); if( pPlayerProfile ) { pPlayerProfile->m_iTotalPlaySeconds += iPlaySeconds; - pPlayerProfile->m_iTotalGameplaySeconds += iGameplaySeconds; pPlayerProfile->m_iTotalPlays++; - pPlayerProfile->m_iCurrentCombo = - PREFSMAN->m_bComboContinuesBetweenSongs ? - g_CurStageStats.iCurCombo[p] : - 0; } - - for( unsigned i=0; iWriteToDisk(); PROFILEMAN->SaveAllProfiles(); @@ -386,6 +364,9 @@ void GameState::EndGame() CHECKPOINT; SONGMAN->FreeAllLoadedFromProfiles(); + + // make sure we don't execute EndGame twice. + m_timeGameStarted.SetZero(); } void GameState::SaveCurrentSettingsToProfile( PlayerNumber pn ) @@ -629,7 +610,7 @@ void GameState::FinishStage() { /* If m_iNumStagesOfThisSong is 0, we've been called more than once before calling * BeginStage. This can happen when backing out of the player options screen. */ - if( !m_iNumStagesOfThisSong ) + if( m_iNumStagesOfThisSong == 0 ) return; // Increment the stage counter. @@ -657,6 +638,41 @@ void GameState::FinishStage() PROFILEMAN->AddStepTotals( pn, iNumTapsAndHolds, iNumJumps, iNumHolds, iNumMines, iNumHands ); } + + // Update profile stats + Profile* pMachineProfile = PROFILEMAN->GetMachineProfile(); + + int iGameplaySeconds = g_CurStageStats.fGameplaySeconds; + + pMachineProfile->m_iTotalGameplaySeconds += iGameplaySeconds; + pMachineProfile->m_iCurrentCombo = 0; + + CHECKPOINT; + FOREACH_HumanPlayer( p ) + { + CHECKPOINT; + + Profile* pPlayerProfile = PROFILEMAN->GetProfile( p ); + if( pPlayerProfile ) + { + pPlayerProfile->m_iTotalGameplaySeconds += iGameplaySeconds; + pPlayerProfile->m_iCurrentCombo = + PREFSMAN->m_bComboContinuesBetweenSongs ? + g_CurStageStats.iCurCombo[p] : + 0; + } + + const StageStats& ss = g_CurStageStats; + AddPlayerStatsToProfile( pMachineProfile, ss, p ); + + if( pPlayerProfile ) + AddPlayerStatsToProfile( pPlayerProfile, ss, p ); + + CHECKPOINT; + } + + + if( PREFSMAN->m_bEventMode ) { const int iSaveProfileEvery = 3; diff --git a/stepmania/src/ScreenEnding.cpp b/stepmania/src/ScreenEnding.cpp index 027cf5c9d3..398d02acc2 100644 --- a/stepmania/src/ScreenEnding.cpp +++ b/stepmania/src/ScreenEnding.cpp @@ -185,6 +185,10 @@ ScreenEnding::ScreenEnding( CString sClassName ) : ScreenAttract( sClassName, fa } + // Update final profile stats before we load them for display below. + GAMESTATE->FinishStage(); + + vector arraySongs; SONGMAN->GetSongs( arraySongs ); SongUtil::SortSongPointerArrayByTitle( arraySongs );