From 0506fee3a75a5c89fe555f7d4fc35233c7d4c254 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Fri, 9 Sep 2005 02:22:18 +0000 Subject: [PATCH] optimization: avoid GetTrail when meter specified --- stepmania/src/Course.cpp | 10 ++++++++++ stepmania/src/Course.h | 2 +- stepmania/src/CourseUtil.cpp | 4 ++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/stepmania/src/Course.cpp b/stepmania/src/Course.cpp index d0070016bf..829c181e09 100644 --- a/stepmania/src/Course.cpp +++ b/stepmania/src/Course.cpp @@ -792,6 +792,16 @@ void Course::GetAllTrails( vector &AddTo ) const } } +int Course::GetMeter( StepsType st, CourseDifficulty cd ) const +{ + if( m_iCustomMeter[cd] != -1 ) + return m_iCustomMeter[cd]; + const Trail* pTrail = GetTrail( st ); + if( pTrail != NULL ) + return pTrail->GetMeter(); + return 0; +} + bool Course::HasMods() const { FOREACH_CONST( CourseEntry, m_vEntries, e ) diff --git a/stepmania/src/Course.h b/stepmania/src/Course.h index 2073403761..63c22df952 100644 --- a/stepmania/src/Course.h +++ b/stepmania/src/Course.h @@ -147,7 +147,7 @@ public: Trail* GetTrailForceRegenCache( StepsType st, CourseDifficulty cd=DIFFICULTY_MEDIUM ) const; void GetTrails( vector &AddTo, StepsType st ) const; void GetAllTrails( vector &AddTo ) const; - float GetMeter( StepsType st, CourseDifficulty cd=DIFFICULTY_MEDIUM ) const; + int GetMeter( StepsType st, CourseDifficulty cd=DIFFICULTY_MEDIUM ) const; bool HasMods() const; bool AllSongsAreFixed() const; diff --git a/stepmania/src/CourseUtil.cpp b/stepmania/src/CourseUtil.cpp index 40bcd845bd..7fba4d328a 100644 --- a/stepmania/src/CourseUtil.cpp +++ b/stepmania/src/CourseUtil.cpp @@ -147,8 +147,8 @@ void CourseUtil::SortCoursePointerArrayByAvgDifficulty( vector &vpCours course_sort_val.clear(); for( unsigned i = 0; i < vpCoursesInOut.size(); ++i ) { - const Trail* pTrail = vpCoursesInOut[i]->GetTrail( GAMESTATE->GetCurrentStyle()->m_StepsType ); - course_sort_val[vpCoursesInOut[i]] = ssprintf("%09.3f", pTrail != NULL? (float) pTrail->GetMeter(): 0.0f); + int iMeter = vpCoursesInOut[i]->GetMeter( GAMESTATE->GetCurrentStyle()->m_StepsType, DIFFICULTY_MEDIUM ); + course_sort_val[vpCoursesInOut[i]] = ssprintf( "%06i", iMeter ); } sort( vpCoursesInOut.begin(), vpCoursesInOut.end(), CompareCoursePointersByTitle ); stable_sort( vpCoursesInOut.begin(), vpCoursesInOut.end(), CompareCoursePointersBySortValueAscending );