fix up Song::GetClosestNotes: search all difficulties; if not looking for an
edit, don't return one
This commit is contained in:
+20
-24
@@ -922,30 +922,26 @@ Steps* Song::GetStepsByDescription( StepsType st, CString sDescription ) const
|
|||||||
|
|
||||||
Steps* Song::GetClosestNotes( StepsType st, Difficulty dc ) const
|
Steps* Song::GetClosestNotes( StepsType st, Difficulty dc ) const
|
||||||
{
|
{
|
||||||
Difficulty newDC = dc;
|
ASSERT( dc != DIFFICULTY_INVALID );
|
||||||
Steps* pSteps;
|
|
||||||
pSteps = GetStepsByDifficulty( st, newDC );
|
const vector<Steps*>& vpSteps = GetAllSteps(st);
|
||||||
if( pSteps )
|
Steps *pClosest = NULL;
|
||||||
return pSteps;
|
int iClosestDistance = 999;
|
||||||
newDC = (Difficulty)(dc-1);
|
for( unsigned i=0; i<vpSteps.size(); i++ ) // for each of the Song's Steps
|
||||||
CLAMP( (int&)newDC, 0, NUM_DIFFICULTIES-1 );
|
{
|
||||||
pSteps = GetStepsByDifficulty( st, newDC );
|
Steps* pSteps = vpSteps[i];
|
||||||
if( pSteps )
|
|
||||||
return pSteps;
|
if( pSteps->GetDifficulty() == DIFFICULTY_EDIT && dc != DIFFICULTY_EDIT )
|
||||||
newDC = (Difficulty)(dc+1);
|
continue;
|
||||||
CLAMP( (int&)newDC, 0, NUM_DIFFICULTIES-1 );
|
int iDistance = abs(dc - pSteps->GetDifficulty());
|
||||||
pSteps = GetStepsByDifficulty( st, newDC );
|
if( iDistance < iClosestDistance )
|
||||||
if( pSteps )
|
{
|
||||||
return pSteps;
|
pClosest = pSteps;
|
||||||
newDC = (Difficulty)(dc-2);
|
iClosestDistance = iDistance;
|
||||||
CLAMP( (int&)newDC, 0, NUM_DIFFICULTIES-1 );
|
}
|
||||||
pSteps = GetStepsByDifficulty( st, newDC );
|
}
|
||||||
if( pSteps )
|
|
||||||
return pSteps;
|
return pClosest;
|
||||||
newDC = (Difficulty)(dc+2);
|
|
||||||
CLAMP( (int&)newDC, 0, NUM_DIFFICULTIES-1 );
|
|
||||||
pSteps = GetStepsByDifficulty( st, newDC );
|
|
||||||
return pSteps;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return whether the song is playable in the given style. */
|
/* Return whether the song is playable in the given style. */
|
||||||
|
|||||||
Reference in New Issue
Block a user