From ad9e71076659c36049d6e53c1691db38af1bdee5 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sun, 18 Apr 2004 05:46:43 +0000 Subject: [PATCH] save guid as string --- stepmania/src/Profile.cpp | 35 +++++++++++------------------- stepmania/src/Profile.h | 8 +++---- stepmania/src/ProfileHtml.cpp | 8 +++---- stepmania/src/ScreenAward.cpp | 2 +- stepmania/src/ScreenEvaluation.cpp | 2 +- 5 files changed, 22 insertions(+), 33 deletions(-) diff --git a/stepmania/src/Profile.cpp b/stepmania/src/Profile.cpp index 18bc52e80a..dbe3336b44 100644 --- a/stepmania/src/Profile.cpp +++ b/stepmania/src/Profile.cpp @@ -44,6 +44,7 @@ const int SM_390A12_CATEGORY_RANKING_VERSION = 6; const int SM_390A12_SONG_SCORES_VERSION = 9; const int SM_390A12_COURSE_SCORES_VERSION = 8; +#define GUID_SIZE_BYTES 8 #if defined(WIN32) #pragma warning (disable : 4706) // assignment within conditional expression @@ -56,7 +57,6 @@ const int SM_390A12_COURSE_SCORES_VERSION = 8; (Var##Iter != Node->childs.end() && (Var = *Var##Iter) ), Var##Iter != Node->childs.end(); \ ++Var##Iter ) - void Profile::InitEditableData() { m_sDisplayName = ""; @@ -72,8 +72,9 @@ void Profile::InitGeneralData() random_add_noise( "ai8049ujr3odusj" ); { - for( unsigned i=0; iGetMachineProfile()->m_iGuid; + m_sLastPlayedMachineGuid = PROFILEMAN->GetMachineProfile()->m_sGuid; // Save editable.xml SaveEditableDataToDir( sDir ); @@ -563,7 +554,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", "LastPlayedMachineGuid", m_iLastPlayedMachineGuid ); + ini.GetValue( "Profile", "LastPlayedMachineGuid", m_sLastPlayedMachineGuid ); unsigned i; for( i=0; iname = "GeneralData"; - pGeneralDataNode->AppendChild( "Guid", m_iGuid ); + pGeneralDataNode->AppendChild( "Guid", m_sGuid ); pGeneralDataNode->AppendChild( "UsingProfileDefaultModifiers", m_bUsingProfileDefaultModifiers ); pGeneralDataNode->AppendChild( "DefaultModifiers", m_sDefaultModifiers ); pGeneralDataNode->AppendChild( "SortOrder", SortOrderToString(m_SortOrder) ); @@ -606,7 +597,7 @@ XNode* Profile::SaveGeneralDataCreateNode() const pGeneralDataNode->AppendChild( "TotalGameplaySeconds", m_iTotalGameplaySeconds ); pGeneralDataNode->AppendChild( "CurrentCombo", m_iCurrentCombo ); pGeneralDataNode->AppendChild( "TotalCaloriesBurned", m_fTotalCaloriesBurned ); - pGeneralDataNode->AppendChild( "LastPlayedMachineGuid", m_iLastPlayedMachineGuid ); + pGeneralDataNode->AppendChild( "LastPlayedMachineGuid", m_sLastPlayedMachineGuid ); pGeneralDataNode->AppendChild( "TotalDancePoints", m_iTotalDancePoints ); pGeneralDataNode->AppendChild( "NumExtraStagesPassed", m_iNumExtraStagesPassed ); pGeneralDataNode->AppendChild( "NumExtraStagesFailed", m_iNumExtraStagesFailed ); @@ -735,7 +726,7 @@ void Profile::LoadGeneralDataFromNode( const XNode* pNode ) CString s; - pNode->GetChildValue( "Guid", m_iGuid ); + pNode->GetChildValue( "Guid", m_sGuid ); pNode->GetChildValue( "UsingProfileDefaultModifiers", m_bUsingProfileDefaultModifiers ); pNode->GetChildValue( "DefaultModifiers", m_sDefaultModifiers ); pNode->GetChildValue( "SortOrder", s ); m_SortOrder = StringToSortOrder( s ); @@ -747,7 +738,7 @@ void Profile::LoadGeneralDataFromNode( const XNode* pNode ) pNode->GetChildValue( "TotalGameplaySeconds", m_iTotalGameplaySeconds ); pNode->GetChildValue( "CurrentCombo", m_iCurrentCombo ); pNode->GetChildValue( "TotalCaloriesBurned", m_fTotalCaloriesBurned ); - pNode->GetChildValue( "LastPlayedMachineGuid", m_iLastPlayedMachineGuid ); + pNode->GetChildValue( "LastPlayedMachineGuid", m_sLastPlayedMachineGuid ); pNode->GetChildValue( "TotalDancePoints", m_iTotalDancePoints ); pNode->GetChildValue( "NumExtraStagesPassed", m_iNumExtraStagesPassed ); pNode->GetChildValue( "NumExtraStagesFailed", m_iNumExtraStagesFailed ); @@ -1560,7 +1551,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("MachineGuid",ss.iMachineGuid) ) + if( !(*screenshot)->GetChildValue("MachineGuid",ss.sMachineGuid) ) WARN; m_vScreenshots.push_back( ss ); @@ -1586,7 +1577,7 @@ XNode* Profile::SaveScreenshotDataCreateNode() const pScreenshotNode->AppendChild( "FileName", ss.sFileName ); pScreenshotNode->AppendChild( "MD5", ss.sMD5 ); pScreenshotNode->AppendChild( "Time", (int) ss.time ); - pScreenshotNode->AppendChild( "MachineGuid", ss.iMachineGuid ); + pScreenshotNode->AppendChild( "MachineGuid", ss.sMachineGuid ); } return pNode; diff --git a/stepmania/src/Profile.h b/stepmania/src/Profile.h index 5ca09520cb..e9051568bc 100644 --- a/stepmania/src/Profile.h +++ b/stepmania/src/Profile.h @@ -67,8 +67,6 @@ public: // smart accessors // CString GetDisplayName() const; - CString GetDisplayGuid() const; - CString GetDisplayLastPlayedMachineGuid() const; CString GetDisplayTotalCaloriesBurned() const; int GetTotalNumSongsPlayed() const; int GetTotalNumSongsPassed() const; @@ -88,7 +86,7 @@ public: // // General data // - Sint32 m_iGuid; + CString m_sGuid; bool m_bUsingProfileDefaultModifiers; CString m_sDefaultModifiers; SortOrder m_SortOrder; @@ -110,7 +108,7 @@ public: int m_iTotalMines; int m_iTotalHands; set m_UnlockedSongs; - 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 + mutable CString m_sLastPlayedMachineGuid; // 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]; @@ -172,7 +170,7 @@ public: 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 + CString sMachineGuid; // 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 6b20212f38..28e58e6124 100644 --- a/stepmania/src/ProfileHtml.cpp +++ b/stepmania/src/ProfileHtml.cpp @@ -271,7 +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( "ID", pProfile->m_sGuid ); TABLE_LINE2( "LastUsedHighScoreName", pProfile->m_sLastUsedHighScoreName ); TABLE_LINE2( "UsingProfileDefaultModifiers", pProfile->m_bUsingProfileDefaultModifiers ); TABLE_LINE2( "DefaultModifiers", pProfile->m_sDefaultModifiers ); @@ -280,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( "LastPlayedMachineID", pProfile->GetDisplayLastPlayedMachineGuid() ); + TABLE_LINE2( "LastPlayedMachineID", pProfile->m_sGuid ); TABLE_LINE2( "TotalTapsAndHolds", pProfile->m_iTotalTapsAndHolds ); TABLE_LINE2( "TotalJumps", pProfile->m_iTotalJumps ); TABLE_LINE2( "TotalHolds", pProfile->m_iTotalHolds ); @@ -922,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( "Machine", ss.iMachineGuid ); + TABLE_LINE2( "Machine", ss.sMachineGuid ); END_TABLE; @@ -1135,7 +1135,7 @@ TITLE.c_str(), STYLE_CSS.c_str() ) ); } CString sName = pProfile->GetDisplayName(); - CString sMachineName = pProfile->GetDisplayLastPlayedMachineGuid(); + CString sMachineName = pProfile->m_sGuid; time_t ltime = time( NULL ); CString sTime = ctime( <ime ); diff --git a/stepmania/src/ScreenAward.cpp b/stepmania/src/ScreenAward.cpp index 1184574ff4..5357c897a3 100644 --- a/stepmania/src/ScreenAward.cpp +++ b/stepmania/src/ScreenAward.cpp @@ -129,7 +129,7 @@ void ScreenAward::Input( const DeviceInput& DeviceI, const InputEventType type, screenshot.sFileName = sFileName; screenshot.sMD5 = CRYPTMAN->GetMD5( sPath ); screenshot.time = time(NULL); - screenshot.iMachineGuid = PROFILEMAN->GetMachineProfile()->m_iGuid; + screenshot.sMachineGuid = PROFILEMAN->GetMachineProfile()->m_sGuid; pProfile->AddScreenshot( screenshot ); } diff --git a/stepmania/src/ScreenEvaluation.cpp b/stepmania/src/ScreenEvaluation.cpp index c5e145f51d..4a15b1cb57 100644 --- a/stepmania/src/ScreenEvaluation.cpp +++ b/stepmania/src/ScreenEvaluation.cpp @@ -1451,7 +1451,7 @@ void ScreenEvaluation::Input( const DeviceInput& DeviceI, const InputEventType t screenshot.sFileName = sFileName; screenshot.sMD5 = CRYPTMAN->GetMD5( sPath ); screenshot.time = time(NULL); - screenshot.iMachineGuid = PROFILEMAN->GetMachineProfile()->m_iGuid; + screenshot.sMachineGuid = PROFILEMAN->GetMachineProfile()->m_sGuid; pProfile->AddScreenshot( screenshot ); }