Back compat hack to fix importing scores for courses that have moved into group dirs
This commit is contained in:
@@ -26,6 +26,7 @@ namespace CourseUtil
|
|||||||
|
|
||||||
class CourseID
|
class CourseID
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
CString sPath;
|
CString sPath;
|
||||||
CString sFullTitle;
|
CString sFullTitle;
|
||||||
|
|
||||||
|
|||||||
@@ -1338,6 +1338,9 @@ void Profile::LoadCourseScoresFromNode( const XNode* pCourseScores )
|
|||||||
|
|
||||||
ASSERT( pCourseScores->m_sName == "CourseScores" );
|
ASSERT( pCourseScores->m_sName == "CourseScores" );
|
||||||
|
|
||||||
|
vector<Course*> vpAllCourses;
|
||||||
|
SONGMAN->GetAllCourses( vpAllCourses, true );
|
||||||
|
|
||||||
FOREACH_CONST_Child( pCourseScores, pCourse )
|
FOREACH_CONST_Child( pCourseScores, pCourse )
|
||||||
{
|
{
|
||||||
if( pCourse->m_sName != "Course" )
|
if( pCourse->m_sName != "Course" )
|
||||||
@@ -1348,6 +1351,35 @@ void Profile::LoadCourseScoresFromNode( const XNode* pCourseScores )
|
|||||||
if( !courseID.IsValid() )
|
if( !courseID.IsValid() )
|
||||||
WARN_AND_CONTINUE;
|
WARN_AND_CONTINUE;
|
||||||
|
|
||||||
|
|
||||||
|
// Backward compatability hack to fix importing scores of old style
|
||||||
|
// courses that weren't in group folder but have now been moved into
|
||||||
|
// a group folder:
|
||||||
|
// If the courseID doesn't resolve, then take the file name part of sPath
|
||||||
|
// and search for matches of just the file name.
|
||||||
|
{
|
||||||
|
Course *pC = courseID.ToCourse();
|
||||||
|
if( pC == NULL )
|
||||||
|
{
|
||||||
|
CString sDir, sFName, sExt;
|
||||||
|
splitpath( courseID.sPath, sDir, sFName, sExt );
|
||||||
|
CString sFullFileName = sFName + sExt;
|
||||||
|
|
||||||
|
FOREACH_CONST( Course*, vpAllCourses, c )
|
||||||
|
{
|
||||||
|
CString sOther = (*c)->m_sPath.Right(sFullFileName.size());
|
||||||
|
|
||||||
|
if( sFullFileName.CompareNoCase(sOther) == 0 )
|
||||||
|
{
|
||||||
|
pC = *c;
|
||||||
|
courseID.FromCourse( pC );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
FOREACH_CONST_Child( pCourse, pTrail )
|
FOREACH_CONST_Child( pCourse, pTrail )
|
||||||
{
|
{
|
||||||
if( pTrail->m_sName != "Trail" )
|
if( pTrail->m_sName != "Trail" )
|
||||||
|
|||||||
@@ -1065,9 +1065,11 @@ Course* SongManager::GetCourseFromPath( CString sPath )
|
|||||||
if( sPath == "" )
|
if( sPath == "" )
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
for( unsigned int i=0; i<m_pCourses.size(); i++ )
|
FOREACH_CONST( Course*, m_pCourses, c )
|
||||||
if( sPath.CompareNoCase(m_pCourses[i]->m_sPath) == 0 )
|
{
|
||||||
return m_pCourses[i];
|
if( sPath.CompareNoCase((*c)->m_sPath) == 0 )
|
||||||
|
return *c;
|
||||||
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user