From 5e4f5ae4e5d453cc6724fd558c99fd74a7100687 Mon Sep 17 00:00:00 2001 From: Crash Cringle <30600688+CrashCringle12@users.noreply.github.com> Date: Tue, 1 Apr 2025 08:38:54 -0400 Subject: [PATCH] Update SanityCheckGroup to return whether the group has passed the check or not rather and log a warning if failed rather than exit the game. --- src/SongManager.cpp | 30 +++++++++++++++--------------- src/SongManager.h | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/SongManager.cpp b/src/SongManager.cpp index 2b39e785eb..4defcb58c2 100644 --- a/src/SongManager.cpp +++ b/src/SongManager.cpp @@ -249,7 +249,7 @@ void SongManager::InitSongsFromDisk( LoadingWindow *ld, bool onlyAdditions ) } static LocalizedString FOLDER_CONTAINS_MUSIC_FILES( "SongManager", "The folder \"%s\" appears to be a song folder. All song folders must reside in a group folder. For example, \"Songs/Originals/My Song\"." ); -void SongManager::SanityCheckGroupDir( RString sDir ) const +bool SongManager::SanityCheckGroupDir( RString sDir ) const { // Check to see if they put a song directly inside the group folder. std::vector arrayFiles; @@ -262,11 +262,12 @@ void SongManager::SanityCheckGroupDir( RString sDir ) const { if(ext == aud) { - RageException::Throw( - FOLDER_CONTAINS_MUSIC_FILES.GetValue(), sDir.c_str()); + LOG->Warn(FOLDER_CONTAINS_MUSIC_FILES.GetValue(), sDir.c_str()); + return false; } } } + return true; } void SongManager::AddGroup( RString sDir, RString sGroupDirName, Group* group ) @@ -400,19 +401,18 @@ void SongManager::LoadSongDir( RString sDir, LoadingWindow *ld, bool onlyAdditio ld->SetText(SANITY_CHECKING_GROUPS.GetValue() + ssprintf("\n%s", Basename(sGroupDirName).c_str())); } - // TODO: If this check fails, log a warning instead of crashing. - SanityCheckGroupDir(sDir+sGroupDirName); - - // Find all Song folders in this group directory - std::vector arraySongDirs; - GetDirListing( sDir+sGroupDirName + "/*", arraySongDirs, true, true ); - StripCvsAndSvn( arraySongDirs ); - StripMacResourceForks( arraySongDirs ); - SortRStringArray( arraySongDirs ); - - arrayGroupSongDirs.push_back(arraySongDirs); - songCount += arraySongDirs.size(); + + if (SanityCheckGroupDir(sDir+sGroupDirName)) { + // Find all Song folders in this group directory + std::vector arraySongDirs; + GetDirListing( sDir+sGroupDirName + "/*", arraySongDirs, true, true ); + StripCvsAndSvn( arraySongDirs ); + StripMacResourceForks( arraySongDirs ); + SortRStringArray( arraySongDirs ); + arrayGroupSongDirs.push_back(arraySongDirs); + songCount += arraySongDirs.size(); + } } if( songCount==0 ) return; diff --git a/src/SongManager.h b/src/SongManager.h index d88bbc6590..462165e8d1 100644 --- a/src/SongManager.h +++ b/src/SongManager.h @@ -216,7 +216,7 @@ protected: */ void LoadSongDir( RString sDir, LoadingWindow *ld, bool onlyAdditions ); bool GetExtraStageInfoFromCourse( bool bExtra2, RString sPreferredGroup, Song*& pSongOut, Steps*& pStepsOut, StepsType stype ); - void SanityCheckGroupDir( RString sDir ) const; + bool SanityCheckGroupDir( RString sDir ) const; void AddGroup( RString sDir, RString sGroupDirName, Group* group ); int GetNumEditsLoadedFromProfile( ProfileSlot slot ) const;