fix grade sorts too

This commit is contained in:
AJ Kelly
2011-03-13 20:33:42 -05:00
parent 919279938e
commit de77a3ac1f
+8 -27
View File
@@ -460,10 +460,6 @@ static bool CompAscending( const pair<Song *, RString> &a, const pair<Song *, RS
void SongUtil::SortSongPointerArrayByGrades( vector<Song*> &vpSongsInOut, bool bDescending ) void SongUtil::SortSongPointerArrayByGrades( vector<Song*> &vpSongsInOut, bool bDescending )
{ {
StepsType st;
Difficulty dc;
SongUtil::GetStepsTypeAndDifficultyFromSortOrder( SORT_EASY_METER, st, dc );
/* Optimize by pre-writing a string to compare, since doing /* Optimize by pre-writing a string to compare, since doing
* GetNumNotesWithGrade inside the sort is too slow. */ * GetNumNotesWithGrade inside the sort is too slow. */
typedef pair< Song *, RString > val; typedef pair< Song *, RString > val;
@@ -477,7 +473,7 @@ void SongUtil::SortSongPointerArrayByGrades( vector<Song*> &vpSongsInOut, bool b
int iCounts[NUM_Grade]; int iCounts[NUM_Grade];
const Profile *pProfile = PROFILEMAN->GetMachineProfile(); const Profile *pProfile = PROFILEMAN->GetMachineProfile();
ASSERT( pProfile ); ASSERT( pProfile );
pProfile->GetGrades( pSong, st, iCounts ); pProfile->GetGrades( pSong, GAMESTATE->GetCurrentStyle()->m_StepsType, iCounts );
RString foo; RString foo;
foo.reserve(256); foo.reserve(256);
@@ -621,12 +617,8 @@ RString SongUtil::GetSectionNameFromSongAndSort( const Song* pSong, SortOrder so
return RString(); return RString();
case SORT_TOP_GRADES: case SORT_TOP_GRADES:
{ {
StepsType st;
Difficulty dc;
SongUtil::GetStepsTypeAndDifficultyFromSortOrder( so, st, dc );
int iCounts[NUM_Grade]; int iCounts[NUM_Grade];
PROFILEMAN->GetMachineProfile()->GetGrades( pSong, st, iCounts ); PROFILEMAN->GetMachineProfile()->GetGrades( pSong, GAMESTATE->GetCurrentStyle()->m_StepsType, iCounts );
for( int i=Grade_Tier01; i<NUM_Grade; ++i ) for( int i=Grade_Tier01; i<NUM_Grade; ++i )
{ {
@@ -973,7 +965,6 @@ bool SongUtil::GetStepsTypeAndDifficultyFromSortOrder( SortOrder so, StepsType &
return false; return false;
} }
bool bDoubles = false;
switch( so ) switch( so )
{ {
DEFAULT_FAIL( so ); DEFAULT_FAIL( so );
@@ -982,38 +973,28 @@ bool SongUtil::GetStepsTypeAndDifficultyFromSortOrder( SortOrder so, StepsType &
case SORT_MEDIUM_METER: case SORT_MEDIUM_METER:
case SORT_HARD_METER: case SORT_HARD_METER:
case SORT_CHALLENGE_METER: case SORT_CHALLENGE_METER:
bDoubles = false; stOut = GAMESTATE->GetCurrentStyle()->m_StepsType;
break; break;
case SORT_DOUBLE_EASY_METER: case SORT_DOUBLE_EASY_METER:
case SORT_DOUBLE_MEDIUM_METER: case SORT_DOUBLE_MEDIUM_METER:
case SORT_DOUBLE_HARD_METER: case SORT_DOUBLE_HARD_METER:
case SORT_DOUBLE_CHALLENGE_METER: case SORT_DOUBLE_CHALLENGE_METER:
bDoubles = true; stOut = GAMESTATE->GetCurrentStyle()->m_StepsType; // in case we don't find any matches below
break;
}
stOut = StepsType_Invalid;
vector<const Style*> vpStyles; vector<const Style*> vpStyles;
GAMEMAN->GetStylesForGame(GAMESTATE->m_pCurGame,vpStyles); GAMEMAN->GetStylesForGame(GAMESTATE->m_pCurGame,vpStyles);
FOREACH_CONST( const Style*, vpStyles, i ) FOREACH_CONST( const Style*, vpStyles, i )
{ {
if( !(*i)->m_bUsedForGameplay ) if( (*i)->m_StyleType == StyleType_OnePlayerTwoSides )
continue; {
if( bDoubles && (*i)->m_StyleType != StyleType_OnePlayerTwoSides )
continue;
if( !bDoubles && (*i)->m_StyleType != StyleType_OnePlayerOneSide && (*i)->m_StyleType != StyleType_TwoPlayersTwoSides )
continue;
// Ugly hack to ignore pump's half-double. // Ugly hack to ignore pump's half-double.
bool bContainsHalf = ((RString)(*i)->m_szName).find("half") != RString::npos; bool bContainsHalf = ((RString)(*i)->m_szName).find("half") != RString::npos;
if( bContainsHalf ) if( bContainsHalf )
continue; continue;
stOut = (*i)->m_StepsType; stOut = (*i)->m_StepsType;
break; break;
} }
}
}
return true; return true;
} }