From c6de356dca3537c771adae487ecbbabff99fde50 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 23 Feb 2005 22:52:03 +0000 Subject: [PATCH] Keep track of number of songs played. The other stats all count per- player: if one person plays on Hard and one on Easy, then each will be incremented. That's useful, but it's also helpful to track the simple number of songs played, irrespective of how many people were playing at the time. --- stepmania/src/Profile.cpp | 5 +++++ stepmania/src/Profile.h | 4 ++++ stepmania/src/StatsManager.cpp | 7 ++++--- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/stepmania/src/Profile.cpp b/stepmania/src/Profile.cpp index 522173c2bd..ca1fee77e4 100644 --- a/stepmania/src/Profile.cpp +++ b/stepmania/src/Profile.cpp @@ -102,6 +102,7 @@ void Profile::InitGeneralData() m_iNumSongsPlayedByDifficulty[i] = 0; for( int i=0; iAppendChild( "NumSingleSongsPlayed", m_iNumSingleSongsPlayed ); + { XNode* pNumStagesPassedByPlayMode = pGeneralDataNode->AppendChild("NumStagesPassedByPlayMode"); FOREACH_PlayMode( pm ) @@ -1053,6 +1056,8 @@ void Profile::LoadGeneralDataFromNode( const XNode* pNode ) pNumSongsPlayedByMeter->GetChildValue( ssprintf("Meter%d",i), m_iNumSongsPlayedByMeter[i] ); } + pNode->GetChildValue("NumSingleSongsPlayed", m_iNumSingleSongsPlayed ); + { const XNode* pNumStagesPassedByGrade = pNode->GetChild("NumStagesPassedByGrade"); if( pNumStagesPassedByGrade ) diff --git a/stepmania/src/Profile.h b/stepmania/src/Profile.h index f6af3c3f2d..0bbbfe200a 100644 --- a/stepmania/src/Profile.h +++ b/stepmania/src/Profile.h @@ -122,10 +122,14 @@ public: set m_UnlockedSongs; 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 mutable DateTime m_LastPlayedDate; + /* These stats count twice in the machine profile if two players are playing; + * that's the only approach that makes sense for ByDifficulty and ByMeter. */ int m_iNumSongsPlayedByPlayMode[NUM_PLAY_MODES]; map m_iNumSongsPlayedByStyle; int m_iNumSongsPlayedByDifficulty[NUM_DIFFICULTIES]; int m_iNumSongsPlayedByMeter[MAX_METER+1]; + /* This stat counts once per song, even if two players are active. */ + int m_iNumSingleSongsPlayed; int m_iNumStagesPassedByPlayMode[NUM_PLAY_MODES]; int m_iNumStagesPassedByGrade[NUM_GRADES]; diff --git a/stepmania/src/StatsManager.cpp b/stepmania/src/StatsManager.cpp index 79d12e207f..178aab4f60 100644 --- a/stepmania/src/StatsManager.cpp +++ b/stepmania/src/StatsManager.cpp @@ -142,6 +142,7 @@ void StatsManager::CommitStatsToProfiles() pMachineProfile->m_iTotalGameplaySeconds += iGameplaySeconds; pMachineProfile->m_iCurrentCombo = 0; + pMachineProfile->m_iNumSingleSongsPlayed += m_CurStageStats.vpSongs.size(); CHECKPOINT; FOREACH_HumanPlayer( pn ) @@ -156,13 +157,13 @@ void StatsManager::CommitStatsToProfiles() PREFSMAN->m_bComboContinuesBetweenSongs ? m_CurStageStats.m_player[pn].iCurCombo : 0; + pPlayerProfile->m_iNumSingleSongsPlayed += m_CurStageStats.vpSongs.size(); } - const StageStats& ss = m_CurStageStats; - AddPlayerStatsToProfile( pMachineProfile, ss, pn ); + AddPlayerStatsToProfile( pMachineProfile, m_CurStageStats, pn ); if( pPlayerProfile ) - AddPlayerStatsToProfile( pPlayerProfile, ss, pn ); + AddPlayerStatsToProfile( pPlayerProfile, m_CurStageStats, pn ); CHECKPOINT; }