From 257697d0a9a28e2f42be8f4a0390ca9f71ddaa83 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Tue, 10 Sep 2002 08:39:58 +0000 Subject: [PATCH] Fixup DWI-tree song paths. Don't prepend paths to those variables when they include a backslash, not when they begin with a period. --- stepmania/src/Song.cpp | 37 ++++++++++++++++++++++++++++++++++++- stepmania/src/song.h | 10 +++++----- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/stepmania/src/Song.cpp b/stepmania/src/Song.cpp index c419ef2928..9663ff455d 100644 --- a/stepmania/src/Song.cpp +++ b/stepmania/src/Song.cpp @@ -346,6 +346,13 @@ bool Song::LoadWithoutCache( CString sDir ) return false; } + /* If this song directory is within the DWI path, prepend the DWI path + * to m_sMusicFile and m_sCDTitleFile. */ + if(sDir.Left(PREFSMAN->m_DWIPath.GetLength()) == PREFSMAN->m_DWIPath) { + m_sMusicFile = PREFSMAN->m_DWIPath+"\\"+m_sMusicFile; + m_sCDTitleFile = PREFSMAN->m_DWIPath+"\\"+m_sCDTitleFile; + } + AddAutoGenNotes(); TidyUpData(); @@ -384,7 +391,7 @@ bool Song::LoadFromSongDir( CString sDir ) } else { - if(!LoadWithoutCache(sDir)) + if(!LoadWithoutCache(m_sSongDir)) return false; } @@ -975,3 +982,31 @@ int Song::GetNumTimesPlayed() const } return iTotalNumTimesPlayed; } + +/* The only files we load that have paths inside these variables + * are DWIs loaded from a DWI tree. This used to look for a leading + * ".", but we're prepending the DWI path explicitely now (so they + * can be loaded from an actual installation), so look for any + * backslashes instead. */ +CString Song::GetMusicPath() const +{ + return m_sMusicFile.Find('\\')!=-1 ? m_sMusicFile : m_sSongDir+m_sMusicFile; +} + +CString Song::GetBannerPath() const +{ + return m_sSongDir+m_sBannerFile; +} + +CString Song::GetBackgroundPath() const +{ + return m_sSongDir+m_sBackgroundFile; +} +CString Song::GetCDTitlePath() const +{ + return m_sCDTitleFile.Find('\\')!=-1 ? m_sCDTitleFile : m_sSongDir+m_sCDTitleFile; +} +CString Song::GetMovieBackgroundPath() const +{ + return m_sSongDir+m_sMovieBackgroundFile; +} diff --git a/stepmania/src/song.h b/stepmania/src/song.h index 2ba33cd38c..96a7b24cfd 100644 --- a/stepmania/src/song.h +++ b/stepmania/src/song.h @@ -110,11 +110,11 @@ public: CString m_sCDTitleFile; CString m_sMovieBackgroundFile; - CString GetMusicPath() const {return m_sMusicFile.Find('.')==0 ? m_sMusicFile : m_sSongDir+m_sMusicFile; }; - CString GetBannerPath() const {return m_sSongDir+m_sBannerFile; }; - CString GetBackgroundPath() const {return m_sSongDir+m_sBackgroundFile; }; - CString GetCDTitlePath() const {return m_sCDTitleFile.Find('.')==0 ? m_sCDTitleFile : m_sSongDir+m_sCDTitleFile; }; - CString GetMovieBackgroundPath() const {return m_sSongDir+m_sMovieBackgroundFile; }; + CString GetMusicPath() const; + CString GetBannerPath() const; + CString GetBackgroundPath() const; + CString GetCDTitlePath() const; + CString GetMovieBackgroundPath() const; bool HasMusic() const;