From f2add3a4c8f51a5826efd4a4f6f86c5b98229a20 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Tue, 22 Mar 2005 10:34:20 +0000 Subject: [PATCH] add FillMachineStats for scores stress testing --- stepmania/src/GameCommand.cpp | 67 +++++++++++++++++++++++++++++++++++ stepmania/src/GameCommand.h | 1 + 2 files changed, 68 insertions(+) diff --git a/stepmania/src/GameCommand.cpp b/stepmania/src/GameCommand.cpp index e2709726f0..3007d3b4ef 100644 --- a/stepmania/src/GameCommand.cpp +++ b/stepmania/src/GameCommand.cpp @@ -56,6 +56,7 @@ void GameCommand::Init() m_bClearBookkeepingData = false; m_bClearMachineStats = false; + m_bFillMachineStats = false; m_bTransferStatsFromMachine = false; m_bTransferStatsToMachine = false; m_bInsertCredit = false; @@ -352,6 +353,10 @@ void GameCommand::Load( int iIndex, const Commands& cmds ) { m_bClearMachineStats = true; } + else if( sName == "fillmachinestats" ) + { + m_bFillMachineStats = true; + } else if( sName == "transferstatsfrommachine" ) { m_bTransferStatsFromMachine = true; @@ -565,6 +570,31 @@ void GameCommand::Apply( PlayerNumber pn ) const Apply( vpns ); } +static HighScore MakeRandomHighScore() +{ + HighScore hs; + hs.sName = (char)('A'+rand()%26); + hs.grade = (Grade)SCALE( rand()%5, 0, 4, GRADE_TIER_1, GRADE_TIER_5 ); + hs.iScore = rand()%100*1000; + hs.fPercentDP = randomf( 50.0f, 100.0f ); + hs.fSurviveSeconds = randomf( 30.0f, 100.0f ); + PlayerOptions po; + po.ChooseRandomMofifiers(); + hs.sModifiers = po.GetString(); + hs.dateTime = DateTime::GetNowDateTime(); + hs.sPlayerGuid = Profile::MakeGuid(); + hs.sMachineGuid = Profile::MakeGuid(); + hs.iProductID = rand()%10; + FOREACH_TapNoteScore( tns ) + hs.iTapNoteScores[tns] = rand() % 100; + FOREACH_HoldNoteScore( hns ) + hs.iHoldNoteScores[hns] = rand() % 100; + FOREACH_RadarCategory( rc ) + hs.radarValues.m_fValues[rc] = randomf( 0, 1 ); + + return hs; +} + void GameCommand::Apply( const vector &vpns ) const { const PlayMode OldPlayMode = GAMESTATE->m_PlayMode; @@ -702,6 +732,43 @@ void GameCommand::Apply( const vector &vpns ) const PROFILEMAN->SaveMachineProfile(); SCREENMAN->SystemMessage( "Machine stats cleared." ); } + if( m_bFillMachineStats ) + { + Profile* pProfile = PROFILEMAN->GetMachineProfile(); + + vector vpAllSongs = SONGMAN->GetAllSongs(); + FOREACH( Song*, vpAllSongs, pSong ) + { + vector vpAllSteps = (*pSong)->GetAllSteps(); + FOREACH( Steps*, vpAllSteps, pSteps ) + { + for( int i=0; im_iMaxHighScoresPerListForMachine; i++ ) + { + int iIndex = 0; + pProfile->AddStepsHighScore( *pSong, *pSteps, MakeRandomHighScore(), iIndex ); + } + } + } + + vector vpAllCourses; + SONGMAN->GetAllCourses( vpAllCourses, true ); + FOREACH( Course*, vpAllCourses, pCourse ) + { + vector vpAllTrails; + (*pCourse)->GetAllTrails( vpAllTrails ); + FOREACH( Trail*, vpAllTrails, pTrail ) + { + for( int i=0; im_iMaxHighScoresPerListForMachine; i++ ) + { + int iIndex = 0; + pProfile->AddCourseHighScore( *pCourse, *pTrail, MakeRandomHighScore(), iIndex ); + } + } + } + + PROFILEMAN->SaveMachineProfile(); + SCREENMAN->SystemMessage( "Machine stats filled." ); + } if( m_bTransferStatsFromMachine ) { bool bTriedToSave = false; diff --git a/stepmania/src/GameCommand.h b/stepmania/src/GameCommand.h index f74613893f..df8260f459 100644 --- a/stepmania/src/GameCommand.h +++ b/stepmania/src/GameCommand.h @@ -67,6 +67,7 @@ public: bool m_bClearBookkeepingData; bool m_bClearMachineStats; + bool m_bFillMachineStats; // for testing bool m_bTransferStatsFromMachine; bool m_bTransferStatsToMachine; bool m_bInsertCredit;