Eliminate GameState::EndGame; games don't necessarily have distinct
endings. Update the play timer periodically when we commit scores. (This timer is a bit different, but reasonable.)
This commit is contained in:
@@ -213,7 +213,7 @@ void GameLoop::RunGameLoop()
|
||||
|
||||
/* If we ended mid-game, finish up. */
|
||||
GAMESTATE->FinishStage();
|
||||
GAMESTATE->EndGame();
|
||||
GAMESTATE->SaveLocalData();
|
||||
|
||||
if( ChangeAppPri() )
|
||||
HOOKS->UnBoostPriority();
|
||||
|
||||
+17
-36
@@ -219,8 +219,9 @@ void GameState::ApplyCmdline()
|
||||
|
||||
void GameState::Reset()
|
||||
{
|
||||
EndGame();
|
||||
|
||||
FOREACH_HumanPlayer( pn )
|
||||
UnjoinPlayer( pn );
|
||||
|
||||
ASSERT( THEME );
|
||||
|
||||
m_timeGameStarted.SetZero();
|
||||
@@ -420,9 +421,6 @@ int GameState::GetCoinsNeededToJoin() const
|
||||
*
|
||||
* FinishStage() - gameplay and evaluation is finished
|
||||
* Clears data which was stored by CommitStageStats.
|
||||
*
|
||||
* EndGame() - the game is finished
|
||||
*
|
||||
*/
|
||||
void GameState::BeginGame()
|
||||
{
|
||||
@@ -510,40 +508,10 @@ bool GameState::HaveProfileToSave()
|
||||
return false;
|
||||
}
|
||||
|
||||
void GameState::EndGame()
|
||||
void GameState::SaveLocalData()
|
||||
{
|
||||
LOG->Trace( "GameState::EndGame" );
|
||||
|
||||
if( m_bDemonstrationOrJukebox )
|
||||
return;
|
||||
if( m_timeGameStarted.IsZero() || !STATSMAN->m_vPlayedStageStats.size() ) // we were in the middle of a game and played at least one song
|
||||
return;
|
||||
|
||||
// Update totalPlaySeconds stat
|
||||
int iPlaySeconds = max( 0, (int) m_timeGameStarted.PeekDeltaTime() );
|
||||
|
||||
Profile* pMachineProfile = PROFILEMAN->GetMachineProfile();
|
||||
pMachineProfile->m_iTotalPlaySeconds += iPlaySeconds;
|
||||
|
||||
FOREACH_HumanPlayer( p )
|
||||
{
|
||||
Profile* pPlayerProfile = PROFILEMAN->GetProfile( p );
|
||||
if( pPlayerProfile )
|
||||
pPlayerProfile->m_iTotalPlaySeconds += iPlaySeconds;
|
||||
}
|
||||
|
||||
|
||||
BOOKKEEPER->WriteToDisk();
|
||||
|
||||
SaveProfiles();
|
||||
|
||||
FOREACH_HumanPlayer( pn )
|
||||
UnjoinPlayer( pn );
|
||||
|
||||
PROFILEMAN->SaveMachineProfile();
|
||||
|
||||
// make sure we don't execute EndGame twice.
|
||||
m_timeGameStarted.SetZero();
|
||||
}
|
||||
|
||||
int GameState::GetNumStagesMultiplierForSong( const Song* pSong )
|
||||
@@ -665,6 +633,19 @@ void GameState::CommitStageStats()
|
||||
m_bStatsCommitted = true;
|
||||
|
||||
STATSMAN->CommitStatsToProfiles();
|
||||
|
||||
// Update TotalPlaySeconds.
|
||||
int iPlaySeconds = max( 0, (int) m_timeGameStarted.GetDeltaTime() );
|
||||
|
||||
Profile* pMachineProfile = PROFILEMAN->GetMachineProfile();
|
||||
pMachineProfile->m_iTotalPlaySeconds += iPlaySeconds;
|
||||
|
||||
FOREACH_HumanPlayer( p )
|
||||
{
|
||||
Profile* pPlayerProfile = PROFILEMAN->GetProfile( p );
|
||||
if( pPlayerProfile )
|
||||
pPlayerProfile->m_iTotalPlaySeconds += iPlaySeconds;
|
||||
}
|
||||
}
|
||||
|
||||
/* Called by ScreenSelectMusic (etc). Increment the stage counter if we just played a
|
||||
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
void SaveProfiles();
|
||||
bool HaveProfileToLoad();
|
||||
bool HaveProfileToSave();
|
||||
void EndGame(); // called on ScreenGameOver, ScreenMusicScroll, ScreenCredits
|
||||
void SaveLocalData();
|
||||
void LoadCurrentSettingsFromProfile( PlayerNumber pn );
|
||||
void SaveCurrentSettingsToProfile( PlayerNumber pn ); // called at the beginning of each stage
|
||||
Song* GetDefaultSong() const;
|
||||
|
||||
Reference in New Issue
Block a user