From 0e52080354a580bb78980d265a593b72d0fcf29b Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Wed, 2 Jun 2004 06:02:20 +0000 Subject: [PATCH] make Random also prefer Songs that have all preferred difficulties make Random and Portal ignore Songs with only beginnger Steps (Training) --- stepmania/src/MusicWheel.cpp | 71 ++++++++++++++++++++++-------------- stepmania/src/MusicWheel.h | 2 + 2 files changed, 45 insertions(+), 28 deletions(-) diff --git a/stepmania/src/MusicWheel.cpp b/stepmania/src/MusicWheel.cpp index 2c968d518b..be66e81767 100644 --- a/stepmania/src/MusicWheel.cpp +++ b/stepmania/src/MusicWheel.cpp @@ -1303,6 +1303,8 @@ void MusicWheel::StartRandom() m_SpinSpeed *= 20.0f; /* faster! */ m_WheelState = STATE_RANDOM_SPINNING; + m_iSelection = GetPreferredSelectionForRandomOrPortal(); + this->Select(); RebuildMusicWheelItems(); } @@ -1508,35 +1510,48 @@ Song* MusicWheel::GetSelectedSong() switch( m_CurWheelItemData[m_iSelection]->m_Type ) { case TYPE_PORTAL: - { - // probe to find a song that has the preferred - // difficulties of each player - vector vDifficultiesToRequire; - FOREACH_HumanPlayer(p) - if( GAMESTATE->m_PreferredDifficulty[p] != DIFFICULTY_INVALID ) - vDifficultiesToRequire.push_back( GAMESTATE->m_PreferredDifficulty[p] ); - - StepsType st = GAMESTATE->GetCurrentStyleDef()->m_StepsType; -#define NUM_PROBES 1000 - for( int i=0; im_Type == TYPE_SONG ) - { - Song* pSong = m_CurWheelItemData[iSelection]->m_pSong; - FOREACH( Difficulty, vDifficultiesToRequire, d ) - if( !pSong->HasStepsTypeAndDifficulty(st,*d) ) - goto skip_song; - return pSong; - } -skip_song: - ; - } - } - return NULL; + return m_CurWheelItemData[ GetPreferredSelectionForRandomOrPortal() ]->m_pSong; + break; } return m_CurWheelItemData[m_iSelection]->m_pSong; } + +int MusicWheel::GetPreferredSelectionForRandomOrPortal() +{ + // probe to find a song that has the preferred + // difficulties of each player + vector vDifficultiesToRequire; + FOREACH_HumanPlayer(p) + if( GAMESTATE->m_PreferredDifficulty[p] != DIFFICULTY_INVALID ) + vDifficultiesToRequire.push_back( GAMESTATE->m_PreferredDifficulty[p] ); + + StepsType st = GAMESTATE->GetCurrentStyleDef()->m_StepsType; + +#define NUM_PROBES 1000 + for( int i=0; im_Type == TYPE_SONG ) + { + Song* pSong = m_CurWheelItemData[iSelection]->m_pSong; + + // HACK: Ignore all Songs with only Beginner steps. It's likely a training song. + vector vpSteps; + pSong->GetSteps( vpSteps, st ); + bool bIsTraining = vpSteps.size()==1 && vpSteps[0]->GetDifficulty()==DIFFICULTY_BEGINNER; + if( bIsTraining ) + goto skip_song; + + FOREACH( Difficulty, vDifficultiesToRequire, d ) + if( !pSong->HasStepsTypeAndDifficulty(st,*d) ) + goto skip_song; + return iSelection; + } +skip_song: + ; + } + return 0; +} diff --git a/stepmania/src/MusicWheel.h b/stepmania/src/MusicWheel.h index b55900a8be..5c56c27d5c 100644 --- a/stepmania/src/MusicWheel.h +++ b/stepmania/src/MusicWheel.h @@ -76,6 +76,8 @@ public: bool WheelIsLocked() { return (m_WheelState == STATE_LOCKED ? true : false); } void RebuildMusicWheelItems(); + int GetPreferredSelectionForRandomOrPortal(); + protected: void GetSongList(vector &arraySongs, SortOrder so, CString sPreferredGroup ); void BuildWheelItemDatas( vector &arrayWheelItems, SortOrder so );