optimization: avoid GetTrail when meter specified

This commit is contained in:
Glenn Maynard
2005-09-09 02:22:18 +00:00
parent 522c37014d
commit 0506fee3a7
3 changed files with 13 additions and 3 deletions
+10
View File
@@ -792,6 +792,16 @@ void Course::GetAllTrails( vector<Trail*> &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 )
+1 -1
View File
@@ -147,7 +147,7 @@ public:
Trail* GetTrailForceRegenCache( StepsType st, CourseDifficulty cd=DIFFICULTY_MEDIUM ) const;
void GetTrails( vector<Trail*> &AddTo, StepsType st ) const;
void GetAllTrails( vector<Trail*> &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;
+2 -2
View File
@@ -147,8 +147,8 @@ void CourseUtil::SortCoursePointerArrayByAvgDifficulty( vector<Course*> &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 );