make Portal try to look for a song that matches all preferred difficulties

This commit is contained in:
Chris Danford
2004-06-02 05:49:38 +00:00
parent 2d269ebe06
commit 6c692d953d
+24 -3
View File
@@ -34,6 +34,7 @@
#include "ActorUtil.h"
#include "SongUtil.h"
#include "CourseUtil.h"
#include "Foreach.h"
#define FADE_SECONDS THEME->GetMetricF("MusicWheel","FadeSeconds")
@@ -1507,12 +1508,32 @@ Song* MusicWheel::GetSelectedSong()
switch( m_CurWheelItemData[m_iSelection]->m_Type )
{
case TYPE_PORTAL:
// probe to find a song
for( int i=0; i<1000; i++ )
{
// probe to find a song that has the preferred
// difficulties of each player
vector<Difficulty> 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; i<NUM_PROBES; i++ )
{
if( i == NUM_PROBES/2 )
vDifficultiesToRequire.clear();
int iSelection = rand() % m_CurWheelItemData.size();
if( m_CurWheelItemData[iSelection]->m_Type == TYPE_SONG )
return m_CurWheelItemData[iSelection]->m_pSong;
{
Song* pSong = m_CurWheelItemData[iSelection]->m_pSong;
FOREACH( Difficulty, vDifficultiesToRequire, d )
if( !pSong->SongHasNotesTypeAndDifficulty(st,*d) )
goto skip_song;
return pSong;
}
skip_song:
;
}
}
return NULL;
}