From c868d447bfdaef3366785c4a1d3c49a2bcfe439b Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 12 Oct 2002 19:30:15 +0000 Subject: [PATCH] fix courses with songs not in Songs\ --- stepmania/src/Course.cpp | 56 +++++++++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 6 deletions(-) diff --git a/stepmania/src/Course.cpp b/stepmania/src/Course.cpp index 5fea8f98e5..cf33427382 100644 --- a/stepmania/src/Course.cpp +++ b/stepmania/src/Course.cpp @@ -68,17 +68,61 @@ void Course::LoadFromCRSFile( CString sPath, CArray &apSongs ) else if( 0 == stricmp(sValueName, "SONG") ) { - CString sSongDir = "Songs\\" + sParams[1] + "\\"; + CString sSongDir = sParams[1]; CString sNotesDescription = sParams[2]; CString sModifiers = sParams[3]; - int i; + if(!sSongDir.GetLength()) { + /* Err. */ + LOG->Trace( "Course file \"%s\" has an empty #SONG. Ignored.", + sPath.GetString(), sSongDir.GetString()); + continue; + } - Song* pSong = NULL; - for( i=0; i 2 ) { - CString sThisSongDir = apSongs[i]->m_sSongDir; - if( 0 == stricmp(sThisSongDir, sSongDir) ) + LOG->Warn( "Course file \"%s\" path \"%s\" should contain " + "at most one backslash; ignored.", + sPath.GetString(), sSongDir.GetString()); + continue; + } + + Song *pSong = NULL; + // foreach song + for( int i = 0; pSong == NULL && i < apSongs.GetSize(); i++ ) + { + CStringArray splitted; + split( apSongs[i]->m_sSongDir, "\\", splitted, true ); + bool matches = true; + + int split_no = splitted.GetSize()-1; + int SongDir_no = split_SongDir.GetSize()-1; + + while( split_no >= 0 && SongDir_no >= 0 ) { + if( stricmp(splitted[split_no--].GetString(), split_SongDir[SongDir_no--].GetString() ) ) + matches=false; + } + + if(matches) pSong = apSongs[i]; } if( pSong == NULL ) // we didn't find the Song