fix course sort crashes

This commit is contained in:
Glenn Maynard
2004-06-20 16:54:51 +00:00
parent f15212a563
commit 7634898375
2 changed files with 4 additions and 5 deletions
+2 -2
View File
@@ -1008,9 +1008,9 @@ void Course::UpdateCourseStats( StepsType st )
return; return;
} }
Trail* pTrail = GetTrail( st, DIFFICULTY_MEDIUM ); const Trail* pTrail = GetTrail( st, DIFFICULTY_MEDIUM );
m_SortOrder_TotalDifficulty += pTrail->GetTotalMeter(); m_SortOrder_TotalDifficulty += pTrail != NULL? pTrail->GetTotalMeter():0;
// OPTIMIZATION: Ranking info isn't dependant on style, so // OPTIMIZATION: Ranking info isn't dependant on style, so
// call it sparingly. Its handled on startup and when // call it sparingly. Its handled on startup and when
+2 -3
View File
@@ -149,9 +149,8 @@ void CourseUtil::SortCoursePointerArrayByAvgDifficulty( vector<Course*> &apCours
course_sort_val.clear(); course_sort_val.clear();
for(unsigned i = 0; i < apCourses.size(); ++i) for(unsigned i = 0; i < apCourses.size(); ++i)
{ {
Trail* pTrail = apCourses[i]->GetTrail( GAMESTATE->GetCurrentStyleDef()->m_StepsType ); const Trail* pTrail = apCourses[i]->GetTrail( GAMESTATE->GetCurrentStyleDef()->m_StepsType );
ASSERT( pTrail ); /* don't give unplayable courses! */ course_sort_val[apCourses[i]] = pTrail != NULL? (float) pTrail->GetMeter(): 0.0f;
course_sort_val[apCourses[i]] = (float) pTrail->GetMeter();
} }
sort( apCourses.begin(), apCourses.end(), CompareCoursePointersByTitle ); sort( apCourses.begin(), apCourses.end(), CompareCoursePointersByTitle );
stable_sort( apCourses.begin(), apCourses.end(), CompareCoursePointersBySortValueAscending ); stable_sort( apCourses.begin(), apCourses.end(), CompareCoursePointersBySortValueAscending );