(hopefully) bugfix for following bug:
"Also, sorting courses by Average feet has some problems. At on point the order went Trip 5, World Tour, Road of Slow, Road of 2MB. The averages for these are 8.4, 7.89, 7.6, and 8.6. A bit out of order, eh?" NOTE: it has to compare floats, NOT ints. getmeter() doesn't work because it returns an integer, causing loss of decimal places
This commit is contained in:
@@ -841,15 +841,22 @@ static bool CompareCoursePointersByDifficulty(const Course* pCourse1, const Cour
|
|||||||
|
|
||||||
static bool CompareCoursePointersByAvgDifficulty(const Course* pCourse1, const Course* pCourse2)
|
static bool CompareCoursePointersByAvgDifficulty(const Course* pCourse1, const Course* pCourse2)
|
||||||
{
|
{
|
||||||
int iNum1 = pCourse1->GetMeter( false ); // SortOrder_AvgDifficulty;
|
// GLENN: we must use the member variable because getmeter
|
||||||
int iNum2 = pCourse2->GetMeter( false ); // SortOrder_AvgDifficulty;
|
// returns an int, and a loss of precision occurs when that
|
||||||
|
// happens. Anyways, we already have this variable
|
||||||
|
// from updatecoursestats.
|
||||||
|
// Plus players best/courses with randomo courses should
|
||||||
|
// go at the end.
|
||||||
|
|
||||||
if( iNum1 < iNum2 )
|
float fNum1 = pCourse1->SortOrder_AvgDifficulty;
|
||||||
|
float fNum2 = pCourse2->SortOrder_AvgDifficulty;
|
||||||
|
|
||||||
|
if( fNum1 < fNum2 )
|
||||||
return true;
|
return true;
|
||||||
else if( iNum1 > iNum2 )
|
else if( fNum1 > fNum2 )
|
||||||
return false;
|
return false;
|
||||||
else // iNum1 == iNum2
|
else // fNum1 == fNum2
|
||||||
return CompareCoursePointersByAutogen( pCourse1, pCourse2 );
|
return ( pCourse1->m_sName < pCourse2->m_sName );
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool CompareCoursePointersByTotalDifficulty(const Course* pCourse1, const Course* pCourse2)
|
static bool CompareCoursePointersByTotalDifficulty(const Course* pCourse1, const Course* pCourse2)
|
||||||
@@ -920,10 +927,7 @@ bool Course::HasBanner() const
|
|||||||
|
|
||||||
void Course::UpdateCourseStats()
|
void Course::UpdateCourseStats()
|
||||||
{
|
{
|
||||||
LOG->Trace("Updating course stats for %s", this->m_sName.c_str() );
|
|
||||||
|
|
||||||
SortOrder_AvgDifficulty = 0;
|
SortOrder_AvgDifficulty = 0;
|
||||||
// SortOrder_Ranking = 2; // handled in SongManager::UpdateRankingCourses
|
|
||||||
SortOrder_TotalDifficulty = 0;
|
SortOrder_TotalDifficulty = 0;
|
||||||
|
|
||||||
unsigned i;
|
unsigned i;
|
||||||
@@ -953,4 +957,8 @@ void Course::UpdateCourseStats()
|
|||||||
// call it sparingly. Its handled on startup and when
|
// call it sparingly. Its handled on startup and when
|
||||||
// themes change..
|
// themes change..
|
||||||
|
|
||||||
|
LOG->Trace("%s: Total feet: %d, Average Difficulty: %f",
|
||||||
|
this->m_sName.c_str(),
|
||||||
|
SortOrder_TotalDifficulty,
|
||||||
|
SortOrder_AvgDifficulty);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -578,6 +578,11 @@ void MusicWheel::BuildWheelItemDatas( vector<WheelItemData> &arrayWheelItemDatas
|
|||||||
|
|
||||||
if (PREFSMAN->m_iCourseSortOrder != PrefsManager::COURSE_SORT_SONGS)
|
if (PREFSMAN->m_iCourseSortOrder != PrefsManager::COURSE_SORT_SONGS)
|
||||||
{
|
{
|
||||||
|
// update course info first. It must be done here
|
||||||
|
// because doubles stats may differ from singles stats.
|
||||||
|
for(unsigned i = 0; i < apCourses.size(); i++)
|
||||||
|
apCourses[i]->UpdateCourseStats();
|
||||||
|
|
||||||
if (PREFSMAN->m_iCourseSortOrder == PrefsManager::COURSE_SORT_METER)
|
if (PREFSMAN->m_iCourseSortOrder == PrefsManager::COURSE_SORT_METER)
|
||||||
SortCoursePointerArrayByAvgDifficulty( apCourses );
|
SortCoursePointerArrayByAvgDifficulty( apCourses );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user