diff --git a/stepmania/src/Course.cpp b/stepmania/src/Course.cpp index 00988a6dc7..a2a102e78e 100644 --- a/stepmania/src/Course.cpp +++ b/stepmania/src/Course.cpp @@ -870,6 +870,36 @@ static bool CompareCoursePointersByTotalDifficulty(const Course* pCourse1, const return CompareCoursePointersByAutogen( pCourse1, pCourse2 ); } +bool Course::CourseHasBestOrWorst() const +{ + for(unsigned i = 0; i < m_entries.size(); i++) + { + switch( m_entries[i].type ) + { + case COURSE_ENTRY_BEST: + case COURSE_ENTRY_WORST: + return true; + } + + } + + return false; +} + +static bool MovePlayersBestToEnd( const Course* pCourse1, const Course* pCourse2 ) +{ + bool C1HasBest = pCourse1->CourseHasBestOrWorst(); + bool C2HasBest = pCourse2->CourseHasBestOrWorst(); + if( !C1HasBest && !C2HasBest ) + return false; + if( C1HasBest && !C2HasBest ) + return false; + if( !C1HasBest && C2HasBest ) + return true; + + return pCourse1->m_sName < pCourse2->m_sName; +} + static bool CompareCoursePointersByRanking(const Course* pCourse1, const Course* pCourse2) { int iNum1 = pCourse1->SortOrder_Ranking; @@ -898,6 +928,7 @@ void SortCoursePointerArrayByRanking( vector &apCourses ) void SortCoursePointerArrayByAvgDifficulty( vector &apCourses ) { sort( apCourses.begin(), apCourses.end(), CompareCoursePointersByAvgDifficulty ); + stable_sort( apCourses.begin(), apCourses.end(), MovePlayersBestToEnd ); } void SortCoursePointerArrayByTotalDifficulty( vector &apCourses ) diff --git a/stepmania/src/Course.h b/stepmania/src/Course.h index ea3ef777e9..5db1d261f7 100644 --- a/stepmania/src/Course.h +++ b/stepmania/src/Course.h @@ -108,6 +108,7 @@ public: int GetEstimatedNumStages() const { return m_entries.size(); } bool HasDifficult( StepsType nt ) const; bool IsPlayableIn( StepsType nt ) const; + bool CourseHasBestOrWorst() const; RageColor GetColor() const; Difficulty GetDifficulty( const Info &stage ) const; void GetMeterRange( const Info &stage, int& iMeterLowOut, int& iMeterHighOut ) const;