From 9f324dc74fb19dd5128ac090025261b142d159ee Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 3 Jun 2007 02:39:13 +0000 Subject: [PATCH] add UnlockAuthString --- stepmania/src/Profile.cpp | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/stepmania/src/Profile.cpp b/stepmania/src/Profile.cpp index 9504352eda..fb86b24bdc 100644 --- a/stepmania/src/Profile.cpp +++ b/stepmania/src/Profile.cpp @@ -41,6 +41,7 @@ const RString EDIT_COURSES_SUBDIR = "EditCourses/"; ThemeMetric SHOW_COIN_DATA( "Profile", "ShowCoinData" ); static Preference g_bProfileDataCompress( "ProfileDataCompress", false ); static Preference g_bCopyCatalogToProfiles( "CopyCatalogToProfiles", true ); +static Preference UNLOCK_AUTH_STRING( "Profile", "UnlockAuthString" ); #define GUID_SIZE_BYTES 8 @@ -1098,7 +1099,16 @@ XNode* Profile::SaveGeneralDataCreateNode() const { XNode* pUnlocks = pGeneralDataNode->AppendChild("Unlocks"); FOREACHS_CONST( RString, m_UnlockedEntryIDs, it ) - pUnlocks->AppendChild("UnlockEntry")->AppendAttr( "UnlockEntryID", it->c_str() ); + { + XNode *pEntry = pUnlocks->AppendChild("UnlockEntry"); + RString sUnlockEntry = it->c_str(); + pEntry->AppendAttr( "UnlockEntryID", sUnlockEntry ); + if( !UNLOCK_AUTH_STRING.Get().empty() ) + { + RString sUnlockAuth = BinaryToHex( CRYPTMAN->GetMD5ForString(sUnlockEntry + UNLOCK_AUTH_STRING.Get()) ); + pEntry->AppendAttr( "Auth", sUnlockAuth ); + } + } } { @@ -1264,8 +1274,21 @@ void Profile::LoadGeneralDataFromNode( const XNode* pNode ) FOREACH_CONST_Child( pUnlocks, unlock ) { RString sUnlockEntryID; - if( unlock->GetAttrValue("UnlockEntryID",sUnlockEntryID) ) - m_UnlockedEntryIDs.insert( sUnlockEntryID ); + if( !unlock->GetAttrValue("UnlockEntryID",sUnlockEntryID) ) + continue; + + if( !UNLOCK_AUTH_STRING.Get().empty() ) + { + RString sUnlockAuth; + if( !unlock->GetAttrValue("Auth", sUnlockAuth) ) + continue; + + RString sExpectedUnlockAuth = BinaryToHex( CRYPTMAN->GetMD5ForString(sUnlockEntryID + UNLOCK_AUTH_STRING.Get()) ); + if( sUnlockAuth != sExpectedUnlockAuth ) + continue; + } + + m_UnlockedEntryIDs.insert( sUnlockEntryID ); } } }