From 063c2cf3a4f9eb616eb8f2519aa572828bd3df29 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sun, 14 Mar 2004 17:49:38 +0000 Subject: [PATCH] keep a Guid in Profile --- stepmania/src/CryptManager.cpp | 1 + stepmania/src/Profile.cpp | 39 ++++++++++++++++++++++++------ stepmania/src/Profile.h | 13 ++++++---- stepmania/src/ProfileHtml.cpp | 7 +++--- stepmania/src/ScreenEvaluation.cpp | 2 +- 5 files changed, 45 insertions(+), 17 deletions(-) diff --git a/stepmania/src/CryptManager.cpp b/stepmania/src/CryptManager.cpp index 96cd3c9e2a..5add631a6e 100644 --- a/stepmania/src/CryptManager.cpp +++ b/stepmania/src/CryptManager.cpp @@ -40,6 +40,7 @@ void CryptManager::GenerateRSAKey( unsigned int keyLength, CString privFilename, { ASSERT( PREFSMAN->m_bSignProfileData ); + // Does the RNG need to be inited and seeded every time? random_init(); random_add_noise( seed ); diff --git a/stepmania/src/Profile.cpp b/stepmania/src/Profile.cpp index 74fccd2dcd..2a04dc84d3 100644 --- a/stepmania/src/Profile.cpp +++ b/stepmania/src/Profile.cpp @@ -25,11 +25,11 @@ #include #include "ThemeManager.h" #include "CryptManager.h" -#include "PrefsManager.h" #include "ProfileHtml.h" #include "ProfileManager.h" #include "RageFileManager.h" #include "ScoreKeeperMAX2.h" +#include "crypto/CryptRand.h" // // Old file versions for backward compatibility @@ -66,6 +66,17 @@ void Profile::InitEditableData() void Profile::InitGeneralData() { + // Init m_iGuid. + // Does the RNG need to be inited and seeded every time? + random_init(); + random_add_noise( "ai8049ujr3odusj" ); + + { + for( int i=0; im_sMachineName; + m_iLastPlayedMachineGuid = PROFILEMAN->GetMachineProfile()->m_iGuid; // Save editable.xml SaveEditableDataToDir( sDir ); @@ -536,7 +557,7 @@ void Profile::LoadProfileDataFromDirSM390a12( CString sDir ) ini.GetValue( "Profile", "CurrentCombo", m_iCurrentCombo ); ini.GetValue( "Profile", "WeightPounds", m_iWeightPounds ); ini.GetValue( "Profile", "CaloriesBurned", m_fTotalCaloriesBurned ); - ini.GetValue( "Profile", "LastPlayedMachineName", m_sLastPlayedMachineName ); + ini.GetValue( "Profile", "LastPlayedMachineGuid", m_iLastPlayedMachineGuid ); unsigned i; for( i=0; iname = "GeneralData"; + pGeneralDataNode->AppendChild( "Guid", m_iGuid ); pGeneralDataNode->AppendChild( "UsingProfileDefaultModifiers", m_bUsingProfileDefaultModifiers ); pGeneralDataNode->AppendChild( "DefaultModifiers", m_sDefaultModifiers ); pGeneralDataNode->AppendChild( "SortOrder", SortOrderToString(m_SortOrder) ); @@ -577,7 +599,7 @@ XNode* Profile::SaveGeneralDataCreateNode() const pGeneralDataNode->AppendChild( "TotalGameplaySeconds", m_iTotalGameplaySeconds ); pGeneralDataNode->AppendChild( "CurrentCombo", m_iCurrentCombo ); pGeneralDataNode->AppendChild( "TotalCaloriesBurned", m_fTotalCaloriesBurned ); - pGeneralDataNode->AppendChild( "LastPlayedMachineName", m_sLastPlayedMachineName ); + pGeneralDataNode->AppendChild( "LastPlayedMachineGuid", m_iLastPlayedMachineGuid ); pGeneralDataNode->AppendChild( "TotalDancePoints", m_iTotalDancePoints ); pGeneralDataNode->AppendChild( "NumExtraStagesPassed", m_iNumExtraStagesPassed ); pGeneralDataNode->AppendChild( "NumExtraStagesFailed", m_iNumExtraStagesFailed ); @@ -706,6 +728,7 @@ void Profile::LoadGeneralDataFromNode( const XNode* pNode ) CString s; + pNode->GetChildValue( "Guid", m_iGuid ); pNode->GetChildValue( "UsingProfileDefaultModifiers", m_bUsingProfileDefaultModifiers ); pNode->GetChildValue( "DefaultModifiers", m_sDefaultModifiers ); pNode->GetChildValue( "SortOrder", s ); m_SortOrder = StringToSortOrder( s ); @@ -716,7 +739,7 @@ void Profile::LoadGeneralDataFromNode( const XNode* pNode ) pNode->GetChildValue( "TotalGameplaySeconds", m_iTotalGameplaySeconds ); pNode->GetChildValue( "CurrentCombo", m_iCurrentCombo ); pNode->GetChildValue( "TotalCaloriesBurned", m_fTotalCaloriesBurned ); - pNode->GetChildValue( "LastPlayedMachineName", m_sLastPlayedMachineName ); + pNode->GetChildValue( "LastPlayedMachineGuid", m_iLastPlayedMachineGuid ); pNode->GetChildValue( "TotalDancePoints", m_iTotalDancePoints ); pNode->GetChildValue( "NumExtraStagesPassed", m_iNumExtraStagesPassed ); pNode->GetChildValue( "NumExtraStagesFailed", m_iNumExtraStagesFailed ); @@ -1529,7 +1552,7 @@ void Profile::LoadScreenshotDataFromNode( const XNode* pNode ) if( !(*screenshot)->GetChildValue("Time",(int&)ss.time) ) // time_t is a signed long on Win32. Is this ok on other platforms? WARN; - if( !(*screenshot)->GetChildValue("MachineName",ss.sMachineName) ) + if( !(*screenshot)->GetChildValue("MachineGuid",ss.iMachineGuid) ) WARN; m_vScreenshots.push_back( ss ); @@ -1555,7 +1578,7 @@ XNode* Profile::SaveScreenshotDataCreateNode() const pScreenshotNode->AppendChild( "FileName", ss.sFileName ); pScreenshotNode->AppendChild( "MD5", ss.sMD5 ); pScreenshotNode->AppendChild( "Time", (int) ss.time ); - pScreenshotNode->AppendChild( "MachineName", ss.sMachineName ); + pScreenshotNode->AppendChild( "MachineGuid", ss.iMachineGuid ); } return pNode; diff --git a/stepmania/src/Profile.h b/stepmania/src/Profile.h index 56995b0c6b..f38f309d60 100644 --- a/stepmania/src/Profile.h +++ b/stepmania/src/Profile.h @@ -67,6 +67,8 @@ public: // smart accessors // CString GetDisplayName() const; + CString GetDisplayGuid() const; + CString GetDisplayLastPlayedMachineGuid() const; CString GetDisplayTotalCaloriesBurned() const; int GetTotalNumSongsPlayed() const; int GetTotalNumSongsPassed() const; @@ -86,6 +88,7 @@ public: // // General data // + Sint32 m_iGuid; bool m_bUsingProfileDefaultModifiers; CString m_sDefaultModifiers; SortOrder m_SortOrder; @@ -106,7 +109,7 @@ public: int m_iTotalMines; int m_iTotalHands; set m_UnlockedSongs; - mutable CString m_sLastPlayedMachineName; // mutable because we overwrite this on save, and I don't want to remove const from the whole save chain. -Chris + mutable Sint32 m_iLastPlayedMachineGuid; // mutable because we overwrite this on save, and I don't want to remove const from the whole save chain. -Chris int m_iNumSongsPlayedByPlayMode[NUM_PLAY_MODES]; int m_iNumSongsPlayedByStyle[NUM_STYLES]; int m_iNumSongsPlayedByDifficulty[NUM_DIFFICULTIES]; @@ -165,10 +168,10 @@ public: // struct Screenshot { - CString sFileName; // no directory part - just the file name - CString sMD5; // MD5 hash of the screenshot file - time_t time; // return value of time() when screenshot was taken - CString sMachineName; // where this screenshot was taken + CString sFileName; // no directory part - just the file name + CString sMD5; // MD5 hash of the screenshot file + time_t time; // return value of time() when screenshot was taken + Sint32 iMachineGuid; // where this screenshot was taken }; vector m_vScreenshots; void AddScreenshot( Screenshot screenshot ); diff --git a/stepmania/src/ProfileHtml.cpp b/stepmania/src/ProfileHtml.cpp index be0e886a51..585b1fd24d 100644 --- a/stepmania/src/ProfileHtml.cpp +++ b/stepmania/src/ProfileHtml.cpp @@ -271,6 +271,7 @@ void PrintStatistics( RageFile &f, const Profile *pProfile, CString sTitle, vect { BEGIN_TABLE(2); TABLE_LINE2( "DisplayName", pProfile->m_sDisplayName ); + TABLE_LINE2( "ID", pProfile->GetDisplayGuid() ); TABLE_LINE2( "LastUsedHighScoreName", pProfile->m_sLastUsedHighScoreName ); TABLE_LINE2( "UsingProfileDefaultModifiers", pProfile->m_bUsingProfileDefaultModifiers ); TABLE_LINE2( "DefaultModifiers", pProfile->m_sDefaultModifiers ); @@ -279,7 +280,7 @@ void PrintStatistics( RageFile &f, const Profile *pProfile, CString sTitle, vect TABLE_LINE2( "TotalGameplay", SecondsToHHMMSS( (float) pProfile->m_iTotalGameplaySeconds) ); TABLE_LINE2( "CurrentCombo", pProfile->m_iCurrentCombo ); TABLE_LINE2( "TotalCaloriesBurned", pProfile->GetDisplayTotalCaloriesBurned() ); - TABLE_LINE2( "LastPlayedMachineName", pProfile->m_sLastPlayedMachineName ); + TABLE_LINE2( "LastPlayedMachineID", pProfile->GetDisplayLastPlayedMachineGuid() ); TABLE_LINE2( "TotalTapsAndHolds", pProfile->m_iTotalTapsAndHolds ); TABLE_LINE2( "TotalJumps", pProfile->m_iTotalJumps ); TABLE_LINE2( "TotalHolds", pProfile->m_iTotalHolds ); @@ -921,7 +922,7 @@ void PrintScreenshot( RageFile &f, const Profile::Screenshot &ss ) TABLE_LINE2( "File", ss.sFileName ); TABLE_LINE2( "MD5", ss.sMD5 ); TABLE_LINE2( "Time", (CString)ctime(&ss.time) ); - TABLE_LINE2( "MachineName", ss.sMachineName ); + TABLE_LINE2( "Machine", ss.iMachineGuid ); END_TABLE; @@ -1134,7 +1135,7 @@ TITLE.c_str(), STYLE_CSS.c_str() ) ); } CString sName = pProfile->GetDisplayName(); - CString sMachineName = pMachineProfile->GetDisplayName(); + CString sMachineName = pProfile->GetDisplayLastPlayedMachineGuid(); time_t ltime = time( NULL ); CString sTime = ctime( <ime ); diff --git a/stepmania/src/ScreenEvaluation.cpp b/stepmania/src/ScreenEvaluation.cpp index 740d2ccdb8..3ba3499352 100644 --- a/stepmania/src/ScreenEvaluation.cpp +++ b/stepmania/src/ScreenEvaluation.cpp @@ -1357,7 +1357,7 @@ void ScreenEvaluation::Input( const DeviceInput& DeviceI, const InputEventType t screenshot.sFileName = sFileName; screenshot.sMD5 = CRYPTMAN->GetMD5( sPath ); screenshot.time = time(NULL); - screenshot.sMachineName = PREFSMAN->m_sMachineName; + screenshot.iMachineGuid = PROFILEMAN->GetMachineProfile()->m_iGuid; pProfile->AddScreenshot( screenshot ); }