#include "stdafx.h" /* ----------------------------------------------------------------------------- Class: Course Desc: See header. Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. Chris Danford ----------------------------------------------------------------------------- */ #include "Course.h" #include "ThemeManager.h" #include "Song.h" void Course::LoadFromCRSFile( CString sPath, CArray &apSongs ) { CStdioFile file; if( !file.Open( sPath, CFile::modeRead|CFile::shareDenyNone ) ) throw RageException( "Error opening SM file '%s'.", sPath ); // read the whole file into a sFileText CString sFileText; CString buffer; while( file.ReadString(buffer) ) sFileText += buffer + "\n"; file.Close(); // strip comments out of sFileText while( sFileText.Find("//") != -1 ) { int iIndexCommentStart = sFileText.Find("//"); int iIndexCommentEnd = sFileText.Find("\n", iIndexCommentStart); if( iIndexCommentEnd == -1 ) // comment doesn't have an end? sFileText.Delete( iIndexCommentStart, 2 ); else sFileText.Delete( iIndexCommentStart, iIndexCommentEnd-iIndexCommentStart ); } // split sFileText into strings containing each value expression CStringArray arrayValueStrings; split( sFileText, ";", arrayValueStrings, false ); // for each value expression string, parse it into a value name and data for( int i=0; i < arrayValueStrings.GetSize(); i++ ) { CString sValueString = arrayValueStrings[i]; // split the value string into tokens CStringArray arrayValueTokens; split( sValueString, ":", arrayValueTokens, false ); for( int j=0; jm_sSongDir, sSongDir) ) pSong = apSongs[i]; if( pSong == NULL ) // we didn't find the Song continue; // skip this song Notes* pNotes = NULL; for( int i=0; im_arrayNotes.GetSize(); i++ ) if( 0 == stricmp(pSong->m_arrayNotes[i]->m_sDescription, sNotesDescription) ) pNotes = pSong->m_arrayNotes[i]; if( pNotes == NULL ) // we didn't find the Notes continue; // skip this song AddStage( pSong, pNotes ); } else LOG->WriteLine( "Unexpected value named '%s'", sValueName ); } }