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. */
|
/* If we ended mid-game, finish up. */
|
||||||
GAMESTATE->FinishStage();
|
GAMESTATE->FinishStage();
|
||||||
GAMESTATE->EndGame();
|
GAMESTATE->SaveLocalData();
|
||||||
|
|
||||||
if( ChangeAppPri() )
|
if( ChangeAppPri() )
|
||||||
HOOKS->UnBoostPriority();
|
HOOKS->UnBoostPriority();
|
||||||
|
|||||||
+16
-35
@@ -219,7 +219,8 @@ void GameState::ApplyCmdline()
|
|||||||
|
|
||||||
void GameState::Reset()
|
void GameState::Reset()
|
||||||
{
|
{
|
||||||
EndGame();
|
FOREACH_HumanPlayer( pn )
|
||||||
|
UnjoinPlayer( pn );
|
||||||
|
|
||||||
ASSERT( THEME );
|
ASSERT( THEME );
|
||||||
|
|
||||||
@@ -420,9 +421,6 @@ int GameState::GetCoinsNeededToJoin() const
|
|||||||
*
|
*
|
||||||
* FinishStage() - gameplay and evaluation is finished
|
* FinishStage() - gameplay and evaluation is finished
|
||||||
* Clears data which was stored by CommitStageStats.
|
* Clears data which was stored by CommitStageStats.
|
||||||
*
|
|
||||||
* EndGame() - the game is finished
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
void GameState::BeginGame()
|
void GameState::BeginGame()
|
||||||
{
|
{
|
||||||
@@ -510,40 +508,10 @@ bool GameState::HaveProfileToSave()
|
|||||||
return false;
|
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();
|
BOOKKEEPER->WriteToDisk();
|
||||||
|
|
||||||
SaveProfiles();
|
|
||||||
|
|
||||||
FOREACH_HumanPlayer( pn )
|
|
||||||
UnjoinPlayer( pn );
|
|
||||||
|
|
||||||
PROFILEMAN->SaveMachineProfile();
|
PROFILEMAN->SaveMachineProfile();
|
||||||
|
|
||||||
// make sure we don't execute EndGame twice.
|
|
||||||
m_timeGameStarted.SetZero();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int GameState::GetNumStagesMultiplierForSong( const Song* pSong )
|
int GameState::GetNumStagesMultiplierForSong( const Song* pSong )
|
||||||
@@ -665,6 +633,19 @@ void GameState::CommitStageStats()
|
|||||||
m_bStatsCommitted = true;
|
m_bStatsCommitted = true;
|
||||||
|
|
||||||
STATSMAN->CommitStatsToProfiles();
|
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
|
/* Called by ScreenSelectMusic (etc). Increment the stage counter if we just played a
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public:
|
|||||||
void SaveProfiles();
|
void SaveProfiles();
|
||||||
bool HaveProfileToLoad();
|
bool HaveProfileToLoad();
|
||||||
bool HaveProfileToSave();
|
bool HaveProfileToSave();
|
||||||
void EndGame(); // called on ScreenGameOver, ScreenMusicScroll, ScreenCredits
|
void SaveLocalData();
|
||||||
void LoadCurrentSettingsFromProfile( PlayerNumber pn );
|
void LoadCurrentSettingsFromProfile( PlayerNumber pn );
|
||||||
void SaveCurrentSettingsToProfile( PlayerNumber pn ); // called at the beginning of each stage
|
void SaveCurrentSettingsToProfile( PlayerNumber pn ); // called at the beginning of each stage
|
||||||
Song* GetDefaultSong() const;
|
Song* GetDefaultSong() const;
|
||||||
|
|||||||
Reference in New Issue
Block a user