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.

This commit is contained in:
Crash Cringle
2025-04-22 22:26:39 -07:00
committed by teejusb
parent 1a2188e898
commit 5e4f5ae4e5
2 changed files with 16 additions and 16 deletions
+6 -6
View File
@@ -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\"." ); 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. // Check to see if they put a song directly inside the group folder.
std::vector<RString> arrayFiles; std::vector<RString> arrayFiles;
@@ -262,11 +262,12 @@ void SongManager::SanityCheckGroupDir( RString sDir ) const
{ {
if(ext == aud) if(ext == aud)
{ {
RageException::Throw( LOG->Warn(FOLDER_CONTAINS_MUSIC_FILES.GetValue(), sDir.c_str());
FOLDER_CONTAINS_MUSIC_FILES.GetValue(), sDir.c_str()); return false;
} }
} }
} }
return true;
} }
void SongManager::AddGroup( RString sDir, RString sGroupDirName, Group* group ) void SongManager::AddGroup( RString sDir, RString sGroupDirName, Group* group )
@@ -400,9 +401,8 @@ void SongManager::LoadSongDir( RString sDir, LoadingWindow *ld, bool onlyAdditio
ld->SetText(SANITY_CHECKING_GROUPS.GetValue() + ssprintf("\n%s", ld->SetText(SANITY_CHECKING_GROUPS.GetValue() + ssprintf("\n%s",
Basename(sGroupDirName).c_str())); Basename(sGroupDirName).c_str()));
} }
// TODO: If this check fails, log a warning instead of crashing.
SanityCheckGroupDir(sDir+sGroupDirName);
if (SanityCheckGroupDir(sDir+sGroupDirName)) {
// Find all Song folders in this group directory // Find all Song folders in this group directory
std::vector<RString> arraySongDirs; std::vector<RString> arraySongDirs;
GetDirListing( sDir+sGroupDirName + "/*", arraySongDirs, true, true ); GetDirListing( sDir+sGroupDirName + "/*", arraySongDirs, true, true );
@@ -412,7 +412,7 @@ void SongManager::LoadSongDir( RString sDir, LoadingWindow *ld, bool onlyAdditio
arrayGroupSongDirs.push_back(arraySongDirs); arrayGroupSongDirs.push_back(arraySongDirs);
songCount += arraySongDirs.size(); songCount += arraySongDirs.size();
}
} }
if( songCount==0 ) return; if( songCount==0 ) return;
+1 -1
View File
@@ -216,7 +216,7 @@ protected:
*/ */
void LoadSongDir( RString sDir, LoadingWindow *ld, bool onlyAdditions ); void LoadSongDir( RString sDir, LoadingWindow *ld, bool onlyAdditions );
bool GetExtraStageInfoFromCourse( bool bExtra2, RString sPreferredGroup, Song*& pSongOut, Steps*& pStepsOut, StepsType stype ); 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 ); void AddGroup( RString sDir, RString sGroupDirName, Group* group );
int GetNumEditsLoadedFromProfile( ProfileSlot slot ) const; int GetNumEditsLoadedFromProfile( ProfileSlot slot ) const;