From 5093809e31d80e206a1c6c02b5e8849e6e470f3f Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 24 Apr 2005 23:23:32 +0000 Subject: [PATCH] fallback load for Editable.ini when loaded by the memory card thread --- stepmania/src/ProfileManager.cpp | 26 ++++++++++++++++++++------ stepmania/src/ProfileManager.h | 2 +- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/stepmania/src/ProfileManager.cpp b/stepmania/src/ProfileManager.cpp index 707696675f..046ba3ba57 100644 --- a/stepmania/src/ProfileManager.cpp +++ b/stepmania/src/ProfileManager.cpp @@ -130,7 +130,7 @@ bool ProfileManager::LoadLocalProfileFromMachine( PlayerNumber pn ) return LoadProfile( pn, sDir, false ) == Profile::success; } -void ProfileManager::GetMemoryCardProfileDirectoriesToTry( vector &asDirsToTry ) +void ProfileManager::GetMemoryCardProfileDirectoriesToTry( vector &asDirsToTry ) const { /* Try to load the preferred profile. */ asDirsToTry.push_back( PREFSMAN->m_sMemoryCardProfileSubdir ); @@ -199,12 +199,26 @@ bool ProfileManager::LoadFirstAvailableProfile( PlayerNumber pn ) bool ProfileManager::FastLoadProfileNameFromMemoryCard( CString sRootDir, CString &sName ) const { - CString sProfileDir = sRootDir + PREFSMAN->m_sMemoryCardProfileSubdir + '/'; + vector asDirsToTry; + GetMemoryCardProfileDirectoriesToTry( asDirsToTry ); - Profile profile; - profile.LoadEditableDataFromDir( sProfileDir ); - sName = profile.GetDisplayName(); - return true; + for( unsigned i = 0; i < asDirsToTry.size(); ++i ) + { + const CString &sSubdir = asDirsToTry[i]; + CString sDir = sRootDir + sSubdir + "/"; + + Profile profile; + Profile::LoadResult res = profile.LoadEditableDataFromDir( sDir ); + if( res == Profile::success ) + { + sName = profile.GetDisplayName(); + return true; + } + else if( res != Profile::failed_no_profile ) + break; + } + + return false; } void ProfileManager::SaveAllProfiles() const diff --git a/stepmania/src/ProfileManager.h b/stepmania/src/ProfileManager.h index b6f12f3a69..c646a46571 100644 --- a/stepmania/src/ProfileManager.h +++ b/stepmania/src/ProfileManager.h @@ -33,7 +33,6 @@ public: void SaveAllProfiles() const; bool SaveProfile( PlayerNumber pn ) const; void UnloadProfile( PlayerNumber pn ); - void GetMemoryCardProfileDirectoriesToTry( vector &asDirsToTry ); // // General data @@ -92,6 +91,7 @@ public: private: Profile::LoadResult LoadProfile( PlayerNumber pn, CString sProfileDir, bool bIsMemCard ); + void GetMemoryCardProfileDirectoriesToTry( vector &asDirsToTry ) const; // Directory that contains the profile. Either on local machine or // on a memory card.