From 7634898375fdd61602dcaedf0298dfb83e024599 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 20 Jun 2004 16:54:51 +0000 Subject: [PATCH] fix course sort crashes --- stepmania/src/Course.cpp | 4 ++-- stepmania/src/CourseUtil.cpp | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/stepmania/src/Course.cpp b/stepmania/src/Course.cpp index b3a6ac444c..4ab437a854 100644 --- a/stepmania/src/Course.cpp +++ b/stepmania/src/Course.cpp @@ -1008,9 +1008,9 @@ void Course::UpdateCourseStats( StepsType st ) 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 // call it sparingly. Its handled on startup and when diff --git a/stepmania/src/CourseUtil.cpp b/stepmania/src/CourseUtil.cpp index c065adb93b..52f2a07308 100644 --- a/stepmania/src/CourseUtil.cpp +++ b/stepmania/src/CourseUtil.cpp @@ -149,9 +149,8 @@ void CourseUtil::SortCoursePointerArrayByAvgDifficulty( vector &apCours course_sort_val.clear(); for(unsigned i = 0; i < apCourses.size(); ++i) { - Trail* pTrail = apCourses[i]->GetTrail( GAMESTATE->GetCurrentStyleDef()->m_StepsType ); - ASSERT( pTrail ); /* don't give unplayable courses! */ - course_sort_val[apCourses[i]] = (float) pTrail->GetMeter(); + const Trail* pTrail = apCourses[i]->GetTrail( GAMESTATE->GetCurrentStyleDef()->m_StepsType ); + course_sort_val[apCourses[i]] = pTrail != NULL? (float) pTrail->GetMeter(): 0.0f; } sort( apCourses.begin(), apCourses.end(), CompareCoursePointersByTitle ); stable_sort( apCourses.begin(), apCourses.end(), CompareCoursePointersBySortValueAscending );