Clean up some sorts; use multiple stable_sorts for multi-level
sorts, instead of hardcoding the order in the compare functions. Don't consider challenge > hard for extra stages.
This commit is contained in:
+6
-11
@@ -187,25 +187,20 @@ bool CompareNotesPointersByRadarValues(const Notes* pNotes1, const Notes* pNotes
|
|||||||
|
|
||||||
bool CompareNotesPointersByMeter(const Notes *pNotes1, const Notes* pNotes2)
|
bool CompareNotesPointersByMeter(const Notes *pNotes1, const Notes* pNotes2)
|
||||||
{
|
{
|
||||||
if( pNotes1->GetMeter() < pNotes2->GetMeter() )
|
return pNotes1->GetMeter() < pNotes2->GetMeter();
|
||||||
return true;
|
|
||||||
if( pNotes1->GetMeter() > pNotes2->GetMeter() )
|
|
||||||
return false;
|
|
||||||
return CompareNotesPointersByRadarValues( pNotes1, pNotes2 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CompareNotesPointersByDifficulty(const Notes *pNotes1, const Notes *pNotes2)
|
bool CompareNotesPointersByDifficulty(const Notes *pNotes1, const Notes *pNotes2)
|
||||||
{
|
{
|
||||||
if( pNotes1->GetDifficulty() < pNotes2->GetDifficulty() )
|
return pNotes1->GetDifficulty() < pNotes2->GetDifficulty();
|
||||||
return true;
|
|
||||||
if( pNotes1->GetDifficulty() > pNotes2->GetDifficulty() )
|
|
||||||
return false;
|
|
||||||
return CompareNotesPointersByMeter( pNotes1, pNotes2 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SortNotesArrayByDifficulty( vector<Notes*> &arraySteps )
|
void SortNotesArrayByDifficulty( vector<Notes*> &arraySteps )
|
||||||
{
|
{
|
||||||
sort( arraySteps.begin(), arraySteps.end(), CompareNotesPointersByDifficulty );
|
/* Sort in reverse order of priority. */
|
||||||
|
stable_sort( arraySteps.begin(), arraySteps.end(), CompareNotesPointersByRadarValues );
|
||||||
|
stable_sort( arraySteps.begin(), arraySteps.end(), CompareNotesPointersByMeter );
|
||||||
|
stable_sort( arraySteps.begin(), arraySteps.end(), CompareNotesPointersByDifficulty );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Notes::Decompress() const
|
void Notes::Decompress() const
|
||||||
|
|||||||
@@ -91,6 +91,8 @@ protected:
|
|||||||
void DeAutogen();
|
void DeAutogen();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool CompareNotesPointersByRadarValues(const Notes* pNotes1, const Notes* pNotes2);
|
||||||
|
bool CompareNotesPointersByMeter(const Notes *pNotes1, const Notes* pNotes2);
|
||||||
bool CompareNotesPointersByDifficulty(const Notes *pNotes1, const Notes *pNotes2);
|
bool CompareNotesPointersByDifficulty(const Notes *pNotes1, const Notes *pNotes2);
|
||||||
void SortNotesArrayByDifficulty( vector<Notes*> &arrayNotess );
|
void SortNotesArrayByDifficulty( vector<Notes*> &arrayNotess );
|
||||||
|
|
||||||
|
|||||||
@@ -537,6 +537,24 @@ bool SongManager::GetExtraStageInfoFromCourse( bool bExtra2, CString sPreferredG
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return true if n1 < n2. */
|
||||||
|
bool CompareNotesPointersForExtra(const Notes *n1, const Notes *n2)
|
||||||
|
{
|
||||||
|
/* Equate CHALLENGE to HARD. */
|
||||||
|
Difficulty d1 = min(n1->GetDifficulty(), DIFFICULTY_HARD);
|
||||||
|
Difficulty d2 = min(n2->GetDifficulty(), DIFFICULTY_HARD);
|
||||||
|
|
||||||
|
if(d1 < d2) return true;
|
||||||
|
if(d1 > d2) return false;
|
||||||
|
/* n1 difficulty == n2 difficulty */
|
||||||
|
|
||||||
|
if(CompareNotesPointersByMeter(n1,n2)) return true;
|
||||||
|
if(CompareNotesPointersByMeter(n2,n1)) return false;
|
||||||
|
/* n1 meter == n2 meter */
|
||||||
|
|
||||||
|
return CompareNotesPointersByRadarValues(n1,n2);
|
||||||
|
}
|
||||||
|
|
||||||
void SongManager::GetExtraStageInfo( bool bExtra2, CString sPreferredGroup, const StyleDef *sd,
|
void SongManager::GetExtraStageInfo( bool bExtra2, CString sPreferredGroup, const StyleDef *sd,
|
||||||
Song*& pSongOut, Notes*& pNotesOut, PlayerOptions& po_out, SongOptions& so_out )
|
Song*& pSongOut, Notes*& pNotesOut, PlayerOptions& po_out, SongOptions& so_out )
|
||||||
{
|
{
|
||||||
@@ -562,7 +580,7 @@ void SongManager::GetExtraStageInfo( bool bExtra2, CString sPreferredGroup, cons
|
|||||||
{
|
{
|
||||||
Notes* pNotes = apNotes[n];
|
Notes* pNotes = apNotes[n];
|
||||||
|
|
||||||
if( pExtra1Notes == NULL || CompareNotesPointersByDifficulty(pExtra1Notes,pNotes) ) // pNotes is harder than pHardestNotes
|
if( pExtra1Notes == NULL || CompareNotesPointersForExtra(pExtra1Notes,pNotes) ) // pNotes is harder than pHardestNotes
|
||||||
{
|
{
|
||||||
pExtra1Song = pSong;
|
pExtra1Song = pSong;
|
||||||
pExtra1Notes = pNotes;
|
pExtra1Notes = pNotes;
|
||||||
@@ -571,7 +589,7 @@ void SongManager::GetExtraStageInfo( bool bExtra2, CString sPreferredGroup, cons
|
|||||||
// for extra 2, we don't want to choose the hardest notes possible. So, we'll disgard Notes with meter > 8
|
// for extra 2, we don't want to choose the hardest notes possible. So, we'll disgard Notes with meter > 8
|
||||||
if( bExtra2 && pNotes->GetMeter() > 8 )
|
if( bExtra2 && pNotes->GetMeter() > 8 )
|
||||||
continue; // skip
|
continue; // skip
|
||||||
if( pExtra2Notes == NULL || CompareNotesPointersByDifficulty(pExtra2Notes,pNotes) ) // pNotes is harder than pHardestNotes
|
if( pExtra2Notes == NULL || CompareNotesPointersForExtra(pExtra2Notes,pNotes) ) // pNotes is harder than pHardestNotes
|
||||||
{
|
{
|
||||||
pExtra2Song = pSong;
|
pExtra2Song = pSong;
|
||||||
pExtra2Notes = pNotes;
|
pExtra2Notes = pNotes;
|
||||||
|
|||||||
Reference in New Issue
Block a user