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
+1
View File
@@ -26,6 +26,7 @@ namespace CourseUtil
class CourseID
{
public:
CString sPath;
CString sFullTitle;
+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" )
@@ -1348,6 +1351,35 @@ void Profile::LoadCourseScoresFromNode( const XNode* pCourseScores )
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 )
{
if( pTrail->m_sName != "Trail" )
+5 -3
View File
@@ -1065,9 +1065,11 @@ Course* SongManager::GetCourseFromPath( CString sPath )
if( sPath == "" )
return NULL;
for( unsigned int i=0; i<m_pCourses.size(); i++ )
if( sPath.CompareNoCase(m_pCourses[i]->m_sPath) == 0 )
return m_pCourses[i];
FOREACH_CONST( Course*, m_pCourses, c )
{
if( sPath.CompareNoCase((*c)->m_sPath) == 0 )
return *c;
}
return NULL;
}