Rename StageStats::operator+= to AddStats. (easier to grep for)
Keep track of whether each stage in StageStats was an extra stage. GAMESTATE->m_vPassedStageStats now holds all played songs, including failed ones (renaming in a moment). GameState::GetFinalEvalStatsAndSongs logic was weird. Simplify.
This commit is contained in:
+20
-12
@@ -446,23 +446,31 @@ void GameState::GetFinalEvalStatsAndSongs( StageStats& statsOut, vector<Song*>&
|
||||
statsOut = StageStats();
|
||||
|
||||
// Show stats only for the latest 3 normal songs + passed extra stages
|
||||
int iNumPassedExtraStages = GAMESTATE->IsExtraStage() ? 1 : (GAMESTATE->IsExtraStage2() ? 2 : 0);
|
||||
int iNumPassedRegularSongs = GAMESTATE->m_vPassedStageStats.size() - iNumPassedExtraStages;
|
||||
int iNumSongsToShow = iNumPassedExtraStages + min( iNumPassedRegularSongs, 3 );
|
||||
int iNumSongsToThrowAway = GAMESTATE->m_vPassedStageStats.size() - iNumSongsToShow;
|
||||
ASSERT( iNumSongsToThrowAway >= 0 );
|
||||
|
||||
for( int i=iNumSongsToThrowAway; i<(int)GAMESTATE->m_vPassedStageStats.size(); i++ )
|
||||
int PassedRegularSongsLeft = 3;
|
||||
for( int i = (int)GAMESTATE->m_vPassedStageStats.size()-1; i >= 0; --i )
|
||||
{
|
||||
// weight long and marathon songs
|
||||
int iLengthMultiplier = SongManager::GetNumStagesForSong( GAMESTATE->m_vPassedStageStats[i].pSong );
|
||||
const StageStats &s = GAMESTATE->m_vPassedStageStats[i];
|
||||
|
||||
statsOut += GAMESTATE->m_vPassedStageStats[i];
|
||||
if( !s.OnePassed() )
|
||||
continue;
|
||||
|
||||
if( s.StageType == StageStats::STAGE_NORMAL )
|
||||
{
|
||||
if( PassedRegularSongsLeft == 0 )
|
||||
break;
|
||||
|
||||
--PassedRegularSongsLeft;
|
||||
}
|
||||
|
||||
// weight long and marathon songs
|
||||
int iLengthMultiplier = SongManager::GetNumStagesForSong( s.pSong );
|
||||
|
||||
statsOut.AddStats( s );
|
||||
for( int p=0; p<NUM_PLAYERS; p++ )
|
||||
if( IsPlayerEnabled(p) )
|
||||
statsOut.iMeter[p] += GAMESTATE->m_vPassedStageStats[i].iMeter[p] * (iLengthMultiplier-1);
|
||||
statsOut.iMeter[p] += s.iMeter[p] * (iLengthMultiplier-1);
|
||||
|
||||
vSongsOut.push_back( GAMESTATE->m_vPassedStageStats[i].pSong );
|
||||
vSongsOut.insert( vSongsOut.begin(), s.pSong );
|
||||
}
|
||||
|
||||
if(!vSongsOut.size()) return;
|
||||
|
||||
@@ -982,9 +982,8 @@ void ScreenEvaluation::MenuStart( PlayerNumber pn )
|
||||
iNumStagesOfLastSong = SongManager::GetNumStagesForSong( GAMESTATE->m_pCurSong );
|
||||
GAMESTATE->m_iCurrentStageIndex += iNumStagesOfLastSong;
|
||||
|
||||
// add current stage stats to accumulated total only if this song was passed
|
||||
if( GAMESTATE->m_CurStageStats.OnePassed() )
|
||||
GAMESTATE->m_vPassedStageStats.push_back( GAMESTATE->m_CurStageStats ); // Save this stage's stats
|
||||
// save current stage stats
|
||||
GAMESTATE->m_vPassedStageStats.push_back( GAMESTATE->m_CurStageStats ); // Save this stage's stats
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,6 +189,13 @@ ScreenGameplay::ScreenGameplay( bool bDemonstration ) : Screen("ScreenGameplay")
|
||||
GAMESTATE->m_CurStageStats.iMeter[p] = m_apNotesQueue[p][0]->GetMeter();
|
||||
}
|
||||
|
||||
if( GAMESTATE->IsExtraStage() )
|
||||
GAMESTATE->m_CurStageStats.StageType = StageStats::STAGE_EXTRA;
|
||||
else if( GAMESTATE->IsExtraStage2() )
|
||||
GAMESTATE->m_CurStageStats.StageType = StageStats::STAGE_EXTRA2;
|
||||
else
|
||||
GAMESTATE->m_CurStageStats.StageType = StageStats::STAGE_NORMAL;
|
||||
|
||||
//
|
||||
// Init ScoreKeepers
|
||||
//
|
||||
|
||||
@@ -21,9 +21,10 @@ StageStats::StageStats()
|
||||
memset( this, 0, sizeof(StageStats) );
|
||||
}
|
||||
|
||||
void StageStats::operator+=( const StageStats& other )
|
||||
void StageStats::AddStats( const StageStats& other )
|
||||
{
|
||||
pSong = NULL; // meaningless
|
||||
StageType = STAGE_INVALID; // meaningless
|
||||
memset( fAliveSeconds, 0, sizeof(fAliveSeconds) );
|
||||
|
||||
for( int p=0; p<NUM_PLAYERS; p++ )
|
||||
|
||||
@@ -21,11 +21,12 @@ class Song;
|
||||
struct StageStats
|
||||
{
|
||||
StageStats();
|
||||
void operator+=( const StageStats& other ); // accumulate
|
||||
void AddStats( const StageStats& other ); // accumulate
|
||||
Grade GetGrade( PlayerNumber pn );
|
||||
bool OnePassed() const;
|
||||
|
||||
Song* pSong;
|
||||
enum { STAGE_INVALID, STAGE_NORMAL, STAGE_EXTRA, STAGE_EXTRA2 } StageType;
|
||||
int iMeter[NUM_PLAYERS];
|
||||
float fAliveSeconds[NUM_PLAYERS]; // how far into the music did they last before failing? Updated by Gameplay.
|
||||
bool bFailed[NUM_PLAYERS]; // true if they have failed at any point during the song
|
||||
|
||||
Reference in New Issue
Block a user