More loops.
This commit is contained in:
+32
-42
@@ -191,10 +191,10 @@ Character *Profile::GetCharacter() const
|
|||||||
{
|
{
|
||||||
vector<Character*> vpCharacters;
|
vector<Character*> vpCharacters;
|
||||||
CHARMAN->GetCharacters( vpCharacters );
|
CHARMAN->GetCharacters( vpCharacters );
|
||||||
FOREACH_CONST( Character*, vpCharacters, c )
|
for (Character *c : vpCharacters)
|
||||||
{
|
{
|
||||||
if( (*c)->m_sCharacterID.CompareNoCase(m_sCharacterID)==0 )
|
if( c->m_sCharacterID.CompareNoCase(m_sCharacterID)==0 )
|
||||||
return *c;
|
return c;
|
||||||
}
|
}
|
||||||
return CHARMAN->GetDefaultCharacter();
|
return CHARMAN->GetDefaultCharacter();
|
||||||
}
|
}
|
||||||
@@ -247,20 +247,20 @@ int Profile::GetTotalStepsWithTopGrade( StepsType st, Difficulty d, Grade g ) co
|
|||||||
{
|
{
|
||||||
int iCount = 0;
|
int iCount = 0;
|
||||||
|
|
||||||
FOREACH_CONST( Song*, SONGMAN->GetAllSongs(), pSong )
|
for (Song *pSong : SONGMAN->GetAllSongs())
|
||||||
{
|
{
|
||||||
if( !(*pSong)->NormallyDisplayed() )
|
if( !pSong->NormallyDisplayed() )
|
||||||
continue; // skip
|
continue; // skip
|
||||||
|
|
||||||
FOREACH_CONST( Steps*, (*pSong)->GetAllSteps(), pSteps )
|
for (Steps *pSteps : pSong->GetAllSteps())
|
||||||
{
|
{
|
||||||
if( (*pSteps)->m_StepsType != st )
|
if( pSteps->m_StepsType != st )
|
||||||
continue; // skip
|
continue; // skip
|
||||||
|
|
||||||
if( (*pSteps)->GetDifficulty() != d )
|
if( pSteps->GetDifficulty() != d )
|
||||||
continue; // skip
|
continue; // skip
|
||||||
|
|
||||||
const HighScoreList &hsl = GetStepsHighScoreList( *pSong, *pSteps );
|
const HighScoreList &hsl = GetStepsHighScoreList( pSong, pSteps );
|
||||||
if( hsl.vHighScores.empty() )
|
if( hsl.vHighScores.empty() )
|
||||||
continue; // skip
|
continue; // skip
|
||||||
|
|
||||||
@@ -279,18 +279,18 @@ int Profile::GetTotalTrailsWithTopGrade( StepsType st, CourseDifficulty d, Grade
|
|||||||
// add course high scores
|
// add course high scores
|
||||||
vector<Course*> vCourses;
|
vector<Course*> vCourses;
|
||||||
SONGMAN->GetAllCourses( vCourses, false );
|
SONGMAN->GetAllCourses( vCourses, false );
|
||||||
FOREACH_CONST( Course*, vCourses, pCourse )
|
for (Course const *pCourse : vCourses)
|
||||||
{
|
{
|
||||||
// Don't count any course that has any entries that change over time.
|
// Don't count any course that has any entries that change over time.
|
||||||
if( !(*pCourse)->AllSongsAreFixed() )
|
if( !pCourse->AllSongsAreFixed() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
vector<Trail*> vTrails;
|
vector<Trail*> vTrails;
|
||||||
Trail* pTrail = (*pCourse)->GetTrail( st, d );
|
Trail* pTrail = pCourse->GetTrail( st, d );
|
||||||
if( pTrail == NULL )
|
if( pTrail == NULL )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const HighScoreList &hsl = GetCourseHighScoreList( *pCourse, pTrail );
|
const HighScoreList &hsl = GetCourseHighScoreList( pCourse, pTrail );
|
||||||
if( hsl.vHighScores.empty() )
|
if( hsl.vHighScores.empty() )
|
||||||
continue; // skip
|
continue; // skip
|
||||||
|
|
||||||
@@ -397,32 +397,24 @@ static void GetHighScoreCourses( vector<Course*> &vpCoursesOut )
|
|||||||
|
|
||||||
vector<Course*> vpCourses;
|
vector<Course*> vpCourses;
|
||||||
SONGMAN->GetAllCourses( vpCourses, false );
|
SONGMAN->GetAllCourses( vpCourses, false );
|
||||||
FOREACH_CONST( Course*, vpCourses, c )
|
|
||||||
|
for (Course *c : vpCourses)
|
||||||
{
|
{
|
||||||
// Don't count any course that has any entries that change over time.
|
// Don't count any course that has any entries that change over time.
|
||||||
if( !(*c)->AllSongsAreFixed() )
|
if( !c->AllSongsAreFixed() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
vpCoursesOut.push_back( *c );
|
vpCoursesOut.push_back( c );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float Profile::GetCoursesPossible( StepsType st, CourseDifficulty cd ) const
|
float Profile::GetCoursesPossible( StepsType st, CourseDifficulty cd ) const
|
||||||
{
|
{
|
||||||
int iTotalTrails = 0;
|
|
||||||
|
|
||||||
vector<Course*> vpCourses;
|
vector<Course*> vpCourses;
|
||||||
GetHighScoreCourses( vpCourses );
|
GetHighScoreCourses( vpCourses );
|
||||||
FOREACH_CONST( Course*, vpCourses, c )
|
return std::count_if(vpCourses.begin(), vpCourses.end(), [&](Course const *c) {
|
||||||
{
|
return c->GetTrail(st, cd) != nullptr;
|
||||||
Trail* pTrail = (*c)->GetTrail(st,cd);
|
});
|
||||||
if( pTrail == NULL )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
iTotalTrails++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (float) iTotalTrails;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float Profile::GetCoursesActual( StepsType st, CourseDifficulty cd ) const
|
float Profile::GetCoursesActual( StepsType st, CourseDifficulty cd ) const
|
||||||
@@ -431,13 +423,13 @@ float Profile::GetCoursesActual( StepsType st, CourseDifficulty cd ) const
|
|||||||
|
|
||||||
vector<Course*> vpCourses;
|
vector<Course*> vpCourses;
|
||||||
GetHighScoreCourses( vpCourses );
|
GetHighScoreCourses( vpCourses );
|
||||||
FOREACH_CONST( Course*, vpCourses, c )
|
for (Course const *c : vpCourses)
|
||||||
{
|
{
|
||||||
Trail *pTrail = (*c)->GetTrail( st, cd );
|
Trail *pTrail = c->GetTrail( st, cd );
|
||||||
if( pTrail == NULL )
|
if( pTrail == NULL )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const HighScoreList& hsl = GetCourseHighScoreList( *c, pTrail );
|
const HighScoreList& hsl = GetCourseHighScoreList( c, pTrail );
|
||||||
fTotalPercents += hsl.GetTopScore().GetPercentDP();
|
fTotalPercents += hsl.GetTopScore().GetPercentDP();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -624,12 +616,10 @@ bool Profile::HasPassedSteps( const Song* pSong, const Steps* pSteps ) const
|
|||||||
|
|
||||||
bool Profile::HasPassedAnyStepsInSong( const Song* pSong ) const
|
bool Profile::HasPassedAnyStepsInSong( const Song* pSong ) const
|
||||||
{
|
{
|
||||||
FOREACH_CONST( Steps*, pSong->GetAllSteps(), steps )
|
auto const &steps = pSong->GetAllSteps();
|
||||||
{
|
return std::any_of(steps.begin(), steps.end(), [&](Steps const *s) {
|
||||||
if( HasPassedSteps( pSong, *steps ) )
|
return HasPassedSteps(pSong, s);
|
||||||
return true;
|
});
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Profile::IncrementStepsPlayCount( const Song* pSong, const Steps* pSteps )
|
void Profile::IncrementStepsPlayCount( const Song* pSong, const Steps* pSteps )
|
||||||
@@ -1526,13 +1516,13 @@ void Profile::LoadCourseScoresFromNode( const XNode* pCourseScores )
|
|||||||
splitpath( courseID.GetPath(), sDir, sFName, sExt );
|
splitpath( courseID.GetPath(), sDir, sFName, sExt );
|
||||||
RString sFullFileName = sFName + sExt;
|
RString sFullFileName = sFName + sExt;
|
||||||
|
|
||||||
FOREACH_CONST( Course*, vpAllCourses, c )
|
for (Course *c : vpAllCourses)
|
||||||
{
|
{
|
||||||
RString sOther = (*c)->m_sPath.Right(sFullFileName.size());
|
RString sOther = c->m_sPath.Right(sFullFileName.size());
|
||||||
|
|
||||||
if( sFullFileName.CompareNoCase(sOther) == 0 )
|
if( sFullFileName.CompareNoCase(sOther) == 0 )
|
||||||
{
|
{
|
||||||
pC = *c;
|
pC = c;
|
||||||
courseID.FromCourse( pC );
|
courseID.FromCourse( pC );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1678,9 +1668,9 @@ XNode* Profile::SaveScreenshotDataCreateNode() const
|
|||||||
|
|
||||||
XNode* pNode = new XNode( "ScreenshotData" );
|
XNode* pNode = new XNode( "ScreenshotData" );
|
||||||
|
|
||||||
FOREACH_CONST( Screenshot, m_vScreenshots, ss )
|
for (Screenshot const &ss : m_vScreenshots)
|
||||||
{
|
{
|
||||||
pNode->AppendChild( ss->CreateNode() );
|
pNode->AppendChild( ss.CreateNode() );
|
||||||
}
|
}
|
||||||
|
|
||||||
return pNode;
|
return pNode;
|
||||||
|
|||||||
Reference in New Issue
Block a user