From 4c5b32db02d45ecf0da207cbe43dbe1c967a040d Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 12 Oct 2003 21:51:02 +0000 Subject: [PATCH] floating-point scores --- stepmania/src/ScreenEvaluation.cpp | 9 ++++++++- stepmania/src/ScreenSelectMusic.cpp | 8 ++++---- stepmania/src/SongManager.cpp | 14 +++++++------- stepmania/src/Steps.cpp | 18 +++++++++--------- stepmania/src/Steps.h | 6 +++--- 5 files changed, 31 insertions(+), 24 deletions(-) diff --git a/stepmania/src/ScreenEvaluation.cpp b/stepmania/src/ScreenEvaluation.cpp index 9a339b8ae6..bcb2aa1756 100644 --- a/stepmania/src/ScreenEvaluation.cpp +++ b/stepmania/src/ScreenEvaluation.cpp @@ -178,7 +178,14 @@ ScreenEvaluation::ScreenEvaluation( CString sClassName ) : Screen(sClassName) if( GAMESTATE->IsHumanPlayer(p) && GAMESTATE->m_SongOptions.m_bSaveScore ) { if( GAMESTATE->m_pCurNotes[p] ) - GAMESTATE->m_pCurNotes[p]->AddScore( (PlayerNumber)p, grade[p], stageStats.iScore[p] + stageStats.iBonus[p], bNewRecord[p] ); + { + float score; + if( PREFSMAN->m_bPercentageScoring ) + score = stageStats.GetPercentDancePoints( (PlayerNumber)p ); + else + score = float(stageStats.iScore[p] + stageStats.iBonus[p]); + GAMESTATE->m_pCurNotes[p]->AddScore( (PlayerNumber)p, grade[p], score, bNewRecord[p] ); + } // update unlock data if unlocks are on if ( PREFSMAN->m_bUseUnlockSystem ) diff --git a/stepmania/src/ScreenSelectMusic.cpp b/stepmania/src/ScreenSelectMusic.cpp index 111fd2be3c..5aae43764e 100644 --- a/stepmania/src/ScreenSelectMusic.cpp +++ b/stepmania/src/ScreenSelectMusic.cpp @@ -900,12 +900,12 @@ void ScreenSelectMusic::AfterNotesChange( PlayerNumber pn ) if( pNotes ) { - int iScore; + float fScore; if( PROFILEMAN->IsUsingProfile(pn) ) - iScore = pNotes->m_MemCardScores[pn].iScore; + fScore = pNotes->m_MemCardScores[pn].fScore; else - iScore = pNotes->m_MemCardScores[MEMORY_CARD_MACHINE].iScore; - m_textHighScore[pn].SetText( ssprintf("%*i", NUM_SCORE_DIGITS, iScore) ); + fScore = pNotes->m_MemCardScores[MEMORY_CARD_MACHINE].fScore; + m_textHighScore[pn].SetText( ssprintf("%*i", NUM_SCORE_DIGITS, (int) fScore) ); } else { diff --git a/stepmania/src/SongManager.cpp b/stepmania/src/SongManager.cpp index eed7b46967..cc53a7b4fb 100644 --- a/stepmania/src/SongManager.cpp +++ b/stepmania/src/SongManager.cpp @@ -358,14 +358,14 @@ void SongManager::ReadNoteScoresFromFile( CString fn, int c ) int iNumTimesPlayed; Grade grade; - int iScore; - if( sscanf(line.c_str(), "%d %d %i\n", &iNumTimesPlayed, (int *)&grade, &iScore) != 3 ) + float fScore; + if( sscanf(line.c_str(), "%d %d %f\n", &iNumTimesPlayed, (int *)&grade, &fScore) != 3 ) break; if( pNotes ) { pNotes->m_MemCardScores[c].iNumTimesPlayed = iNumTimesPlayed; pNotes->m_MemCardScores[c].grade = grade; - pNotes->m_MemCardScores[c].iScore = iScore; + pNotes->m_MemCardScores[c].fScore = fScore; } } } @@ -550,10 +550,10 @@ void SongManager::ReadSM300NoteScores() iRetVal = sscanf( value, - "%d::%[^:]::%d::%d", + "%d::%[^:]::%f::%d", &pNotes->m_MemCardScores[MEMORY_CARD_MACHINE].iNumTimesPlayed, szGradeLetters, - &pNotes->m_MemCardScores[MEMORY_CARD_MACHINE].iScore, + &pNotes->m_MemCardScores[MEMORY_CARD_MACHINE].fScore, &iMaxCombo ); if( iRetVal != 4 ) @@ -661,10 +661,10 @@ void SongManager::SaveNoteScoresToFile( CString fn, int c ) pNotes->GetDifficulty(), pNotes->GetDescription().c_str() ); - fprintf(fp, "%d %d %i\n", + fprintf(fp, "%d %d %f\n", pNotes->m_MemCardScores[c].iNumTimesPlayed, pNotes->m_MemCardScores[c].grade, - pNotes->m_MemCardScores[c].iScore); + pNotes->m_MemCardScores[c].fScore); } } diff --git a/stepmania/src/Steps.cpp b/stepmania/src/Steps.cpp index 67f11f21f2..19ddd5aaff 100644 --- a/stepmania/src/Steps.cpp +++ b/stepmania/src/Steps.cpp @@ -46,7 +46,7 @@ Steps::Steps() { m_MemCardScores[m].iNumTimesPlayed = 0; m_MemCardScores[m].grade = GRADE_NO_DATA; - m_MemCardScores[m].iScore = 0; + m_MemCardScores[m].fScore = 0; } } @@ -298,32 +298,32 @@ void Steps::SetRadarValue(int r, float val) * XXX: Isn't it possible to beat the grade but not beat the score, since * grading and scores are on completely different systems? Should we be * checking for these completely separately? */ -bool Steps::MemCardScore::HigherScore( int vsScore, Grade vsGrade ) const +bool Steps::MemCardScore::HigherScore( float vsScore, Grade vsGrade ) const { - if( vsScore > this->iScore ) + if( vsScore > this->fScore ) return true; - if( vsScore < this->iScore ) + if( vsScore < this->fScore ) return false; return vsGrade > this->grade; } -void Steps::AddScore( PlayerNumber pn, Grade grade, int iScore, bool& bNewRecordOut ) +void Steps::AddScore( PlayerNumber pn, Grade grade, float fScore, bool& bNewRecordOut ) { bNewRecordOut = false; m_MemCardScores[MEMORY_CARD_MACHINE].iNumTimesPlayed++; m_MemCardScores[pn].iNumTimesPlayed++; - if( m_MemCardScores[pn].HigherScore(iScore, grade) && iScore > 0) + if( m_MemCardScores[pn].HigherScore(fScore, grade) && fScore > 0) { - m_MemCardScores[pn].iScore = iScore; + m_MemCardScores[pn].fScore = fScore; m_MemCardScores[pn].grade = grade; bNewRecordOut = true; } - if( m_MemCardScores[MEMORY_CARD_MACHINE].HigherScore(iScore, grade) ) + if( m_MemCardScores[MEMORY_CARD_MACHINE].HigherScore(fScore, grade) ) { - m_MemCardScores[MEMORY_CARD_MACHINE].iScore = iScore; + m_MemCardScores[MEMORY_CARD_MACHINE].fScore = fScore; m_MemCardScores[MEMORY_CARD_MACHINE].grade = grade; } } diff --git a/stepmania/src/Steps.h b/stepmania/src/Steps.h index 3ed6572e2e..bcb322a3e8 100644 --- a/stepmania/src/Steps.h +++ b/stepmania/src/Steps.h @@ -58,11 +58,11 @@ public: { int iNumTimesPlayed; Grade grade; - int iScore; - bool HigherScore( int iScore, Grade grade ) const; + float fScore; + bool HigherScore( float fScore, Grade grade ) const; } m_MemCardScores[NUM_MEMORY_CARDS]; - void AddScore( PlayerNumber pn, Grade grade, int iScore, bool& bNewRecordOut ); + void AddScore( PlayerNumber pn, Grade grade, float fScore, bool& bNewRecordOut ); void TidyUpData();