fix "current combo on ScreenEnding shows the previous saved value, not the current value"
This commit is contained in:
+44
-28
@@ -327,48 +327,26 @@ void GameState::EndGame()
|
|||||||
/* Finish the final stage. */
|
/* Finish the final stage. */
|
||||||
FinishStage();
|
FinishStage();
|
||||||
|
|
||||||
// Update profile stats
|
|
||||||
|
// Update totalPlaySeconds stat
|
||||||
int iPlaySeconds = max( 0, (int) m_timeGameStarted.PeekDeltaTime() );
|
int iPlaySeconds = max( 0, (int) m_timeGameStarted.PeekDeltaTime() );
|
||||||
|
|
||||||
Profile* pMachineProfile = PROFILEMAN->GetMachineProfile();
|
Profile* pMachineProfile = PROFILEMAN->GetMachineProfile();
|
||||||
|
|
||||||
int iGameplaySeconds = 0;
|
|
||||||
for( unsigned i=0; i<g_vPlayedStageStats.size(); i++ )
|
|
||||||
iGameplaySeconds += (int) roundf(g_vPlayedStageStats[i].fGameplaySeconds);
|
|
||||||
|
|
||||||
pMachineProfile->m_iTotalPlaySeconds += iPlaySeconds;
|
pMachineProfile->m_iTotalPlaySeconds += iPlaySeconds;
|
||||||
pMachineProfile->m_iTotalGameplaySeconds += iGameplaySeconds;
|
|
||||||
pMachineProfile->m_iTotalPlays++;
|
pMachineProfile->m_iTotalPlays++;
|
||||||
pMachineProfile->m_iCurrentCombo = 0;
|
|
||||||
|
|
||||||
CHECKPOINT;
|
|
||||||
FOREACH_HumanPlayer( p )
|
FOREACH_HumanPlayer( p )
|
||||||
{
|
{
|
||||||
CHECKPOINT;
|
|
||||||
|
|
||||||
Profile* pPlayerProfile = PROFILEMAN->GetProfile( p );
|
Profile* pPlayerProfile = PROFILEMAN->GetProfile( p );
|
||||||
if( pPlayerProfile )
|
if( pPlayerProfile )
|
||||||
{
|
{
|
||||||
pPlayerProfile->m_iTotalPlaySeconds += iPlaySeconds;
|
pPlayerProfile->m_iTotalPlaySeconds += iPlaySeconds;
|
||||||
pPlayerProfile->m_iTotalGameplaySeconds += iGameplaySeconds;
|
|
||||||
pPlayerProfile->m_iTotalPlays++;
|
pPlayerProfile->m_iTotalPlays++;
|
||||||
pPlayerProfile->m_iCurrentCombo =
|
|
||||||
PREFSMAN->m_bComboContinuesBetweenSongs ?
|
|
||||||
g_CurStageStats.iCurCombo[p] :
|
|
||||||
0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for( unsigned i=0; i<g_vPlayedStageStats.size(); i++ )
|
|
||||||
{
|
|
||||||
const StageStats& ss = g_vPlayedStageStats[i];
|
|
||||||
AddPlayerStatsToProfile( pMachineProfile, ss, p );
|
|
||||||
|
|
||||||
if( pPlayerProfile )
|
|
||||||
AddPlayerStatsToProfile( pPlayerProfile, ss, p );
|
|
||||||
}
|
|
||||||
|
|
||||||
CHECKPOINT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BOOKKEEPER->WriteToDisk();
|
BOOKKEEPER->WriteToDisk();
|
||||||
PROFILEMAN->SaveAllProfiles();
|
PROFILEMAN->SaveAllProfiles();
|
||||||
|
|
||||||
@@ -386,6 +364,9 @@ void GameState::EndGame()
|
|||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
|
|
||||||
SONGMAN->FreeAllLoadedFromProfiles();
|
SONGMAN->FreeAllLoadedFromProfiles();
|
||||||
|
|
||||||
|
// make sure we don't execute EndGame twice.
|
||||||
|
m_timeGameStarted.SetZero();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameState::SaveCurrentSettingsToProfile( PlayerNumber pn )
|
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
|
/* 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. */
|
* BeginStage. This can happen when backing out of the player options screen. */
|
||||||
if( !m_iNumStagesOfThisSong )
|
if( m_iNumStagesOfThisSong == 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Increment the stage counter.
|
// Increment the stage counter.
|
||||||
@@ -657,6 +638,41 @@ void GameState::FinishStage()
|
|||||||
PROFILEMAN->AddStepTotals( pn, iNumTapsAndHolds, iNumJumps, iNumHolds, iNumMines, iNumHands );
|
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 )
|
if( PREFSMAN->m_bEventMode )
|
||||||
{
|
{
|
||||||
const int iSaveProfileEvery = 3;
|
const int iSaveProfileEvery = 3;
|
||||||
|
|||||||
@@ -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<Song*> arraySongs;
|
vector<Song*> arraySongs;
|
||||||
SONGMAN->GetSongs( arraySongs );
|
SONGMAN->GetSongs( arraySongs );
|
||||||
SongUtil::SortSongPointerArrayByTitle( arraySongs );
|
SongUtil::SortSongPointerArrayByTitle( arraySongs );
|
||||||
|
|||||||
Reference in New Issue
Block a user