From 91818ab8298f4f29a1db164ee369e7a66cff3715 Mon Sep 17 00:00:00 2001 From: Kevin Slaughter Date: Fri, 5 Sep 2003 09:14:11 +0000 Subject: [PATCH] Basic support for symbolic song linking. Currently it duplicatly loads a song into the specified dir. The SONGNAME.include should be in whatever mix folder the link should appear in, and only have the tag of #LINK:Songs/mixfolder/songname; -- Unfortunatly since it is double-loading this song, this causes 2 scores to be saved, etc. Added m_bIsSymLink into the Song class so we can ID it as such, to exclude it from score writing/song enumeration and such. I kinda need some help makgin sure scores and all writable data are mapped back to the real song. --- stepmania/src/Song.cpp | 1 + stepmania/src/SongManager.cpp | 33 ++++++++++++++++++++++++++++++++- stepmania/src/SongManager.h | 1 + stepmania/src/song.h | 1 + 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/stepmania/src/Song.cpp b/stepmania/src/Song.cpp index ed83e302bd..73b5472c77 100644 --- a/stepmania/src/Song.cpp +++ b/stepmania/src/Song.cpp @@ -101,6 +101,7 @@ Song::Song() m_DisplayBPMType = DISPLAY_ACTUAL; m_fSpecifiedBPMMin = 0; m_fSpecifiedBPMMax = 0; + m_bIsSymLink = false; } Song::~Song() diff --git a/stepmania/src/SongManager.cpp b/stepmania/src/SongManager.cpp index 917f39d658..9dc4917178 100644 --- a/stepmania/src/SongManager.cpp +++ b/stepmania/src/SongManager.cpp @@ -13,6 +13,7 @@ #include "SongManager.h" #include "IniFile.h" #include "RageLog.h" +#include "MsdFile.h" #include "NotesLoaderDWI.h" #include "BannerCache.h" #include "arch/arch.h" @@ -204,7 +205,7 @@ void SongManager::LoadStepManiaSongDir( CString sDir, LoadingWindow *ld ) CStringArray arrayGroupDirs; GetDirListing( sDir+"*", arrayGroupDirs, true ); SortCStringArray( arrayGroupDirs ); - + for( unsigned i=0; i< arrayGroupDirs.size(); i++ ) // for each dir in /Songs/ { CString sGroupDirName = arrayGroupDirs[i]; @@ -255,6 +256,36 @@ void SongManager::LoadStepManiaSongDir( CString sDir, LoadingWindow *ld ) /* Cache and load the group banner. */ BANNERCACHE->CacheBanner( GetGroupBannerPath(sGroupDirName) ); + + /* Load the group sym links (if any)*/ + LoadGroupSymLinks(sDir, sGroupDirName); + } +} + +void SongManager::LoadGroupSymLinks(CString sDir, CString sGroupFolder) +{ + // Find all symlink files in this folder + CStringArray arraySymLinks; + GetDirListing( sDir+sGroupFolder+SLASH+"*.include", arraySymLinks, false ); + SortCStringArray( arraySymLinks ); + for( unsigned s=0; s< arraySymLinks.size(); s++ ) // for each symlink in this dir, add it in as a song. + { + MsdFile msdF; + msdF.ReadFile( sDir+sGroupFolder+SLASH+arraySymLinks[s].c_str() ); + CString sSymDestination = msdF.GetParam(0,1); // Should only be 1 vale¶m...period. + + Song* pNewSong = new Song; + if( !pNewSong->LoadFromSongDir( sSymDestination ) ) + delete pNewSong; // The song failed to load. + else + { + pNewSong->m_apNotes.clear(); // No memory hogs.. + pNewSong->m_BackgroundChanges.clear(); + + pNewSong->m_bIsSymLink = true; // Very important so we don't double-parse later + pNewSong->m_sGroupName = sGroupFolder; + m_pSongs.push_back( pNewSong ); + } } } diff --git a/stepmania/src/SongManager.h b/stepmania/src/SongManager.h index 57fa436857..f400d0cce7 100644 --- a/stepmania/src/SongManager.h +++ b/stepmania/src/SongManager.h @@ -35,6 +35,7 @@ public: void InitSongsFromDisk( LoadingWindow *ld ); void FreeSongs(); void CompressSongs(); + void LoadGroupSymLinks( CString sDir, CString sGroupFolder ); void InitCoursesFromDisk( LoadingWindow *ld ); void InitAutogenCourses(); diff --git a/stepmania/src/song.h b/stepmania/src/song.h index e8461a907d..2f305d894a 100644 --- a/stepmania/src/song.h +++ b/stepmania/src/song.h @@ -111,6 +111,7 @@ public: bool m_bChangedSinceSave; + bool m_bIsSymLink; CString m_sMainTitle, m_sSubTitle, m_sArtist; CString m_sMainTitleTranslit, m_sSubTitleTranslit, m_sArtistTranslit;