create new profiles without reloading all old ones
This commit is contained in:
@@ -1889,15 +1889,20 @@ void Profile::BackupToDir( CString sFromDir, CString sToDir )
|
|||||||
FileCopy( sFromDir+DONT_SHARE_SIG, sToDir+DONT_SHARE_SIG );
|
FileCopy( sFromDir+DONT_SHARE_SIG, sToDir+DONT_SHARE_SIG );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Profile::CreateNewProfile( CString sProfileDir, CString sName, bool bFillWithRandomCharacter )
|
Profile *Profile::CreateNewProfile( CString sProfileDir, CString sName, bool bFillWithRandomCharacter )
|
||||||
{
|
{
|
||||||
Profile pro;
|
Profile *pProfile = new Profile;
|
||||||
pro.m_sDisplayName = sName;
|
pProfile->m_sDisplayName = sName;
|
||||||
if( bFillWithRandomCharacter )
|
if( bFillWithRandomCharacter )
|
||||||
pro.m_sCharacter = GAMESTATE->GetRandomCharacter()->m_sName;
|
pProfile->m_sCharacter = GAMESTATE->GetRandomCharacter()->m_sName;
|
||||||
bool bResult = pro.SaveAllToDir( sProfileDir, PREFSMAN->m_bSignProfileData );
|
if( !pProfile->SaveAllToDir(sProfileDir, PREFSMAN->m_bSignProfileData) )
|
||||||
|
{
|
||||||
|
delete pProfile;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
FlushDirCache();
|
FlushDirCache();
|
||||||
return bResult;
|
return pProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -332,7 +332,7 @@ public:
|
|||||||
void SaveStatsWebPageToDir( CString sDir ) const;
|
void SaveStatsWebPageToDir( CString sDir ) const;
|
||||||
void SaveMachinePublicKeyToDir( CString sDir ) const;
|
void SaveMachinePublicKeyToDir( CString sDir ) const;
|
||||||
|
|
||||||
static bool CreateNewProfile( CString sProfileDir, CString sName, bool bFillWithRandomCharacter );
|
static Profile *CreateNewProfile( CString sProfileDir, CString sName, bool bFillWithRandomCharacter );
|
||||||
static void BackupToDir( CString sFromDir, CString sToDir );
|
static void BackupToDir( CString sFromDir, CString sToDir );
|
||||||
|
|
||||||
// Lua
|
// Lua
|
||||||
|
|||||||
@@ -378,10 +378,11 @@ bool ProfileManager::CreateLocalProfile( CString sName, CString &sProfileIDOut )
|
|||||||
bool ProfileManager::CreateLocalProfileByID( CString sName, CString sProfileID )
|
bool ProfileManager::CreateLocalProfileByID( CString sName, CString sProfileID )
|
||||||
{
|
{
|
||||||
CString sProfileDir = LocalProfileIdToDir( sProfileID );
|
CString sProfileDir = LocalProfileIdToDir( sProfileID );
|
||||||
if( !Profile::CreateNewProfile(sProfileDir, sName, true) )
|
Profile *pProfile = Profile::CreateNewProfile( sProfileDir, sName, true );
|
||||||
|
if( pProfile == NULL )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
RefreshLocalProfilesFromDisk();
|
g_mapLocalProfileIdToProfile[sProfileID] = pProfile;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -434,8 +435,9 @@ void ProfileManager::LoadMachineProfile()
|
|||||||
Profile::LoadResult lr = m_pMachineProfile->LoadAllFromDir(MACHINE_PROFILE_DIR, false);
|
Profile::LoadResult lr = m_pMachineProfile->LoadAllFromDir(MACHINE_PROFILE_DIR, false);
|
||||||
if( lr == Profile::failed_no_profile )
|
if( lr == Profile::failed_no_profile )
|
||||||
{
|
{
|
||||||
Profile::CreateNewProfile( MACHINE_PROFILE_DIR, "Machine", false );
|
Profile *pProfile = Profile::CreateNewProfile( MACHINE_PROFILE_DIR, "Machine", false );
|
||||||
m_pMachineProfile->LoadAllFromDir( MACHINE_PROFILE_DIR, false );
|
delete m_pMachineProfile;
|
||||||
|
m_pMachineProfile = pProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the machine name has changed, make sure we use the new name
|
// If the machine name has changed, make sure we use the new name
|
||||||
|
|||||||
Reference in New Issue
Block a user