diff --git a/stepmania/src/Profile.cpp b/stepmania/src/Profile.cpp index b7464a3a82..a4f0e8a8c3 100644 --- a/stepmania/src/Profile.cpp +++ b/stepmania/src/Profile.cpp @@ -135,20 +135,6 @@ void Profile::InitCalorieData() m_mapDayToCaloriesBurned.clear(); } -void Profile::InitAwards() -{ - FOREACH_StepsType( st ) - { - FOREACH_Difficulty( dc ) - FOREACH_PerDifficultyAward( pda ) - m_PerDifficultyAwards[st][dc][pda].Unset(); - } - FOREACH_PeakComboAward( pca ) - { - m_PeakComboAwards[pca].Unset(); - } -} - void Profile::InitRecentSongScores() { m_vRecentStepsScores.clear(); @@ -632,7 +618,6 @@ bool Profile::LoadAllFromDir( CString sDir, bool bRequireSignature ) LOAD_NODE( CategoryScores ); LOAD_NODE( ScreenshotData ); LOAD_NODE( CalorieData ); - LOAD_NODE( Awards ); LOAD_NODE( RecentSongScores ); LOAD_NODE( RecentCourseScores ); } @@ -660,7 +645,6 @@ bool Profile::SaveAllToDir( CString sDir, bool bSignData ) const xml.AppendChild( SaveCategoryScoresCreateNode() ); xml.AppendChild( SaveScreenshotDataCreateNode() ); xml.AppendChild( SaveCalorieDataCreateNode() ); - xml.AppendChild( SaveAwardsCreateNode() ); xml.AppendChild( SaveRecentSongScoresCreateNode() ); xml.AppendChild( SaveRecentCourseScoresCreateNode() ); @@ -1335,158 +1319,6 @@ float Profile::GetCaloriesBurnedForDay( DateTime day ) const return i->second; } -XNode* Profile::AwardRecord::CreateNode() const -{ - XNode* pNode = new XNode; - pNode->name = "AwardRecord"; - - pNode->AppendChild( "FirstTime", int(first) ); - pNode->AppendChild( "LastTime", int(last) ); - pNode->AppendChild( "Count", iCount ); - - return pNode; -} - -void Profile::AwardRecord::LoadFromNode( const XNode* pNode ) -{ - Unset(); - - ASSERT( pNode->name == "AwardRecord" ); - pNode->GetChildValue( "FirstTime", (int&)first ); // time_t is a signed long in Win32. Is this OK on other platforms? - pNode->GetChildValue( "LastTime", (int&)last ); - pNode->GetChildValue( "Count", iCount ); -} - -void Profile::LoadAwardsFromNode( const XNode* pNode ) -{ - CHECKPOINT; - - ASSERT( pNode->name == "Awards" ); - for( XNodes::const_iterator pAward = pNode->childs.begin(); - pAward != pNode->childs.end(); - pAward++ ) - { - if( (*pAward)->name == "PerDifficultyAward" ) - { - CString sStepsType; - if( !(*pAward)->GetAttrValue( "StepsType", sStepsType ) ) - WARN_AND_CONTINUE; - StepsType st = GameManager::StringToStepsType( sStepsType ); - if( st == STEPS_TYPE_INVALID ) - WARN_AND_CONTINUE; - - CString sDifficulty; - if( !(*pAward)->GetAttrValue( "Difficulty", sDifficulty ) ) - WARN_AND_CONTINUE; - Difficulty dc = StringToDifficulty( sDifficulty ); - if( dc == DIFFICULTY_INVALID ) - WARN_AND_CONTINUE; - - CString sPerDifficultyAward; - if( !(*pAward)->GetAttrValue( "PerDifficultyAward", sPerDifficultyAward ) ) - WARN_AND_CONTINUE; - PerDifficultyAward pda = StringToPerDifficultyAward( sPerDifficultyAward ); - if( pda == PER_DIFFICULTY_AWARD_INVALID ) - WARN_AND_CONTINUE; - - AwardRecord &ar = m_PerDifficultyAwards[st][dc][pda]; - - XNode* pAwardRecord = (*pAward)->GetChild("AwardRecord"); - if( pAwardRecord == NULL ) - WARN_AND_CONTINUE; - - ar.LoadFromNode( pAwardRecord ); - } - else if( (*pAward)->name == "PeakComboAward" ) - { - CString sPeakComboAward; - if( !(*pAward)->GetAttrValue( "PeakComboAward", sPeakComboAward ) ) - WARN_AND_CONTINUE; - PeakComboAward pca = StringToPeakComboAward( sPeakComboAward ); - if( pca == PEAK_COMBO_AWARD_INVALID ) - WARN_AND_CONTINUE; - - AwardRecord &ar = m_PeakComboAwards[pca]; - - XNode* pAwardRecord = (*pAward)->GetChild("AwardRecord"); - if( pAwardRecord == NULL ) - WARN_AND_CONTINUE; - - ar.LoadFromNode( pAwardRecord ); - } - else - WARN_AND_CONTINUE; - } -} - -XNode* Profile::SaveAwardsCreateNode() const -{ - CHECKPOINT; - - const Profile* pProfile = this; - ASSERT( pProfile ); - - XNode* pNode = new XNode; - pNode->name = "Awards"; - - FOREACH_StepsType( st ) - { - FOREACH_Difficulty( dc ) - { - FOREACH_PerDifficultyAward( pda ) - { - const AwardRecord &ar = m_PerDifficultyAwards[st][dc][pda]; - if( !ar.IsSet() ) - continue; - - XNode* pAward = pNode->AppendChild( "PerDifficultyAward" ); - - pAward->AppendAttr( "StepsType", GameManager::StepsTypeToString(st) ); - pAward->AppendAttr( "Difficulty", DifficultyToString(dc) ); - pAward->AppendAttr( "PerDifficultyAward", PerDifficultyAwardToString(pda) ); - - pAward->AppendChild( ar.CreateNode() ); - } - } - } - - FOREACH_PeakComboAward( pca ) - { - const AwardRecord &ar = m_PeakComboAwards[pca]; - if( !ar.IsSet() ) - continue; - - XNode* pAward = pNode->AppendChild( "PeakComboAward" ); - - pAward->AppendAttr( "PeakComboAward", PeakComboAwardToString(pca) ); - - pAward->AppendChild( ar.CreateNode() ); - } - - return pNode; -} - -void Profile::AddPerDifficultyAward( StepsType st, Difficulty dc, PerDifficultyAward pda ) -{ - m_PerDifficultyAwards[st][dc][pda].Set( time(NULL) ); -} - -void Profile::AddPeakComboAward( PeakComboAward pca ) -{ - m_PeakComboAwards[pca].Set( time(NULL) ); -} - -bool Profile::HasPerDifficultyAward( StepsType st, Difficulty dc, PerDifficultyAward pda ) -{ - return m_PerDifficultyAwards[st][dc][pda].IsSet(); -} - -bool Profile::HasPeakComboAward( PeakComboAward pca ) -{ - return m_PeakComboAwards[pca].IsSet(); -} - - XNode* Profile::HighScoreForASongAndSteps::CreateNode() const { XNode* pNode = new XNode; diff --git a/stepmania/src/Profile.h b/stepmania/src/Profile.h index 4310125deb..34f0f4482a 100644 --- a/stepmania/src/Profile.h +++ b/stepmania/src/Profile.h @@ -191,30 +191,6 @@ public: map m_mapDayToCaloriesBurned; float GetCaloriesBurnedForDay( DateTime day ) const; - // - // Awards - // - struct AwardRecord - { - time_t first; - time_t last; - int iCount; // num times achieved - - AwardRecord() { Unset(); } - - bool IsSet() const { return iCount>0; } - void Set(time_t t) { if (iCount==0) first = t; last = t; iCount++; } - void Unset() { iCount = 0; first = -1; last = -1; } - - XNode* CreateNode() const; - void LoadFromNode( const XNode* pNode ); - }; - AwardRecord m_PerDifficultyAwards[NUM_STEPS_TYPES][NUM_DIFFICULTIES][NUM_PER_DIFFICULTY_AWARDS]; - AwardRecord m_PeakComboAwards[NUM_PEAK_COMBO_AWARDS]; - void AddPerDifficultyAward( StepsType st, Difficulty dc, PerDifficultyAward pda ); - void AddPeakComboAward( PeakComboAward pca ); - bool HasPerDifficultyAward( StepsType st, Difficulty dc, PerDifficultyAward pda ); - bool HasPeakComboAward( PeakComboAward pca ); // // RecentSongScores @@ -264,7 +240,6 @@ public: InitCategoryScores(); InitScreenshotData(); InitCalorieData(); - InitAwards(); InitRecentSongScores(); InitRecentCourseScores(); } @@ -275,7 +250,6 @@ public: void InitCategoryScores(); void InitScreenshotData(); void InitCalorieData(); - void InitAwards(); void InitRecentSongScores(); void InitRecentCourseScores(); @@ -292,7 +266,6 @@ public: void LoadCategoryScoresFromNode( const XNode* pNode ); void LoadScreenshotDataFromNode( const XNode* pNode ); void LoadCalorieDataFromNode( const XNode* pNode ); - void LoadAwardsFromNode( const XNode* pNode ); void LoadRecentSongScoresFromNode( const XNode* pNode ); void LoadRecentCourseScoresFromNode( const XNode* pNode ); @@ -303,7 +276,6 @@ public: XNode* SaveCategoryScoresCreateNode() const; XNode* SaveScreenshotDataCreateNode() const; XNode* SaveCalorieDataCreateNode() const; - XNode* SaveAwardsCreateNode() const; XNode* SaveRecentSongScoresCreateNode() const; XNode* SaveRecentCourseScoresCreateNode() const; diff --git a/stepmania/src/ScreenEvaluation.cpp b/stepmania/src/ScreenEvaluation.cpp index 5f592e7c7e..669ec67864 100644 --- a/stepmania/src/ScreenEvaluation.cpp +++ b/stepmania/src/ScreenEvaluation.cpp @@ -1111,52 +1111,6 @@ void ScreenEvaluation::CommitScores( pcaToShowOut[p] = GAMESTATE->m_vLastPeakComboAwards[p].back(); LOG->Trace( "done with per combo awards" ); - - - // - // erase awards from the Last list that have been received so that we - // won't show them again. - // - if( !PROFILEMAN->IsUsingProfile(p) ) - { - // don't show any awards on ScreenAward unless using a profile - GAMESTATE->m_vLastPerDifficultyAwards[p].clear(); - GAMESTATE->m_vLastPeakComboAwards[p].clear(); - } - else - { - Profile* pProfile = PROFILEMAN->GetProfile(p); - - switch( m_Type ) - { - case stage: - for( int i=GAMESTATE->m_vLastPerDifficultyAwards[p].size()-1; i>=0; i-- ) - { - PerDifficultyAward pda = GAMESTATE->m_vLastPerDifficultyAwards[p][i]; - Steps* pSteps = stageStats.pSteps[p]; - ASSERT( pSteps != NULL ); - bool bAlreadyHad = pProfile->HasPerDifficultyAward( pSteps->m_StepsType, pSteps->GetDifficulty(), pda ); - pProfile->AddPerDifficultyAward( pSteps->m_StepsType, pSteps->GetDifficulty(), pda ); - if( bAlreadyHad ) - GAMESTATE->m_vLastPerDifficultyAwards[p].erase( GAMESTATE->m_vLastPerDifficultyAwards[p].begin()+i ); - } - } - - LOG->Trace( "done erasing dupe pdas" ); - - { - for( int i=GAMESTATE->m_vLastPeakComboAwards[p].size()-1; i>=0; i-- ) - { - PeakComboAward pca = GAMESTATE->m_vLastPeakComboAwards[p][i]; - bool bAlreadyHad = pProfile->HasPeakComboAward( pca ); - pProfile->AddPeakComboAward( pca ); - if( bAlreadyHad ) - GAMESTATE->m_vLastPeakComboAwards[p].erase( GAMESTATE->m_vLastPeakComboAwards[p].begin()+i ); - } - } - - LOG->Trace( "done erasing pcas" ); - } } }