From a84d30b92e34d72c3b5f2d155cca92f886bdf553 Mon Sep 17 00:00:00 2001 From: Charles Lohr Date: Wed, 17 May 2006 06:49:55 +0000 Subject: [PATCH] Fix crash from MusicWheel when in BuildWheelItemData(), and under case SORT_ENDLESS_COURSES. Automatically generated courses will cause there to be no group name, and the default (preferred) sort. When this function does not return a value, and it gets assigned to c (In MusicWheel), in some cases we will get a crash. By default, I use white in the metrics, this doesn't look "great," but it should be up to the themer. --- stepmania/Themes/default/metrics.ini | 1 + stepmania/src/Course.cpp | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/stepmania/Themes/default/metrics.ini b/stepmania/Themes/default/metrics.ini index a173c14c50..9235a2d490 100644 --- a/stepmania/Themes/default/metrics.ini +++ b/stepmania/Themes/default/metrics.ini @@ -4365,6 +4365,7 @@ WriteSimpleValues=1 TapsAndHolds=1 [Course] +SortPreferredColor=1,1,1,1 //Preferred is both for when courses are in preferred sort, or are autogen SortLevel1Color=1,0,0,1 SortLevel2Color=1,1,0,1 SortLevel3Color=1,0.5,0,1 diff --git a/stepmania/src/Course.cpp b/stepmania/src/Course.cpp index e9231a39c7..049b10ebc0 100644 --- a/stepmania/src/Course.cpp +++ b/stepmania/src/Course.cpp @@ -51,6 +51,7 @@ XToLocalizedString( SongSort ); /* Maximum lower value of ranges when difficult: */ const int MAX_BOTTOM_RANGE = 10; +#define SORT_PREFERRED_COLOR THEME->GetMetricC("Course","SortPreferredColor") #define SORT_LEVEL1_COLOR THEME->GetMetricC("Course","SortLevel1Color") #define SORT_LEVEL2_COLOR THEME->GetMetricC("Course","SortLevel2Color") #define SORT_LEVEL3_COLOR THEME->GetMetricC("Course","SortLevel3Color") @@ -729,7 +730,8 @@ RageColor Course::GetColor() const switch( PREFSMAN->m_CourseSortOrder ) { case PrefsManager::COURSE_SORT_PREFERRED: - break; + return SORT_PREFERRED_COLOR; //This will also be used for autogen'd courses in some cases. + case PrefsManager::COURSE_SORT_SONGS: if( m_vEntries.size() >= 7 ) return SORT_LEVEL2_COLOR; else if( m_vEntries.size() >= 4 ) return SORT_LEVEL4_COLOR;