keep a Guid in Profile

This commit is contained in:
Chris Danford
2004-03-14 17:49:38 +00:00
parent 105f307d5f
commit 063c2cf3a4
5 changed files with 45 additions and 17 deletions
+1
View File
@@ -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 );
+31 -8
View File
@@ -25,11 +25,11 @@
#include <time.h>
#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; i<sizeof(m_iGuid); i++ )
((Uint8*)&m_iGuid)[i] = random_byte();
}
m_bUsingProfileDefaultModifiers = false;
m_sDefaultModifiers = "";
m_SortOrder = SORT_INVALID;
@@ -81,7 +92,7 @@ void Profile::InitGeneralData()
m_iNumExtraStagesFailed = 0;
m_iNumToasties = 0;
m_UnlockedSongs.clear();
m_sLastPlayedMachineName = "";
m_iLastPlayedMachineGuid = 0;
m_iTotalTapsAndHolds = 0;
m_iTotalJumps = 0;
m_iTotalHolds = 0;
@@ -152,6 +163,16 @@ CString Profile::GetDisplayName() const
return "NoName";
}
CString Profile::GetDisplayGuid() const
{
return ssprintf("%x",m_iGuid);
}
CString Profile::GetDisplayLastPlayedMachineGuid() const
{
return ssprintf("%x",m_iLastPlayedMachineGuid);
}
CString Profile::GetDisplayTotalCaloriesBurned() const
{
if( m_iWeightPounds == 0 ) // weight not entered
@@ -466,7 +487,7 @@ bool Profile::LoadAllFromDir( CString sDir )
bool Profile::SaveAllToDir( CString sDir ) const
{
m_sLastPlayedMachineName = PREFSMAN->m_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; i<NUM_PLAY_MODES; i++ )
@@ -567,6 +588,7 @@ XNode* Profile::SaveGeneralDataCreateNode() const
XNode* pGeneralDataNode = new XNode;
pGeneralDataNode->name = "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;
+8 -5
View File
@@ -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<int> 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<Screenshot> m_vScreenshots;
void AddScreenshot( Screenshot screenshot );
+4 -3
View File
@@ -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( &ltime );
+1 -1
View File
@@ -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 );
}