diff --git a/stepmania/src/Profile.cpp b/stepmania/src/Profile.cpp index 9181aa231d..3022d43e84 100644 --- a/stepmania/src/Profile.cpp +++ b/stepmania/src/Profile.cpp @@ -31,7 +31,6 @@ #include "ScoreKeeperMAX2.h" #include "crypto/CryptRand.h" #include "UnlockSystem.h" -#include "CatalogXml.h" #include "XmlFile.h" #include "Foreach.h" @@ -1257,8 +1256,6 @@ void Profile::SaveStatsWebPageToDir( CString sDir ) const PROFILEMAN->GetMachineProfile(), bThisIsMachineProfile ? HTML_TYPE_MACHINE : HTML_TYPE_PLAYER ); - if( bThisIsMachineProfile ) - SaveCatalogXml( sDir ); } void Profile::SaveMachinePublicKeyToDir( CString sDir ) const diff --git a/stepmania/src/ProfileManager.cpp b/stepmania/src/ProfileManager.cpp index ad9ef56188..e5e937ba51 100644 --- a/stepmania/src/ProfileManager.cpp +++ b/stepmania/src/ProfileManager.cpp @@ -42,18 +42,6 @@ ProfileManager* PROFILEMAN = NULL; // global and accessable from anywhere in our ProfileManager::ProfileManager() { - PROFILEMAN = this; - - try - { - FOREACH_PlayerNumber( p ) - m_bWasLoadedFromMemoryCard[p] = false; - - LoadMachineProfile(); - } catch(...) { - PROFILEMAN = NULL; - throw; - } } ProfileManager::~ProfileManager() @@ -61,6 +49,14 @@ ProfileManager::~ProfileManager() SaveMachineProfile(); } +void ProfileManager::Init() +{ + FOREACH_PlayerNumber( p ) + m_bWasLoadedFromMemoryCard[p] = false; + + LoadMachineProfile(); +} + void ProfileManager::GetLocalProfileIDs( vector &asProfileIDsOut ) const { GetDirListing( USER_PROFILES_DIR "*", asProfileIDsOut, true, false ); @@ -76,7 +72,7 @@ void ProfileManager::GetLocalProfileNames( vector &asNamesOut ) const CString sProfileID = vsProfileIDs[i]; CString sProfileDir = USER_PROFILES_DIR + sProfileID + "/"; CString sDisplayName = Profile::GetProfileDisplayNameFromDir( sProfileDir ); - LOG->Trace(" '%s'", sDisplayName.c_str()); + LOG->Trace(" '%s'", sDisplayName.c_str()); asNamesOut.push_back( sDisplayName ); } } diff --git a/stepmania/src/ProfileManager.h b/stepmania/src/ProfileManager.h index f6747a5b22..c09284e7a8 100644 --- a/stepmania/src/ProfileManager.h +++ b/stepmania/src/ProfileManager.h @@ -26,6 +26,8 @@ public: ProfileManager(); ~ProfileManager(); + void Init(); + bool CreateLocalProfile( CString sName ); bool RenameLocalProfile( CString sProfileID, CString sNewName ); bool DeleteLocalProfile( CString sProfileID ); diff --git a/stepmania/src/SongManager.cpp b/stepmania/src/SongManager.cpp index 38414d873d..6d9848104f 100644 --- a/stepmania/src/SongManager.cpp +++ b/stepmania/src/SongManager.cpp @@ -38,11 +38,13 @@ #include "CourseUtil.h" #include "RageFileManager.h" #include "UnlockSystem.h" +#include "CatalogXml.h" SongManager* SONGMAN = NULL; // global and accessable from anywhere in our program #define SONGS_DIR "Songs/" #define COURSES_DIR "Courses/" +#define DATA_DIR "Data/" #define MAX_EDITS_PER_PROFILE 200 @@ -80,24 +82,10 @@ static void UpdateMetrics() EXTRA_COLOR_METER.Refresh(); } -SongManager::SongManager( LoadingWindow *ld ) +SongManager::SongManager() { g_LastMetricUpdate.SetZero(); UpdateMetrics(); - - /* We initialize things that assume they can get at SONGMAN; we only - * init one of these, so hook us up to it immediately. */ - SONGMAN = this; - try - { - InitSongsFromDisk( ld ); - InitCoursesFromDisk( ld ); - InitAutogenCourses(); - - } catch(...) { - SONGMAN = NULL; - throw; - } } SongManager::~SongManager() @@ -106,6 +94,14 @@ SongManager::~SongManager() FreeCourses(); } +void SongManager::InitAll( LoadingWindow *ld ) +{ + InitSongsFromDisk( ld ); + InitCoursesFromDisk( ld ); + InitAutogenCourses(); + SaveCatalogXml( DATA_DIR ); +} + void SongManager::Reload( LoadingWindow *ld ) { FlushDirCache(); @@ -126,9 +122,7 @@ void SongManager::Reload( LoadingWindow *ld ) const bool OldVal = PREFSMAN->m_bFastLoad; PREFSMAN->m_bFastLoad = false; - InitSongsFromDisk( ld ); - InitCoursesFromDisk( ld ); - InitAutogenCourses(); + InitAll( ld ); // reload scores afterward PROFILEMAN->LoadMachineProfile(); diff --git a/stepmania/src/SongManager.h b/stepmania/src/SongManager.h index 3c3e415d6c..f0234c1780 100644 --- a/stepmania/src/SongManager.h +++ b/stepmania/src/SongManager.h @@ -29,7 +29,7 @@ struct PlayerOptions; class SongManager { public: - SongManager( LoadingWindow *ld ); + SongManager(); ~SongManager(); void InitSongsFromDisk( LoadingWindow *ld ); @@ -45,6 +45,7 @@ public: void InitAutogenCourses(); void FreeCourses(); + void InitAll( LoadingWindow *ld ); // songs, courses, groups - everything. void Reload( LoadingWindow *ld=NULL ); // songs, courses, groups - everything. void PreloadSongImages(); diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index 9521174e54..1194864587 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -1052,10 +1052,12 @@ int main(int argc, char* argv[]) BANNERCACHE = new BannerCache; /* depends on SONGINDEX: */ - SONGMAN = new SongManager( loading_window ); // this takes a long time to load + SONGMAN = new SongManager(); + SONGMAN->InitAll( loading_window ); // this takes a long time CRYPTMAN = new CryptManager; // need to do this before ProfileMan MEMCARDMAN = new MemoryCardManager; - PROFILEMAN = new ProfileManager; // must load after SONGMAN + PROFILEMAN = new ProfileManager; + PROFILEMAN->Init(); // must load after SONGMAN UNLOCKMAN = new UnlockSystem; MODELMAN = new ModelManager; delete loading_window; // destroy this before init'ing Display