From 18911711c4fc0cb56e7f8d4aed66b799279a5573 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 13 Aug 2005 00:10:18 +0000 Subject: [PATCH] split FillProfile --- stepmania/src/GameCommand.cpp | 83 +++++++++++++++++++---------------- 1 file changed, 46 insertions(+), 37 deletions(-) diff --git a/stepmania/src/GameCommand.cpp b/stepmania/src/GameCommand.cpp index 5d230166e9..783dd05590 100644 --- a/stepmania/src/GameCommand.cpp +++ b/stepmania/src/GameCommand.cpp @@ -635,6 +635,51 @@ static HighScore MakeRandomHighScore( float fPercentDP ) return hs; } +static void FillProfile( Profile *pProfile ) +{ + // Choose a percent for all scores. This is useful for testing unlocks + // where some elements are unlocked at a certain percent complete + float fPercentDP = randomf( 0.6f, 1.2f ); + CLAMP( fPercentDP, 0.0f, 1.0f ); + + int iCount = pProfile->IsMachine()? + PREFSMAN->m_iMaxHighScoresPerListForMachine.Get(): + PREFSMAN->m_iMaxHighScoresPerListForPlayer.Get(); + + vector vpAllSongs = SONGMAN->GetAllSongs(); + FOREACH( Song*, vpAllSongs, pSong ) + { + vector vpAllSteps = (*pSong)->GetAllSteps(); + FOREACH( Steps*, vpAllSteps, pSteps ) + { + pProfile->IncrementStepsPlayCount( *pSong, *pSteps ); + for( int i=0; iAddStepsHighScore( *pSong, *pSteps, MakeRandomHighScore(fPercentDP), iIndex ); + } + } + } + + vector vpAllCourses; + SONGMAN->GetAllCourses( vpAllCourses, true ); + FOREACH( Course*, vpAllCourses, pCourse ) + { + vector vpAllTrails; + (*pCourse)->GetAllTrails( vpAllTrails ); + FOREACH( Trail*, vpAllTrails, pTrail ) + { + pProfile->IncrementCoursePlayCount( *pCourse, *pTrail ); + for( int i=0; iAddCourseHighScore( *pCourse, *pTrail, MakeRandomHighScore(fPercentDP), iIndex ); + } + } + } +} + + /* Hack: if this GameCommand would set the screen, clear the setting and return * the screen that would have been set. */ CString GameCommand::GetAndClearScreen() @@ -840,45 +885,9 @@ void GameCommand::ApplySelf( const vector &vpns ) const } if( m_bFillMachineStats ) { - // Choose a percent for all scores. This is useful for testing unlocks - // where some elements are unlocked at a certain percent complete - float fPercentDP = randomf( 0.6f, 1.2f ); - CLAMP( fPercentDP, 0.0f, 1.0f ); - Profile* pProfile = PROFILEMAN->GetMachineProfile(); + FillProfile( pProfile ); - vector vpAllSongs = SONGMAN->GetAllSongs(); - FOREACH( Song*, vpAllSongs, pSong ) - { - vector vpAllSteps = (*pSong)->GetAllSteps(); - FOREACH( Steps*, vpAllSteps, pSteps ) - { - pProfile->IncrementStepsPlayCount( *pSong, *pSteps ); - for( int i=0; im_iMaxHighScoresPerListForMachine; i++ ) - { - int iIndex = 0; - pProfile->AddStepsHighScore( *pSong, *pSteps, MakeRandomHighScore(fPercentDP), iIndex ); - } - } - } - - vector vpAllCourses; - SONGMAN->GetAllCourses( vpAllCourses, true ); - FOREACH( Course*, vpAllCourses, pCourse ) - { - vector vpAllTrails; - (*pCourse)->GetAllTrails( vpAllTrails ); - FOREACH( Trail*, vpAllTrails, pTrail ) - { - pProfile->IncrementCoursePlayCount( *pCourse, *pTrail ); - for( int i=0; im_iMaxHighScoresPerListForMachine.Get(); i++ ) - { - int iIndex = 0; - pProfile->AddCourseHighScore( *pCourse, *pTrail, MakeRandomHighScore(fPercentDP), iIndex ); - } - } - } - PROFILEMAN->SaveMachineProfile(); SCREENMAN->SystemMessage( "Machine stats filled." ); }