Loops and a non mac goodie.
This commit is contained in:
+22
-17
@@ -206,11 +206,11 @@ void CourseUtil::SortByMostRecentlyPlayedForMachine( vector<Course*> &vpCoursesI
|
||||
{
|
||||
Profile *pProfile = PROFILEMAN->GetMachineProfile();
|
||||
|
||||
FOREACH_CONST( Course*, vpCoursesInOut, c )
|
||||
for (Course const * c: vpCoursesInOut)
|
||||
{
|
||||
int iNumTimesPlayed = pProfile->GetCourseNumTimesPlayed( *c );
|
||||
RString val = iNumTimesPlayed ? pProfile->GetCourseLastPlayedDateTime(*c).GetString() : "9999999999999";
|
||||
course_sort_val[*c] = val;
|
||||
int iNumTimesPlayed = pProfile->GetCourseNumTimesPlayed( c );
|
||||
RString val = iNumTimesPlayed ? pProfile->GetCourseLastPlayedDateTime(c).GetString() : "9999999999999";
|
||||
course_sort_val[c] = val;
|
||||
}
|
||||
|
||||
stable_sort( vpCoursesInOut.begin(), vpCoursesInOut.end(), CompareCoursePointersBySortValueAscending );
|
||||
@@ -327,12 +327,12 @@ void CourseUtil::WarnOnInvalidMods( RString sMods )
|
||||
SongOptions so;
|
||||
vector<RString> vs;
|
||||
split( sMods, ",", vs, true );
|
||||
FOREACH_CONST( RString, vs, s )
|
||||
for (RString const &s : vs)
|
||||
{
|
||||
bool bValid = false;
|
||||
RString sErrorDetail;
|
||||
bValid |= po.FromOneModString( *s, sErrorDetail );
|
||||
bValid |= so.FromOneModString( *s, sErrorDetail );
|
||||
bValid |= po.FromOneModString( s, sErrorDetail );
|
||||
bValid |= so.FromOneModString( s, sErrorDetail );
|
||||
/* ==Invalid options that used to be valid==
|
||||
* all noteskins (solo, note, foon, &c.)
|
||||
* protiming (done in Lua now)
|
||||
@@ -346,7 +346,7 @@ void CourseUtil::WarnOnInvalidMods( RString sMods )
|
||||
*/
|
||||
if( !bValid )
|
||||
{
|
||||
RString sFullError = ssprintf("Error processing '%s' in '%s'", (*s).c_str(), sMods.c_str() );
|
||||
RString sFullError = ssprintf("Error processing '%s' in '%s'", s.c_str(), sMods.c_str() );
|
||||
if( !sErrorDetail.empty() )
|
||||
sFullError += ": " + sErrorDetail;
|
||||
LOG->UserLog( "", "", "%s", sFullError.c_str() );
|
||||
@@ -431,12 +431,12 @@ bool EditCourseUtil::ValidateEditCourseName( const RString &sAnswer, RString &sE
|
||||
// Check for name conflicts
|
||||
vector<Course*> vpCourses;
|
||||
EditCourseUtil::GetAllEditCourses( vpCourses );
|
||||
FOREACH_CONST( Course*, vpCourses, p )
|
||||
for (Course const *p : vpCourses)
|
||||
{
|
||||
if( GAMESTATE->m_pCurCourse == *p )
|
||||
if( GAMESTATE->m_pCurCourse == p )
|
||||
continue; // don't comepare name against ourself
|
||||
|
||||
if( (*p)->GetDisplayFullTitle() == sAnswer )
|
||||
if( p->GetDisplayFullTitle() == sAnswer )
|
||||
{
|
||||
sErrorOut = EDIT_NAME_CONFLICTS;
|
||||
return false;
|
||||
@@ -471,10 +471,10 @@ void EditCourseUtil::GetAllEditCourses( vector<Course*> &vpCoursesOut )
|
||||
{
|
||||
vector<Course*> vpCoursesTemp;
|
||||
SONGMAN->GetAllCourses( vpCoursesTemp, false );
|
||||
FOREACH_CONST( Course*, vpCoursesTemp, c )
|
||||
for (Course *c : vpCoursesTemp)
|
||||
{
|
||||
if( (*c)->GetLoadedFromProfileSlot() != ProfileSlot_Invalid )
|
||||
vpCoursesOut.push_back( *c );
|
||||
if( c->GetLoadedFromProfileSlot() != ProfileSlot_Invalid )
|
||||
vpCoursesOut.push_back( c );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -489,13 +489,15 @@ void EditCourseUtil::LoadDefaults( Course &out )
|
||||
for( int i=0; i<10000; i++ )
|
||||
{
|
||||
out.m_sMainTitle = ssprintf("Workout %d", i+1);
|
||||
bool bNameInUse = false;
|
||||
|
||||
vector<Course*> vpCourses;
|
||||
EditCourseUtil::GetAllEditCourses( vpCourses );
|
||||
FOREACH_CONST( Course*, vpCourses, p )
|
||||
|
||||
#ifdef MACOSX
|
||||
bool bNameInUse = false;
|
||||
for (Course const *p : vpCourses)
|
||||
{
|
||||
if( out.m_sMainTitle == (*p)->m_sMainTitle )
|
||||
if( out.m_sMainTitle == p->m_sMainTitle )
|
||||
{
|
||||
bNameInUse = true;
|
||||
break;
|
||||
@@ -503,6 +505,9 @@ void EditCourseUtil::LoadDefaults( Course &out )
|
||||
}
|
||||
|
||||
if( !bNameInUse )
|
||||
#else
|
||||
if (std::any_of(vpCourses.begin(), vpCourses.end(), [&](Course const *p) { return out.m_sMainTitle == p->m_sMainTitle; }))
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user