From f345edb3665f1015d9847132b990335055fd1917 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 18 Jun 2003 20:08:39 +0000 Subject: [PATCH] store scores as ints nonstop scoring fixes --- stepmania/src/Notes.cpp | 2 +- stepmania/src/Notes.h | 2 +- stepmania/src/Player.cpp | 4 ++-- stepmania/src/ScoreDisplay.h | 2 +- stepmania/src/ScoreDisplayNormal.cpp | 34 ++++++++++++++-------------- stepmania/src/ScoreDisplayNormal.h | 8 +++---- stepmania/src/ScoreKeeperMAX2.cpp | 14 ++++++------ stepmania/src/ScreenEvaluation.cpp | 6 ++--- stepmania/src/ScreenRanking.cpp | 4 ++-- stepmania/src/ScreenSelectMusic.cpp | 2 +- stepmania/src/SongManager.cpp | 30 ++++++++++++------------ stepmania/src/SongManager.h | 4 ++-- stepmania/src/StageStats.cpp | 2 +- stepmania/src/StageStats.h | 2 +- 14 files changed, 57 insertions(+), 59 deletions(-) diff --git a/stepmania/src/Notes.cpp b/stepmania/src/Notes.cpp index 9aa66a7317..57737e498c 100644 --- a/stepmania/src/Notes.cpp +++ b/stepmania/src/Notes.cpp @@ -274,7 +274,7 @@ void Notes::SetRadarValue(int r, float val) m_fRadarValues[r] = val; } -void Notes::AddScore( PlayerNumber pn, Grade grade, float iScore, bool& bNewRecordOut ) +void Notes::AddScore( PlayerNumber pn, Grade grade, int iScore, bool& bNewRecordOut ) { bNewRecordOut = false; diff --git a/stepmania/src/Notes.h b/stepmania/src/Notes.h index 9a98193bbd..d629ffdddf 100644 --- a/stepmania/src/Notes.h +++ b/stepmania/src/Notes.h @@ -60,7 +60,7 @@ public: int iScore; } m_MemCardScores[NUM_MEMORY_CARDS]; - void AddScore( PlayerNumber pn, Grade grade, float iScore, bool& bNewRecordOut ); + void AddScore( PlayerNumber pn, Grade grade, int iScore, bool& bNewRecordOut ); void TidyUpData(); diff --git a/stepmania/src/Player.cpp b/stepmania/src/Player.cpp index a6ed614b8e..7cce41bb3d 100644 --- a/stepmania/src/Player.cpp +++ b/stepmania/src/Player.cpp @@ -663,7 +663,7 @@ void Player::HandleTapRowScore( unsigned row ) m_pScoreKeeper->HandleTapRowScore(scoreOfLastTap, iNumTapsInRow, m_pInventory); if (m_pScore) - m_pScore->SetScore(GAMESTATE->m_CurStageStats.fScore[m_PlayerNumber]); + m_pScore->SetScore(GAMESTATE->m_CurStageStats.iScore[m_PlayerNumber]); if( m_pLifeMeter ) { m_pLifeMeter->ChangeLife( scoreOfLastTap ); @@ -689,7 +689,7 @@ void Player::HandleHoldScore( HoldNoteScore holdScore, TapNoteScore tapScore ) m_pScoreKeeper->HandleHoldScore(holdScore, tapScore); if (m_pScore) - m_pScore->SetScore(GAMESTATE->m_CurStageStats.fScore[m_PlayerNumber]); + m_pScore->SetScore(GAMESTATE->m_CurStageStats.iScore[m_PlayerNumber]); if( m_pLifeMeter ) { m_pLifeMeter->ChangeLife( holdScore, tapScore ); diff --git a/stepmania/src/ScoreDisplay.h b/stepmania/src/ScoreDisplay.h index 20dd459ce6..3e287266e7 100644 --- a/stepmania/src/ScoreDisplay.h +++ b/stepmania/src/ScoreDisplay.h @@ -19,7 +19,7 @@ class ScoreDisplay : public ActorFrame public: virtual void Init( PlayerNumber pn ) { m_PlayerNumber = pn; }; - virtual void SetScore( float fNewScore ) {}; + virtual void SetScore( int iNewScore ) {}; protected: PlayerNumber m_PlayerNumber; // needed to look up statistics in GAMESTATE diff --git a/stepmania/src/ScoreDisplayNormal.cpp b/stepmania/src/ScoreDisplayNormal.cpp index dcd5ba5fe6..c83857732f 100644 --- a/stepmania/src/ScoreDisplayNormal.cpp +++ b/stepmania/src/ScoreDisplayNormal.cpp @@ -14,7 +14,6 @@ #include "RageUtil.h" #include "RageLog.h" #include "PrefsManager.h" -#include "RageLog.h" #include "GameState.h" #include "ThemeManager.h" @@ -34,9 +33,9 @@ ScoreDisplayNormal::ScoreDisplayNormal() m_text.LoadFromNumbers( THEME->GetPathToN("ScoreDisplayNormal") ); m_text.EnableShadow( false ); - m_fScore = 0; - m_fTrailingScore = 0; - m_fScoreVelocity = 0; + m_iScore = 0; + m_iTrailingScore = 0; + m_iScoreVelocity = 0; CString s; for( int i=0; i 0) || + (iDeltaBefore > 0 && iDeltaAfter < 0) ) // the sign changed { - m_fTrailingScore = (float)m_fScore; - m_fScoreVelocity = 0; + m_iTrailingScore = m_iScore; + m_iScoreVelocity = 0; } - m_text.SetText( ssprintf("%*.0f", NUM_SCORE_DIGITS, m_fTrailingScore) ); + m_text.SetText( ssprintf("%*.0i", NUM_SCORE_DIGITS, m_iTrailingScore) ); } } diff --git a/stepmania/src/ScoreDisplayNormal.h b/stepmania/src/ScoreDisplayNormal.h index 77e188b7fc..5ae823cdde 100644 --- a/stepmania/src/ScoreDisplayNormal.h +++ b/stepmania/src/ScoreDisplayNormal.h @@ -25,16 +25,16 @@ public: virtual void Update( float fDeltaTime ); - virtual void SetScore( float fNewScore ); + virtual void SetScore( int iNewScore ); virtual void SetText( CString s ); protected: Sprite m_sprFrame; BitmapText m_text; - float m_fScore; // the actual score - float m_fTrailingScore; // what is displayed temporarily - float m_fScoreVelocity; // how fast trailing approaches real score + int m_iScore; // the actual score + int m_iTrailingScore; // what is displayed temporarily + int m_iScoreVelocity; // how fast trailing approaches real score }; #endif diff --git a/stepmania/src/ScoreKeeperMAX2.cpp b/stepmania/src/ScoreKeeperMAX2.cpp index dd7512e587..edd144eac9 100644 --- a/stepmania/src/ScoreKeeperMAX2.cpp +++ b/stepmania/src/ScoreKeeperMAX2.cpp @@ -95,26 +95,26 @@ void ScoreKeeperMAX2::OnNextSong( int iSongInCourseIndex, Notes* pNotes ) int sum = (N * (N + 1)) / 2; int iMaxPossiblePoints = 0; + int courseMult = 0; if( GAMESTATE->IsCourseMode() ) { const int numSongsInCourse = apNotes.size(); - int courseMult = (numSongsInCourse * (numSongsInCourse + 1)) / 2; + courseMult = (numSongsInCourse * (numSongsInCourse + 1)) / 2; if ( iSongInCourseIndex == numSongsInCourse - 1 ) m_bIsLastSongInCourse = true; - iMaxPossiblePoints = (10000000 * (iSongInCourseIndex+1)) / courseMult; + iMaxPossiblePoints = (100000000 * (iSongInCourseIndex+1)) / courseMult; m_iMaxScoreSoFar += iMaxPossiblePoints; } else { int iMeter = pNotes->GetMeter(); CLAMP( iMeter, 1, 10 ); - iMaxPossiblePoints = iMeter * 1000000; + iMaxPossiblePoints = iMeter * 10000000; } - - m_iScoreMultiplier = iMaxPossiblePoints / sum; - m_iPointBonus = (iMaxPossiblePoints * 10) - (sum * 10 * m_iScoreMultiplier); + m_iScoreMultiplier = iMaxPossiblePoints / (10*sum); + m_iPointBonus = iMaxPossiblePoints - (sum * 10 * m_iScoreMultiplier); ASSERT( m_iScoreMultiplier >= 0 ); ASSERT( m_iPointBonus >= 0 ); @@ -182,7 +182,7 @@ void ScoreKeeperMAX2::AddScore( TapNoteScore score ) printf( "score: %i\n", m_iScore ); - GAMESTATE->m_CurStageStats.fScore[m_PlayerNumber] = float(m_iScore); + GAMESTATE->m_CurStageStats.iScore[m_PlayerNumber] = m_iScore; } void ScoreKeeperMAX2::HandleTapRowScore( TapNoteScore scoreOfLastTap, int iNumTapsInRow, Inventory* pInventory ) diff --git a/stepmania/src/ScreenEvaluation.cpp b/stepmania/src/ScreenEvaluation.cpp index 14d759ace7..b3f1445bea 100644 --- a/stepmania/src/ScreenEvaluation.cpp +++ b/stepmania/src/ScreenEvaluation.cpp @@ -200,7 +200,7 @@ ScreenEvaluation::ScreenEvaluation( CString sClassName, Type type ) : Screen(sCl { if( GAMESTATE->IsHumanPlayer(p) ) { - GAMESTATE->m_pCurNotes[p]->AddScore( (PlayerNumber)p, grade[p], stageStats.fScore[p], bNewRecord[p] ); + GAMESTATE->m_pCurNotes[p]->AddScore( (PlayerNumber)p, grade[p], stageStats.iScore[p], bNewRecord[p] ); } } } @@ -222,7 +222,7 @@ ScreenEvaluation::ScreenEvaluation( CString sClassName, Type type ) : Screen(sCl fTotalDP += stageStats.iActualDancePoints[p]; } - SONGMAN->AddScores( nt, bIsHumanPlayer, cat, stageStats.fScore, iRankingIndex ); + SONGMAN->AddScores( nt, bIsHumanPlayer, cat, stageStats.iScore, iRankingIndex ); COPY( GAMESTATE->m_RankingCategory, cat ); COPY( GAMESTATE->m_iRankingIndex, iRankingIndex ); @@ -591,7 +591,7 @@ ScreenEvaluation::ScreenEvaluation( CString sClassName, Type type ) : Screen(sCl m_textScore[p].SetDiffuse( PlayerToColor(p) ); m_textScore[p].SetName( ssprintf("ScoreNumberP%d",p+1) ); UtilSetXYAndOnCommand( m_textScore[p], "ScreenEvaluation" ); - m_textScore[p].SetText( ssprintf("%*.0f", NUM_SCORE_DIGITS, stageStats.fScore[p]) ); + m_textScore[p].SetText( ssprintf("%*.0i", NUM_SCORE_DIGITS, stageStats.iScore[p]) ); this->AddChild( &m_textScore[p] ); } } diff --git a/stepmania/src/ScreenRanking.cpp b/stepmania/src/ScreenRanking.cpp index ab532b61b2..fa11b07355 100644 --- a/stepmania/src/ScreenRanking.cpp +++ b/stepmania/src/ScreenRanking.cpp @@ -204,9 +204,9 @@ void ScreenRanking::SetPage( PageToShow pts ) { m_sprBullets[l].SetDiffuse( RageColor(1,1,1,1) ); CString sName = SONGMAN->m_MachineScores[pts.nt][pts.category][l].sName; - float fScore = SONGMAN->m_MachineScores[pts.nt][pts.category][l].fScore; + int iScore = SONGMAN->m_MachineScores[pts.nt][pts.category][l].iScore; m_textNames[l].SetText( sName ); - m_textScores[l].SetText( ssprintf("%09.0f",fScore) ); + m_textScores[l].SetText( ssprintf("%09i",iScore) ); m_textPoints[l].SetText( "" ); m_textTime[l].SetText( "" ); m_textNames[l].SetDiffuse( TEXT_COLOR(pts.colorIndex) ); diff --git a/stepmania/src/ScreenSelectMusic.cpp b/stepmania/src/ScreenSelectMusic.cpp index 2f2f449015..6616077c20 100644 --- a/stepmania/src/ScreenSelectMusic.cpp +++ b/stepmania/src/ScreenSelectMusic.cpp @@ -749,7 +749,7 @@ void ScreenSelectMusic::AfterNotesChange( PlayerNumber pn ) Notes* m_pNotes = GAMESTATE->m_pCurNotes[pn]; if( m_pNotes && SONGMAN->IsUsingMemoryCard(pn) ) - m_textHighScore[pn].SetText( ssprintf("%*.0f", NUM_SCORE_DIGITS, m_pNotes->m_MemCardScores[pn].fScore) ); + m_textHighScore[pn].SetText( ssprintf("%*i", NUM_SCORE_DIGITS, m_pNotes->m_MemCardScores[pn].iScore) ); m_DifficultyIcon[pn].SetFromNotes( pn, pNotes ); if( pNotes && pNotes->IsAutogen() ) diff --git a/stepmania/src/SongManager.cpp b/stepmania/src/SongManager.cpp index c60034ad53..9fa356f948 100644 --- a/stepmania/src/SongManager.cpp +++ b/stepmania/src/SongManager.cpp @@ -247,7 +247,7 @@ void SongManager::InitMachineScoresFromDisk() for( int j=0; jm_MemCardScores[c].iNumTimesPlayed = iNumTimesPlayed; pNotes->m_MemCardScores[c].grade = grade; - pNotes->m_MemCardScores[c].fScore = fScore; + pNotes->m_MemCardScores[c].iScore = iScore; } } } @@ -434,7 +434,7 @@ void SongManager::SaveMachineScoresToDisk() for( int j=0; jGetDifficulty(), pNotes->GetDescription().c_str() ); - fprintf(fp, "%d %d %f\n", + fprintf(fp, "%d %d %i\n", pNotes->m_MemCardScores[c].iNumTimesPlayed, pNotes->m_MemCardScores[c].grade, - pNotes->m_MemCardScores[c].fScore); + pNotes->m_MemCardScores[c].iScore); } } @@ -998,13 +998,11 @@ struct CategoryScoreToInsert { PlayerNumber pn; RankingCategory cat; - float fScore; + int iScore; static int CompareDescending( const CategoryScoreToInsert &hs1, const CategoryScoreToInsert &hs2 ) { - if( hs1.fScore > hs2.fScore ) return -1; - else if( hs1.fScore == hs2.fScore ) return 0; - else return +1; + return hs1.iScore > hs2.iScore; } static void SortDescending( vector& vHSout ) { @@ -1015,7 +1013,7 @@ struct CategoryScoreToInsert // set iNewRecordIndex = -1 if not a new record void SongManager::AddScores( NotesType nt, bool bPlayerEnabled[NUM_PLAYERS], RankingCategory hsc[NUM_PLAYERS], - float fScore[NUM_PLAYERS], + int iScore[NUM_PLAYERS], int iNewRecordIndexOut[NUM_PLAYERS] ) { vector vHS; @@ -1029,7 +1027,7 @@ void SongManager::AddScores( NotesType nt, bool bPlayerEnabled[NUM_PLAYERS], CategoryScoreToInsert hs; hs.pn = (PlayerNumber)p; hs.cat = hsc[p]; - hs.fScore = fScore[p]; + hs.iScore = iScore[p]; vHS.push_back( hs ); } @@ -1043,13 +1041,13 @@ void SongManager::AddScores( NotesType nt, bool bPlayerEnabled[NUM_PLAYERS], MachineScore* machineScores = m_MachineScores[nt][newHS.cat]; for( int i=0; i machineScores[i].fScore ) + if( newHS.iScore > machineScores[i].iScore ) { // We found the insert point. Shift down. for( int j=NUM_RANKING_LINES-1; j>i; j-- ) machineScores[j] = machineScores[j-1]; // insert - machineScores[i].fScore = newHS.fScore; + machineScores[i].iScore = newHS.iScore; machineScores[i].sName = DEFAULT_RANKING_NAME; iNewRecordIndexOut[newHS.pn] = i; break; diff --git a/stepmania/src/SongManager.h b/stepmania/src/SongManager.h index fb773f588f..a0045195b6 100644 --- a/stepmania/src/SongManager.h +++ b/stepmania/src/SongManager.h @@ -92,10 +92,10 @@ public: struct MachineScore { - float fScore; + int iScore; CString sName; } m_MachineScores[NUM_NOTES_TYPES][NUM_RANKING_CATEGORIES][NUM_RANKING_LINES]; - void AddScores( NotesType nt, bool bPlayerEnabled[NUM_PLAYERS], RankingCategory hsc[NUM_PLAYERS], float fScore[NUM_PLAYERS], int iNewRecordIndexOut[NUM_PLAYERS] ); // set iNewRecordIndex = -1 if not a new record + void AddScores( NotesType nt, bool bPlayerEnabled[NUM_PLAYERS], RankingCategory hsc[NUM_PLAYERS], int iScore[NUM_PLAYERS], int iNewRecordIndexOut[NUM_PLAYERS] ); // set iNewRecordIndex = -1 if not a new record protected: void LoadStepManiaSongDir( CString sDir, LoadingWindow *ld ); diff --git a/stepmania/src/StageStats.cpp b/stepmania/src/StageStats.cpp index 51717839f4..98c5754203 100644 --- a/stepmania/src/StageStats.cpp +++ b/stepmania/src/StageStats.cpp @@ -39,7 +39,7 @@ void StageStats::operator+=( const StageStats& other ) iHoldNoteScores[p][h] += other.iHoldNoteScores[p][h]; iCurCombo[p] += other.iCurCombo[p]; iMaxCombo[p] += other.iMaxCombo[p]; - fScore[p] += other.fScore[p]; + iScore[p] += other.iScore[p]; for( int r=0; r