Back compat hack to fix importing scores for courses that have moved into group dirs

This commit is contained in:
Chris Danford
2005-06-18 15:00:11 +00:00
parent c576001d21
commit a77e0bb273
3 changed files with 38 additions and 3 deletions
+32
View File
@@ -1338,6 +1338,9 @@ void Profile::LoadCourseScoresFromNode( const XNode* pCourseScores )
ASSERT( pCourseScores->m_sName == "CourseScores" );
vector<Course*> vpAllCourses;
SONGMAN->GetAllCourses( vpAllCourses, true );
FOREACH_CONST_Child( pCourseScores, pCourse )
{
if( pCourse->m_sName != "Course" )
@@ -1347,6 +1350,35 @@ void Profile::LoadCourseScoresFromNode( const XNode* pCourseScores )
courseID.LoadFromNode( pCourse );
if( !courseID.IsValid() )
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 )
{