diff --git a/stepmania/src/GameCommand.cpp b/stepmania/src/GameCommand.cpp index 6f87e9858d..190797a835 100644 --- a/stepmania/src/GameCommand.cpp +++ b/stepmania/src/GameCommand.cpp @@ -613,7 +613,7 @@ static HighScore MakeRandomHighScore( float fPercentDP ) HighScore hs; hs.SetName( "FAKE" ); hs.SetGrade( (Grade)SCALE( rand()%5, 0, 4, GRADE_TIER01, GRADE_TIER05 ) ); - hs.iScore = rand()%100*1000; + hs.SetScore( rand()%100*1000 ); hs.fPercentDP = fPercentDP; hs.fSurviveSeconds = randomf( 30.0f, 100.0f ); PlayerOptions po; diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index 9f359e2f13..215596c7a2 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -1393,7 +1393,7 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector &asFeatsOu feat.pStringToFill = hs.GetNameMutable(); feat.grade = hs.GetGrade(); feat.fPercentDP = hs.fPercentDP; - feat.iScore = hs.iScore; + feat.iScore = hs.GetScore(); if( pSong->HasBanner() ) feat.Banner = pSong->GetBannerPath(); @@ -1421,7 +1421,7 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector &asFeatsOu feat.pStringToFill = hs.GetNameMutable(); feat.grade = hs.GetGrade(); feat.fPercentDP = hs.fPercentDP; - feat.iScore = hs.iScore; + feat.iScore = hs.GetScore(); // XXX: temporary hack if( pSong->HasBackground() ) @@ -1454,7 +1454,7 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector &asFeatsOu feat.Feat = ssprintf("MR #%d in Type %c (%d)", j+1, 'A'+rc, stats.GetAverageMeter(pn) ); feat.pStringToFill = hs.GetNameMutable(); feat.grade = GRADE_NO_DATA; - feat.iScore = hs.iScore; + feat.iScore = hs.GetScore(); feat.fPercentDP = hs.fPercentDP; asFeatsOut.push_back( feat ); } @@ -1477,7 +1477,7 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector &asFeatsOu feat.Feat = ssprintf("PR #%d in Type %c (%d)", j+1, 'A'+rc, stats.GetAverageMeter(pn) ); feat.pStringToFill = hs.GetNameMutable(); feat.grade = GRADE_NO_DATA; - feat.iScore = hs.iScore; + feat.iScore = hs.GetScore(); feat.fPercentDP = hs.fPercentDP; asFeatsOut.push_back( feat ); } @@ -1514,7 +1514,7 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector &asFeatsOu feat.Feat += " " + CourseDifficultyToThemedString(cd); feat.pStringToFill = hs.GetNameMutable(); feat.grade = GRADE_NO_DATA; - feat.iScore = hs.iScore; + feat.iScore = hs.GetScore(); feat.fPercentDP = hs.fPercentDP; if( pCourse->HasBanner() ) feat.Banner = pCourse->m_sBannerPath; @@ -1538,7 +1538,7 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector &asFeatsOu feat.Feat = ssprintf("PR #%d in %s", i+1, pCourse->GetDisplayFullTitle().c_str() ); feat.pStringToFill = hs.GetNameMutable(); feat.grade = GRADE_NO_DATA; - feat.iScore = hs.iScore; + feat.iScore = hs.GetScore(); feat.fPercentDP = hs.fPercentDP; if( pCourse->HasBanner() ) feat.Banner = pCourse->m_sBannerPath; diff --git a/stepmania/src/HighScore.cpp b/stepmania/src/HighScore.cpp index e7e63427f2..9505240da4 100644 --- a/stepmania/src/HighScore.cpp +++ b/stepmania/src/HighScore.cpp @@ -12,6 +12,8 @@ struct HighScoreImpl { CString sName; // name that shows in the machine's ranking screen + Grade grade; + int iScore; void Unset(); void AppendChildren( XNode *pNode ) const; @@ -25,6 +27,8 @@ bool HighScoreImpl::operator==( const HighScoreImpl& other ) const { #define COMPARE(x) if( x!=other.x ) return false; COMPARE( sName ); + COMPARE( grade ); + COMPARE( iScore ); #undef COMPARE return true; @@ -33,17 +37,29 @@ bool HighScoreImpl::operator==( const HighScoreImpl& other ) const void HighScoreImpl::Unset() { sName = ""; + grade = GRADE_NO_DATA; + iScore = 0; } void HighScoreImpl::AppendChildren( XNode *pNode ) const { pNode->AppendChild( "Name", IsRankingToFillIn(sName) ? CString("") : sName ); + pNode->AppendChild( "Grade", GradeToString(grade) ); + pNode->AppendChild( "Score", iScore ); } void HighScoreImpl::LoadFromNode( const XNode *pNode ) { + CString s; + pNode->GetChildValue( "Name", sName ); + pNode->GetChildValue( "Grade", s ); + grade = StringToGrade( s ); + pNode->GetChildValue( "Score", iScore ); + + /* Validate input. */ + grade = clamp( grade, GRADE_TIER01, GRADE_FAILED ); } REGISTER_CLASS_TRAITS( HighScoreImpl, new HighScoreImpl(*pCopy) ) @@ -57,8 +73,6 @@ HighScore::HighScore() void HighScore::Unset() { m_Impl->Unset(); - grade = GRADE_NO_DATA; - iScore = 0; fPercentDP = 0; fSurviveSeconds = 0; sModifiers = ""; @@ -74,6 +88,10 @@ void HighScore::Unset() CString HighScore::GetName() const { return m_Impl->sName; } void HighScore::SetName( const CString &sName ) { m_Impl->sName = sName; } +Grade HighScore::GetGrade() const { return m_Impl->grade; } +void HighScore::SetGrade( Grade g ) { m_Impl->grade = g; } +int HighScore::GetScore() const { return m_Impl->iScore; } +void HighScore::SetScore( int iScore ) { m_Impl->iScore = iScore; } /* We normally don't give direct access to the members. We need this one * for NameToFillIn; use a special accessor so it's easy to find where this @@ -87,16 +105,16 @@ bool HighScore::operator>=( const HighScore& other ) const if( PREFSMAN->m_bPercentageScoring ) { if( fPercentDP == other.fPercentDP ) - return grade >= other.grade; + return GetGrade() >= other.GetGrade(); else return fPercentDP >= other.fPercentDP; } else { - if( iScore == other.iScore ) - return grade >= other.grade; + if( GetScore() == other.GetScore() ) + return GetGrade() >= other.GetGrade(); else - return iScore >= other.iScore; + return GetScore() >= other.GetScore(); } } @@ -105,8 +123,6 @@ bool HighScore::operator==( const HighScore& other ) const if( *m_Impl != *other.m_Impl ) return false; #define COMPARE(x) if( x!=other.x ) return false; - COMPARE( grade ); - COMPARE( iScore ); COMPARE( fPercentDP ); COMPARE( fSurviveSeconds ); COMPARE( sModifiers ); @@ -131,8 +147,6 @@ XNode* HighScore::CreateNode() const // TRICKY: Don't write "name to fill in" markers. m_Impl->AppendChildren( pNode ); - pNode->AppendChild( "Grade", GradeToString(grade) ); - pNode->AppendChild( "Score", iScore ); pNode->AppendChild( "PercentDP", fPercentDP ); pNode->AppendChild( "SurviveSeconds", fSurviveSeconds ); pNode->AppendChild( "Modifiers", sModifiers ); @@ -157,16 +171,7 @@ void HighScore::LoadFromNode( const XNode* pNode ) { ASSERT( pNode->m_sName == "HighScore" ); - CString s; - m_Impl->LoadFromNode( pNode ); - 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 ); @@ -186,9 +191,6 @@ void HighScore::LoadFromNode( const XNode* pNode ) if( pRadarValues ) radarValues.LoadFromNode( pRadarValues ); pNode->GetChildValue( "LifeRemainingSeconds", fLifeRemainingSeconds ); - - /* Validate input. */ - grade = clamp( grade, GRADE_TIER01, GRADE_FAILED ); } CString HighScore::GetDisplayName() const @@ -289,7 +291,7 @@ void HighScoreList::LoadFromNode( const XNode* pHighScoreList ) vHighScores.back().LoadFromNode( p ); // ignore all high scores that are 0 - if( vHighScores.back().iScore == 0 ) + if( vHighScores.back().GetScore() == 0 ) vHighScores.pop_back(); } } diff --git a/stepmania/src/HighScore.h b/stepmania/src/HighScore.h index a3446e219e..781eab1bb7 100644 --- a/stepmania/src/HighScore.h +++ b/stepmania/src/HighScore.h @@ -19,8 +19,10 @@ struct HighScore CString *GetNameMutable(); const CString *GetNameMutable() const { return const_cast (const_cast(this)->GetNameMutable()); } - Grade grade; - int iScore; + Grade GetGrade() const; + void SetGrade( Grade g ); + int GetScore() const; + void SetScore( int iScore ); float fPercentDP; float fSurviveSeconds; CString sModifiers; diff --git a/stepmania/src/ScreenEvaluation.cpp b/stepmania/src/ScreenEvaluation.cpp index 04dee8ec2f..f3c054b814 100644 --- a/stepmania/src/ScreenEvaluation.cpp +++ b/stepmania/src/ScreenEvaluation.cpp @@ -898,7 +898,7 @@ void ScreenEvaluation::CommitScores( HighScore &hs = m_HighScore[p]; hs.SetName( RANKING_TO_FILL_IN_MARKER[p] ); hs.SetGrade( stageStats.m_player[p].GetGrade() ); - hs.iScore = stageStats.m_player[p].iScore; + hs.SetScore( stageStats.m_player[p].iScore ); hs.fPercentDP = stageStats.m_player[p].GetPercentDancePoints(); hs.fSurviveSeconds = stageStats.m_player[p].fAliveSeconds; hs.sModifiers = GAMESTATE->m_pPlayerState[p]->m_PlayerOptions.GetString(); diff --git a/stepmania/src/ScreenNameEntryTraditional.cpp b/stepmania/src/ScreenNameEntryTraditional.cpp index c4f49188e1..93d89c2b3c 100644 --- a/stepmania/src/ScreenNameEntryTraditional.cpp +++ b/stepmania/src/ScreenNameEntryTraditional.cpp @@ -63,7 +63,7 @@ void HighScoreWheelItem::Load( int iRankIndex, const HighScore& hs ) if( PREFSMAN->m_bPercentageScoring ) m_textScore.SetText( PercentageDisplay::FormatPercentScore(hs.fPercentDP) ); else - m_textScore.SetText( ssprintf("%i", hs.iScore) ); + m_textScore.SetText( ssprintf("%i", hs.GetScore()) ); m_textScore.SetShadowLength( 2 ); this->AddChild( &m_textScore ); SET_XY_AND_ON_COMMAND( m_textScore ); @@ -171,7 +171,7 @@ ScreenNameEntryTraditional::ScreenNameEntryTraditional( CString sClassName ) : S HighScore hs; hs.SetGrade( GRADE_TIER03 ); hs.fPercentDP = ss.m_player[p].GetPercentDancePoints(); - hs.iScore = ss.m_player[p].iScore; + hs.SetScore( ss.m_player[p].iScore ); hs.dateTime = DateTime::GetNowDateTime(); int a, b; PROFILEMAN->AddStepsScore( ss.vpPlayedSongs[0], pSteps, p, hs, a, b ); @@ -361,7 +361,7 @@ void ScreenNameEntryTraditional::Init() const HighScore &hs = hsl.vHighScores[h]; if( hs.GetName() == RANKING_TO_FILL_IN_MARKER[p] && hs.fPercentDP == fPercentDP && - hs.iScore == iScore ) + hs.GetScore() == iScore ) { iHighScoreIndex = h; break; diff --git a/stepmania/src/ScreenRanking.cpp b/stepmania/src/ScreenRanking.cpp index 7a0e6f51af..53e9eee2e2 100644 --- a/stepmania/src/ScreenRanking.cpp +++ b/stepmania/src/ScreenRanking.cpp @@ -769,7 +769,7 @@ float ScreenRanking::SetPage( PageToShow pts ) } m_textNames[l].SetText( hs.GetDisplayName() ); - m_textScores[l].SetText( ssprintf("%09i",hs.iScore) ); + m_textScores[l].SetText( ssprintf("%09i",hs.GetScore()) ); m_textNames[l].SetDiffuse( STEPS_TYPE_COLOR.GetValue(pts.colorIndex) ); m_textScores[l].SetDiffuse( STEPS_TYPE_COLOR.GetValue(pts.colorIndex) ); @@ -811,13 +811,13 @@ float ScreenRanking::SetPage( PageToShow pts ) m_textNames[l].SetText( hs.GetDisplayName() ); if( pts.pCourse->IsOni() ) { - m_textPoints[l].SetText( ssprintf("%04d",hs.iScore) ); + m_textPoints[l].SetText( ssprintf("%04d",hs.GetScore()) ); m_textTime[l].SetText( SecondsToMMSSMsMs(hs.fSurviveSeconds) ); m_textScores[l].SetText( "" ); } else { m_textPoints[l].SetText( "" ); m_textTime[l].SetText( "" ); - m_textScores[l].SetText( ssprintf("%09d",hs.iScore) ); + m_textScores[l].SetText( ssprintf("%09d",hs.GetScore()) ); } m_textNames[l].SetDiffuse( STEPS_TYPE_COLOR.GetValue(pts.colorIndex) ); m_textPoints[l].SetDiffuse( STEPS_TYPE_COLOR.GetValue(pts.colorIndex) ); diff --git a/stepmania/src/ScreenSelectMusic.cpp b/stepmania/src/ScreenSelectMusic.cpp index e0f8859a74..a5ff7fa568 100644 --- a/stepmania/src/ScreenSelectMusic.cpp +++ b/stepmania/src/ScreenSelectMusic.cpp @@ -1301,7 +1301,7 @@ void ScreenSelectMusic::AfterStepsChange( const vector &vpns ) if( pSteps ) { Profile* pProfile = PROFILEMAN->IsPersistentProfile(pn) ? PROFILEMAN->GetProfile(pn) : PROFILEMAN->GetMachineProfile(); - iScore = pProfile->GetStepsHighScoreList(pSong,pSteps).GetTopScore().iScore; + iScore = pProfile->GetStepsHighScoreList(pSong,pSteps).GetTopScore().GetScore(); } m_textHighScore[pn].SetText( ssprintf("%*i", NUM_SCORE_DIGITS, iScore) ); @@ -1346,7 +1346,7 @@ void ScreenSelectMusic::AfterTrailChange( const vector &vpns ) if( pTrail ) { Profile* pProfile = PROFILEMAN->IsPersistentProfile(pn) ? PROFILEMAN->GetProfile(pn) : PROFILEMAN->GetMachineProfile(); - iScore = pProfile->GetCourseHighScoreList(pCourse,pTrail).GetTopScore().iScore; + iScore = pProfile->GetCourseHighScoreList(pCourse,pTrail).GetTopScore().GetScore(); } m_textHighScore[pn].SetText( ssprintf("%*i", NUM_SCORE_DIGITS, iScore) );