From 2cd058620b2ce2884cafb78e9282370ef99795e0 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Mon, 15 Dec 2003 06:24:59 +0000 Subject: [PATCH] Always set GAMESTATE->m_CurStageStats.pSong. Always fill in m_vPlayedStageStats. --- stepmania/src/ScreenEvaluation.cpp | 3 -- stepmania/src/ScreenGameplay.cpp | 74 +++++++++++++++++------------- stepmania/src/ScreenGameplay.h | 1 + 3 files changed, 43 insertions(+), 35 deletions(-) diff --git a/stepmania/src/ScreenEvaluation.cpp b/stepmania/src/ScreenEvaluation.cpp index 0a8dd6339d..6e4a7583b5 100644 --- a/stepmania/src/ScreenEvaluation.cpp +++ b/stepmania/src/ScreenEvaluation.cpp @@ -1279,9 +1279,6 @@ void ScreenEvaluation::MenuStart( PlayerNumber pn ) iNumStagesOfLastSong = 1; } GAMESTATE->m_iCurrentStageIndex += iNumStagesOfLastSong; - - // save current stage stats - GAMESTATE->m_vPlayedStageStats.push_back( GAMESTATE->m_CurStageStats ); // Save this stage's stats break; } } diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index 27f275a20e..1eef5ebc3a 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -196,10 +196,7 @@ ScreenGameplay::ScreenGameplay( CString sName, bool bDemonstration ) : Screen("S } - if( !GAMESTATE->IsCourseMode() ) - GAMESTATE->m_CurStageStats.pSong = GAMESTATE->m_pCurSong; - else - GAMESTATE->m_CurStageStats.pSong = NULL; + GAMESTATE->m_CurStageStats.pSong = NULL; // set in LoadNextSong GAMESTATE->m_CurStageStats.playMode = GAMESTATE->m_PlayMode; GAMESTATE->m_CurStageStats.style = GAMESTATE->m_CurStyle; @@ -735,6 +732,8 @@ void ScreenGameplay::LoadNextSong() iPlaySongIndex %= m_apSongsQueue.size(); GAMESTATE->m_pCurSong = m_apSongsQueue[iPlaySongIndex]; + GAMESTATE->m_CurStageStats.pSong = GAMESTATE->m_pCurSong; + // Restore the player's originally selected options. GAMESTATE->RemoveAllActiveAttacks(); GAMESTATE->RestoreSelectedOptions(); @@ -1639,6 +1638,30 @@ void ScreenGameplay::ShowSavePrompt( ScreenMessage SM_SendWhenDone ) SCREENMAN->Prompt( SM_SendWhenDone, sMessage, true, false, SaveChanges, RevertChanges, &m_apSongsQueue ); } +void ScreenGameplay::SongFinished() +{ + /* Need to Finish before calling GetActualRadarValue, for GetMaxCombo. */ + GAMESTATE->m_CurStageStats.Finish(); + + // save any statistics + int p; + for( p=0; pIsPlayerEnabled(p) ) + continue; + for( int r=0; rm_CurStageStats.fRadarPossible[p][r] = NoteDataUtil::GetRadarValue( m_Player[p], rc, GAMESTATE->m_pCurSong->m_fMusicLengthSeconds ); + GAMESTATE->m_CurStageStats.fRadarActual[p][r] = m_Player[p].GetActualRadarValue( rc, (PlayerNumber)p, GAMESTATE->m_pCurSong->m_fMusicLengthSeconds ); + } + } + + + // save current stage stats + GAMESTATE->m_vPlayedStageStats.push_back( GAMESTATE->m_CurStageStats ); +} + void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM ) { CHECKPOINT_M( ssprintf("HandleScreenMessage(%i)", SM) ); @@ -1660,28 +1683,11 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM ) // received while STATE_DANCING case SM_NotesEnded: { - /* Need to Finish before calling GetActualRadarValue, for GetMaxCombo. */ - GAMESTATE->m_CurStageStats.Finish(); - - // save any statistics - int p; - for( p=0; pIsPlayerEnabled(p) ) - { - for( int r=0; rm_CurStageStats.fRadarPossible[p][r] = NoteDataUtil::GetRadarValue( m_Player[p], rc, GAMESTATE->m_pCurSong->m_fMusicLengthSeconds ); - GAMESTATE->m_CurStageStats.fRadarActual[p][r] = m_Player[p].GetActualRadarValue( rc, (PlayerNumber)p, GAMESTATE->m_pCurSong->m_fMusicLengthSeconds ); - } - } - } - /* Do this in LoadNextSong, so we don't tween off old attacks until * m_NextSongOut finishes. */ // GAMESTATE->RemoveAllActiveAttacks(); + int p; for( p=0; pIsPlayerEnabled(p) ) @@ -1697,20 +1703,16 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM ) GAMESTATE->m_CurStageStats.bFailed[p] = true; } + /* Mark failure. This hasn't been done yet if m_bTwoPlayerRecovery is set. */ + if( GAMESTATE->m_SongOptions.m_FailType != SongOptions::FAIL_OFF && + (m_pLifeMeter[p] && m_pLifeMeter[p]->IsFailing()) || + (m_pCombinedLifeMeter && m_pCombinedLifeMeter->IsFailing((PlayerNumber)p)) ) + GAMESTATE->m_CurStageStats.bFailed[p] = true; + if( !GAMESTATE->m_CurStageStats.bFailed[p] ) GAMESTATE->m_CurStageStats.iSongsPassed[p]++; } - /* Mark failure. This was possibly already done by UpdateCheckFail, but - * not always, if m_bTwoPlayerRecovery is set. */ - if( GAMESTATE->m_SongOptions.m_FailType != SongOptions::FAIL_OFF ) - { - for( p=0; pIsFailing()) || - (m_pCombinedLifeMeter && m_pCombinedLifeMeter->IsFailing((PlayerNumber)p)) ) - GAMESTATE->m_CurStageStats.bFailed[p] = true; - } - /* If all players have *really* failed (bFailed, not the life meter or * bFailedEarlier): */ const bool bAllReallyFailed = GAMESTATE->m_CurStageStats.AllFailed(); @@ -1816,6 +1818,8 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM ) break; case SM_LoadNextSong: + SongFinished(); + LoadNextSong(); GAMESTATE->m_bPastHereWeGo = true; /* We're fading in, so don't hit any notes for a few seconds; they'll be @@ -1973,12 +1977,16 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM ) break; case SM_GoToScreenAfterBack: + SongFinished(); + /* Reset options. (Should this be done in ScreenSelect*?) */ GAMESTATE->RestoreSelectedOptions(); SCREENMAN->SetNewScreen( PREV_SCREEN(GAMESTATE->m_PlayMode) ); break; case SM_GoToStateAfterCleared: + SongFinished(); + /* Reset options. (Should this be done in ScreenSelect*?) */ GAMESTATE->RestoreSelectedOptions(); @@ -2030,6 +2038,8 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM ) break; case SM_GoToScreenAfterFail: + SongFinished(); + /* Reset options. (Should this be done in ScreenSelect*?) */ GAMESTATE->RestoreSelectedOptions(); diff --git a/stepmania/src/ScreenGameplay.h b/stepmania/src/ScreenGameplay.h index 32c0f8ecf7..3090d485aa 100644 --- a/stepmania/src/ScreenGameplay.h +++ b/stepmania/src/ScreenGameplay.h @@ -80,6 +80,7 @@ protected: bool IsTimeToPlayTicks() const; void UpdateLyrics( float fDeltaTime ); void UpdateCheckFail(); + void SongFinished(); enum DancingState { STATE_INTRO = 0, // not allowed to press Back