From 70958ad3cba22b309ffd2f76aef945ba1283691e Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Tue, 20 Apr 2004 00:07:17 +0000 Subject: [PATCH] never sign machine profiles --- stepmania/src/Profile.cpp | 8 ++++---- stepmania/src/Profile.h | 4 ++-- stepmania/src/ProfileManager.cpp | 16 ++++++++-------- stepmania/src/ScreenDownloadMachineStats.cpp | 3 ++- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/stepmania/src/Profile.cpp b/stepmania/src/Profile.cpp index 6d704d6372..6d65925ccc 100644 --- a/stepmania/src/Profile.cpp +++ b/stepmania/src/Profile.cpp @@ -446,7 +446,7 @@ int g_iOnceCtr; #define FOR_ONCE for(g_iOnceCtr=0;g_iOnceCtr<1;g_iOnceCtr++) -bool Profile::LoadAllFromDir( CString sDir ) +bool Profile::LoadAllFromDir( CString sDir, bool bRequireSignature ) { CHECKPOINT; @@ -483,7 +483,7 @@ bool Profile::LoadAllFromDir( CString sDir ) break; } - if( PREFSMAN->m_bSignProfileData ) + if( bRequireSignature ) { CString sStatsXmlSigFile = fn+SIGNATURE_APPEND; CString sDontShareFile = sDir + DONT_SHARE_SIG; @@ -526,7 +526,7 @@ bool Profile::LoadAllFromDir( CString sDir ) return true; // FIXME? Investigate what happens if we always return true. } -bool Profile::SaveAllToDir( CString sDir ) const +bool Profile::SaveAllToDir( CString sDir, bool bSignData ) const { m_sLastPlayedMachineGuid = PROFILEMAN->GetMachineProfile()->m_sGuid; @@ -547,7 +547,7 @@ bool Profile::SaveAllToDir( CString sDir ) const xml.AppendChild( SaveCalorieDataCreateNode() ); xml.AppendChild( SaveAwardsCreateNode() ); bool bSaved = xml.SaveToFile(fn); - if( bSaved && PREFSMAN->m_bSignProfileData ) + if( bSaved && bSignData ) { CString sStatsXmlSigFile = fn+SIGNATURE_APPEND; CryptManager::SignFileToFile(fn, sStatsXmlSigFile); diff --git a/stepmania/src/Profile.h b/stepmania/src/Profile.h index bbce50840d..0c55d7a221 100644 --- a/stepmania/src/Profile.h +++ b/stepmania/src/Profile.h @@ -263,8 +263,8 @@ public: // // Loading and saving // - bool LoadAllFromDir( CString sDir ); // return false on - bool SaveAllToDir( CString sDir ) const; + bool LoadAllFromDir( CString sDir, bool bRequireSignature ); // return false on error + bool SaveAllToDir( CString sDir, bool bSignData ) const; void LoadProfileDataFromDirSM390a12( CString sDir ); void LoadSongScoresFromDirSM390a12( CString sDir ); diff --git a/stepmania/src/ProfileManager.cpp b/stepmania/src/ProfileManager.cpp index 895690f789..96848bff5d 100644 --- a/stepmania/src/ProfileManager.cpp +++ b/stepmania/src/ProfileManager.cpp @@ -93,7 +93,7 @@ bool ProfileManager::LoadProfile( PlayerNumber pn, CString sProfileDir, bool bIs if( bLoadNamesOnly ) m_Profile[pn].LoadEditableDataFromDir( m_sProfileDir[pn] ); else - m_Profile[pn].LoadAllFromDir( m_sProfileDir[pn] ); + m_Profile[pn].LoadAllFromDir( m_sProfileDir[pn], PREFSMAN->m_bSignProfileData ); return true; } @@ -104,7 +104,7 @@ bool ProfileManager::CreateProfile( CString sProfileDir, CString sName ) Profile pro; pro.m_sDisplayName = sName; - bResult = pro.SaveAllToDir( sProfileDir ); + bResult = pro.SaveAllToDir( sProfileDir, PREFSMAN->m_bSignProfileData ); if( !bResult ) return false; @@ -186,7 +186,7 @@ bool ProfileManager::SaveProfile( PlayerNumber pn ) const if( m_sProfileDir[pn].empty() ) return false; - return m_Profile[pn].SaveAllToDir( m_sProfileDir[pn] ); + return m_Profile[pn].SaveAllToDir( m_sProfileDir[pn], PREFSMAN->m_bSignProfileData ); } void ProfileManager::UnloadProfile( PlayerNumber pn ) @@ -249,11 +249,11 @@ bool ProfileManager::RenameLocalProfile( CString sProfileID, CString sNewName ) Profile pro; bool bResult; - bResult = pro.LoadAllFromDir( sProfileDir ); + bResult = pro.LoadAllFromDir( sProfileDir, PREFSMAN->m_bSignProfileData ); if( !bResult ) return false; pro.m_sDisplayName = sNewName; - bResult = pro.SaveAllToDir( sProfileDir ); + bResult = pro.SaveAllToDir( sProfileDir, PREFSMAN->m_bSignProfileData ); if( !bResult ) return false; @@ -280,7 +280,7 @@ void ProfileManager::SaveMachineProfile() // are saved, so that the Player's profiles show the right machine name. m_MachineProfile.m_sDisplayName = PREFSMAN->m_sMachineName; - m_MachineProfile.SaveAllToDir( MACHINE_PROFILE_DIR ); + m_MachineProfile.SaveAllToDir( MACHINE_PROFILE_DIR, false ); /* don't sign machine profiles */ } @@ -291,10 +291,10 @@ void ProfileManager::LoadMachineProfile() // read old style notes scores // ReadSM300NoteScores(); - if( !m_MachineProfile.LoadAllFromDir(MACHINE_PROFILE_DIR ) ) + if( !m_MachineProfile.LoadAllFromDir(MACHINE_PROFILE_DIR, false) ) { CreateProfile(MACHINE_PROFILE_DIR, "Machine"); - m_MachineProfile.LoadAllFromDir( MACHINE_PROFILE_DIR ); + m_MachineProfile.LoadAllFromDir( MACHINE_PROFILE_DIR, false ); } // If the machine name has changed, make sure we use the new name diff --git a/stepmania/src/ScreenDownloadMachineStats.cpp b/stepmania/src/ScreenDownloadMachineStats.cpp index 436cf6af16..3c24c5033c 100644 --- a/stepmania/src/ScreenDownloadMachineStats.cpp +++ b/stepmania/src/ScreenDownloadMachineStats.cpp @@ -5,6 +5,7 @@ #include "ScreenManager.h" #include "MemoryCardManager.h" #include "ThemeManager.h" +#include "PrefsManager.h" #define NEXT_SCREEN THEME->GetMetric(m_sName,"NextScreen") @@ -17,7 +18,7 @@ static void SaveMachineStatsToFirstMemCard() CString sDir = MEM_CARD_MOUNT_POINT[pn]; sDir += "MachineProfile/"; - PROFILEMAN->GetMachineProfile()->SaveAllToDir( sDir ); + PROFILEMAN->GetMachineProfile()->SaveAllToDir( sDir, PREFSMAN->m_bSignProfileData ); SCREENMAN->SystemMessage( ssprintf("Machine stats saved to P%d card.",pn+1) ); return; }