From 6a82d3c5a0a7069aae5c4379989932b7213a8d94 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Thu, 27 May 2004 07:59:46 +0000 Subject: [PATCH] add judge counts to HighScore. Will this make Stats.xml too big? --- stepmania/src/GameConstantsAndTypes.cpp | 10 ++++ stepmania/src/GameConstantsAndTypes.h | 9 ++-- stepmania/src/HighScore.cpp | 63 +++++++++++++++---------- stepmania/src/HighScore.h | 13 +++++ stepmania/src/ScreenEvaluation.cpp | 3 ++ 5 files changed, 68 insertions(+), 30 deletions(-) diff --git a/stepmania/src/GameConstantsAndTypes.cpp b/stepmania/src/GameConstantsAndTypes.cpp index 37fd787642..6d006715e3 100644 --- a/stepmania/src/GameConstantsAndTypes.cpp +++ b/stepmania/src/GameConstantsAndTypes.cpp @@ -109,6 +109,16 @@ static const CString TapNoteScoreNames[NUM_TAP_NOTE_SCORES] = { "Marvelous", }; XToString( TapNoteScore ); +StringToX( TapNoteScore ); + + +static const CString HoldNoteScoreNames[NUM_HOLD_NOTE_SCORES] = { + "None", + "OK", + "NG", +}; +XToString( HoldNoteScore ); +StringToX( HoldNoteScore ); static const CString MemoryCardStateNames[NUM_MEMORY_CARD_STATES] = { diff --git a/stepmania/src/GameConstantsAndTypes.h b/stepmania/src/GameConstantsAndTypes.h index d0d7a1e6b2..3a173bdda9 100644 --- a/stepmania/src/GameConstantsAndTypes.h +++ b/stepmania/src/GameConstantsAndTypes.h @@ -189,12 +189,7 @@ enum TapNoteScore { }; #define FOREACH_TapNoteScore( tns ) FOREACH_ENUM( TapNoteScore, NUM_TAP_NOTE_SCORES, tns ) const CString& TapNoteScoreToString( TapNoteScore tns ); - -//enum TapNoteTiming { -// TNT_NONE, -// TNT_EARLY, -// TNT_LATE -//}; +TapNoteScore StringToTapNoteScore( const CString& str ); enum HoldNoteScore @@ -205,6 +200,8 @@ enum HoldNoteScore NUM_HOLD_NOTE_SCORES }; #define FOREACH_HoldNoteScore( hns ) FOREACH_ENUM( HoldNoteScore, NUM_HOLD_NOTE_SCORES, hns ) +const CString& HoldNoteScoreToString( HoldNoteScore tns ); +HoldNoteScore StringToHoldNoteScore( const CString& str ); // diff --git a/stepmania/src/HighScore.cpp b/stepmania/src/HighScore.cpp index 9f8307bbaa..5a92047d0c 100644 --- a/stepmania/src/HighScore.cpp +++ b/stepmania/src/HighScore.cpp @@ -59,6 +59,15 @@ XNode* HighScore::CreateNode() const pNode->AppendChild( "PlayerGuid", sPlayerGuid ); pNode->AppendChild( "MachineGuid", sMachineGuid ); pNode->AppendChild( "ProductID", iProductID ); + XNode* pTapNoteScores = pNode->AppendChild( "TapNoteScores" ); + FOREACH_TapNoteScore( tns ) + pTapNoteScores->AppendChild( TapNoteScoreToString(tns), iTapNoteScores[tns] ); + XNode* pHoldNoteScores = pNode->AppendChild( "HoldNoteScores" ); + FOREACH_HoldNoteScore( hns ) + pHoldNoteScores->AppendChild( HoldNoteScoreToString(hns), iHoldNoteScores[hns] ); + XNode* pRadarCategories = pNode->AppendChild( "RadarActuals" ); + FOREACH_RadarCategory( rc ) + pRadarCategories->AppendChild( RadarCategoryToString(rc), fRadarActual[rc] ); return pNode; } @@ -66,30 +75,36 @@ XNode* HighScore::CreateNode() const void HighScore::LoadFromNode( const XNode* pNode ) { ASSERT( pNode->name == "HighScore" ); - for( XNodes::const_iterator child = pNode->childs.begin(); - child != pNode->childs.end(); - child++ ) - { - if( (*child)->name == "Name" ) (*child)->GetValue( sName ); - else if( (*child)->name == "Grade" ) - { - CString sGrade; - (*child)->GetValue( sGrade ); - /* Pre-a19 compatibility; remove eventually: */ - if( IsAnInt(sGrade) ) - grade = (Grade) atoi( sGrade ); - else - grade = StringToGrade( sGrade ); - } - else if( (*child)->name == "Score" ) (*child)->GetValue( iScore ); - else if( (*child)->name == "PercentDP" ) (*child)->GetValue( fPercentDP ); - else if( (*child)->name == "SurviveSeconds" ) (*child)->GetValue( fSurviveSeconds ); - else if( (*child)->name == "Modifiers" ) (*child)->GetValue( sModifiers ); - else if( (*child)->name == "Time" ) (*child)->GetValue( (int&)time ); - else if( (*child)->name == "PlayerGuid" ) (*child)->GetValue( sPlayerGuid ); - else if( (*child)->name == "MachineGuid" ) (*child)->GetValue( sMachineGuid ); - else if( (*child)->name == "ProductID" ) (*child)->GetValue( iProductID ); - } + + CString s; + + pNode->GetChildValue( "Name", sName ); + pNode->GetChildValue( "Grade", s ); + /* Pre-a19 compatibility; remove eventually */ + if( IsAnInt(s) ) + grade = (Grade) atoi( s ); + else + grade = StringToGrade( s ); + pNode->GetChildValue( "Score", iScore ); + pNode->GetChildValue( "PercentDP", fPercentDP ); + pNode->GetChildValue( "SurviveSeconds", fSurviveSeconds ); + pNode->GetChildValue( "Modifiers", sModifiers ); + pNode->GetChildValue( "Time", (int&)time ); + pNode->GetChildValue( "PlayerGuid", sPlayerGuid ); + pNode->GetChildValue( "MachineGuid", sMachineGuid ); + pNode->GetChildValue( "ProductID", iProductID ); + XNode* pTapNoteScores = pNode->GetChild( "TapNoteScores" ); + if( pTapNoteScores ) + FOREACH_TapNoteScore( tns ) + pTapNoteScores->GetChildValue( TapNoteScoreToString(tns), iTapNoteScores[tns] ); + XNode* pHoldNoteScores = pNode->GetChild( "HoldNoteScores" ); + if( pHoldNoteScores ) + FOREACH_HoldNoteScore( hns ) + pHoldNoteScores->GetChildValue( HoldNoteScoreToString(hns), iHoldNoteScores[hns] ); + XNode* pRadarCategories = pNode->GetChild( "RadarActuals" ); + if( pRadarCategories ) + FOREACH_RadarCategory( rc ) + pRadarCategories->GetChildValue( RadarCategoryToString(rc), fRadarActual[rc] ); /* Validate input. */ grade = clamp( grade, GRADE_TIER_1, GRADE_FAILED ); diff --git a/stepmania/src/HighScore.h b/stepmania/src/HighScore.h index f572aca8ae..28633bb992 100644 --- a/stepmania/src/HighScore.h +++ b/stepmania/src/HighScore.h @@ -13,6 +13,7 @@ */ #include "Grade.h" +#include "GameConstantsAndTypes.h" struct XNode; struct HighScore @@ -27,6 +28,9 @@ struct HighScore CString sPlayerGuid; // who made this high score CString sMachineGuid; // where this high score was made int iProductID; + int iTapNoteScores[NUM_TAP_NOTE_SCORES]; + int iHoldNoteScores[NUM_HOLD_NOTE_SCORES]; + float fRadarActual[NUM_RADAR_CATEGORIES]; HighScore() { Unset(); } void Unset() @@ -41,6 +45,9 @@ struct HighScore sPlayerGuid = ""; sMachineGuid = ""; iProductID = 0; + ZERO( iTapNoteScores ); + ZERO( iHoldNoteScores ); + ZERO( fRadarActual ); } bool operator>=( const HighScore& other ) const; @@ -57,6 +64,12 @@ struct HighScore COMPARE( sPlayerGuid ); COMPARE( sMachineGuid ); COMPARE( iProductID ); + FOREACH_TapNoteScore( tns ) + COMPARE( iTapNoteScores[tns] ); + FOREACH_HoldNoteScore( hns ) + COMPARE( iHoldNoteScores[hns] ); + FOREACH_RadarCategory( rc ) + COMPARE( fRadarActual[rc] ); #undef COMPARE return true; } diff --git a/stepmania/src/ScreenEvaluation.cpp b/stepmania/src/ScreenEvaluation.cpp index 36787b7a27..6e09751dac 100644 --- a/stepmania/src/ScreenEvaluation.cpp +++ b/stepmania/src/ScreenEvaluation.cpp @@ -899,6 +899,9 @@ void ScreenEvaluation::CommitScores( hs.sPlayerGuid = PROFILEMAN->IsUsingProfile(p) ? PROFILEMAN->GetProfile(p)->m_sGuid : ""; hs.sMachineGuid = PROFILEMAN->GetMachineProfile()->m_sGuid; hs.iProductID = PREFSMAN->m_iProductID; + memcpy( hs.iTapNoteScores, stageStats.iTapNoteScores[p], sizeof(hs.iTapNoteScores) ); + memcpy( hs.iHoldNoteScores, stageStats.iHoldNoteScores[p], sizeof(hs.iHoldNoteScores) ); + memcpy( hs.fRadarActual, stageStats.fRadarActual[p], sizeof(hs.fRadarActual) ); StepsType st = GAMESTATE->GetCurrentStyleDef()->m_StepsType;