From 242d99a5df3d9a4ae2a5857f68f90737d2961fb1 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Mon, 30 Jun 2003 08:06:47 +0000 Subject: [PATCH] Fix RankingToInsert::CompareDescending. Store regular scores in nonstop, not oni. We only ever display those scores in that mdoe. Add Course::IsNonstop, Course::IsOni, Course::IsEndless. --- stepmania/src/Course.cpp | 39 ++++++++++++++++++------------ stepmania/src/Course.h | 9 +++++-- stepmania/src/ScreenEvaluation.cpp | 8 +++++- stepmania/src/ScreenRanking.cpp | 18 ++++++++++---- stepmania/src/SongManager.cpp | 22 ++++++++--------- 5 files changed, 62 insertions(+), 34 deletions(-) diff --git a/stepmania/src/Course.cpp b/stepmania/src/Course.cpp index 428bd9883c..9f22cbd2c2 100644 --- a/stepmania/src/Course.cpp +++ b/stepmania/src/Course.cpp @@ -35,13 +35,18 @@ Course::Course() m_bDifficult = false; m_iLives = -1; + SetDefaultScore(); +} + +void Course::SetDefaultScore() +{ // // Init high scores // for( unsigned i=0; i &apSongs SONGMAN->GetSongs( vSongs, e.group_name ); for( unsigned i = 0; i < vSongs.size(); ++i) m_entries.push_back( e ); + + SetDefaultScore(); } void Course::AutogenNonstopFromGroup( CString sGroupName, vector &apSongsInGroup ) @@ -348,6 +357,8 @@ void Course::AutogenNonstopFromGroup( CString sGroupName, vector &apSongs m_entries.push_back( m_entries[0] ); while( m_entries.size() > 4 ) m_entries.pop_back(); + + SetDefaultScore(); } @@ -609,14 +620,12 @@ bool Course::GetTotalSeconds( float& fSecondsOut ) const struct RankingToInsert { PlayerNumber pn; - int iDancePoints; + int iScore; float fSurviveTime; - static int CompareDescending( const RankingToInsert &hs1, const RankingToInsert &hs2 ) + static bool CompareDescending( const RankingToInsert &hs1, const RankingToInsert &hs2 ) { - if( hs1.iDancePoints > hs2.iDancePoints ) return -1; - else if( hs1.iDancePoints == hs2.iDancePoints ) return 0; - else return +1; + return hs1.iScore > hs2.iScore; } static void SortDescending( vector& vHSout ) { @@ -624,7 +633,7 @@ struct RankingToInsert } }; -void Course::AddScores( NotesType nt, bool bPlayerEnabled[NUM_PLAYERS], int iDancePoints[NUM_PLAYERS], float fSurviveTime[NUM_PLAYERS], int iRankingIndexOut[NUM_PLAYERS], bool bNewRecordOut[NUM_PLAYERS] ) +void Course::AddScores( NotesType nt, bool bPlayerEnabled[NUM_PLAYERS], int iScore[NUM_PLAYERS], float fSurviveTime[NUM_PLAYERS], int iRankingIndexOut[NUM_PLAYERS], bool bNewRecordOut[NUM_PLAYERS] ) { vector vHS; for( int p=0; p m_MemCardScores[p][nt].iDancePoints ) + if( iScore[p] > m_MemCardScores[p][nt].iScore ) { - m_MemCardScores[p][nt].iDancePoints = iDancePoints[p]; + m_MemCardScores[p][nt].iScore = iScore[p]; m_MemCardScores[p][nt].fSurviveTime = fSurviveTime[p]; bNewRecordOut[p] = true; } - if( iDancePoints[p] > m_MemCardScores[MEMORY_CARD_MACHINE][nt].iDancePoints ) + if( iScore[p] > m_MemCardScores[MEMORY_CARD_MACHINE][nt].iScore ) { - m_MemCardScores[MEMORY_CARD_MACHINE][nt].iDancePoints = iDancePoints[p]; + m_MemCardScores[MEMORY_CARD_MACHINE][nt].iScore = iScore[p]; m_MemCardScores[MEMORY_CARD_MACHINE][nt].fSurviveTime = fSurviveTime[p]; } // Update Ranking RankingToInsert hs; - hs.iDancePoints = iDancePoints[p]; + hs.iScore = iScore[p]; hs.fSurviveTime = fSurviveTime[p]; hs.pn = (PlayerNumber)p; vHS.push_back( hs ); @@ -672,14 +681,14 @@ void Course::AddScores( NotesType nt, bool bPlayerEnabled[NUM_PLAYERS], int iDan RankingScore* rankingScores = m_RankingScores[nt]; for( int i=0; i rankingScores[i].iDancePoints ) + if( newHS.iScore > rankingScores[i].iScore ) { // We found the insert point. Shift down. for( int j=NUM_RANKING_LINES-1; j>i; j-- ) rankingScores[j] = rankingScores[j-1]; // insert rankingScores[i].fSurviveTime = newHS.fSurviveTime; - rankingScores[i].iDancePoints = newHS.iDancePoints; + rankingScores[i].iScore = newHS.iScore; rankingScores[i].sName = DEFAULT_RANKING_NAME; iRankingIndexOut[newHS.pn] = i; break; diff --git a/stepmania/src/Course.h b/stepmania/src/Course.h index d1e1a99671..819460b5f2 100644 --- a/stepmania/src/Course.h +++ b/stepmania/src/Course.h @@ -79,6 +79,9 @@ public: bool ContainsAnyMysterySongs() const; bool GetTotalSeconds( float& fSecondsOut ) const; + bool IsNonstop() const { return !m_bRepeat && m_iLives <= 0; } // use bar life meter + bool IsOni() const { return !m_bRepeat && m_iLives > 0; } // use battery life meter + bool IsEndless() const { return m_bRepeat; } void LoadFromCRSFile( CString sPath ); void Save(); @@ -89,14 +92,15 @@ public: // Statistics struct RankingScore { - int iDancePoints; + /* Dance points for oni, regular score for nonstop. */ + int iScore; float fSurviveTime; CString sName; } m_RankingScores[NUM_NOTES_TYPES][NUM_RANKING_LINES]; // sorted highest to lowest by iDancePoints struct MemCardScore { int iNumTimesPlayed; - int iDancePoints; + int iScore; float fSurviveTime; } m_MemCardScores[NUM_MEMORY_CARDS][NUM_NOTES_TYPES]; @@ -105,6 +109,7 @@ public: private: Song *FindSong(CString sGroup, CString sSong) const; + void SetDefaultScore(); }; diff --git a/stepmania/src/ScreenEvaluation.cpp b/stepmania/src/ScreenEvaluation.cpp index b3f1445bea..5cee1135f5 100644 --- a/stepmania/src/ScreenEvaluation.cpp +++ b/stepmania/src/ScreenEvaluation.cpp @@ -246,7 +246,13 @@ ScreenEvaluation::ScreenEvaluation( CString sClassName, Type type ) : Screen(sCl int iRankingIndex[NUM_PLAYERS]; Course* pCourse = GAMESTATE->m_pCurCourse; - pCourse->AddScores( nt, bIsHumanPlayer, stageStats.iActualDancePoints, stageStats.fAliveSeconds, iRankingIndex, bNewRecord ); + + int *score; + if( pCourse->IsOni() ) + score = stageStats.iActualDancePoints; + else + score = stageStats.iScore; + pCourse->AddScores( nt, bIsHumanPlayer, score, stageStats.fAliveSeconds, iRankingIndex, bNewRecord ); COPY( GAMESTATE->m_iRankingIndex, iRankingIndex ); GAMESTATE->m_pRankingCourse = pCourse; GAMESTATE->m_RankingNotesType = nt; diff --git a/stepmania/src/ScreenRanking.cpp b/stepmania/src/ScreenRanking.cpp index fa11b07355..28ffc13ad6 100644 --- a/stepmania/src/ScreenRanking.cpp +++ b/stepmania/src/ScreenRanking.cpp @@ -245,15 +245,23 @@ void ScreenRanking::SetPage( PageToShow pts ) { m_sprBullets[l].SetDiffuse( RageColor(1,1,1,1) ); CString sName = pts.pCourse->m_RankingScores[pts.nt][l].sName; - int iDancePoints = pts.pCourse->m_RankingScores[pts.nt][l].iDancePoints; - float fSurviveTime = pts.pCourse->m_RankingScores[pts.nt][l].fSurviveTime; + const int iScore = pts.pCourse->m_RankingScores[pts.nt][l].iScore; + const float fSurviveTime = pts.pCourse->m_RankingScores[pts.nt][l].fSurviveTime; m_textNames[l].SetText( sName ); - m_textScores[l].SetText( "" ); - m_textPoints[l].SetText( ssprintf("%04d",iDancePoints) ); - m_textTime[l].SetText( SecondsToTime(fSurviveTime) ); + if( pts.pCourse->IsOni() ) + { + m_textPoints[l].SetText( ssprintf("%04d",iScore) ); + m_textTime[l].SetText( SecondsToTime(fSurviveTime) ); + m_textScores[l].SetText( "" ); + } else { + m_textPoints[l].SetText( "" ); + m_textTime[l].SetText( "" ); + m_textScores[l].SetText( ssprintf("%10d",iScore) ); + } m_textNames[l].SetDiffuse( TEXT_COLOR(pts.colorIndex) ); m_textPoints[l].SetDiffuse( TEXT_COLOR(pts.colorIndex) ); m_textTime[l].SetDiffuse( TEXT_COLOR(pts.colorIndex) ); + m_textScores[l].SetDiffuse( TEXT_COLOR(pts.colorIndex) ); for( int p=0; pm_pRankingCourse && diff --git a/stepmania/src/SongManager.cpp b/stepmania/src/SongManager.cpp index 8f874933f9..04436048cb 100644 --- a/stepmania/src/SongManager.cpp +++ b/stepmania/src/SongManager.cpp @@ -324,13 +324,13 @@ void SongManager::ReadCourseScoresFromFile( CString fn, int c ) if( !feof(fp) ) { int iNumTimesPlayed; - int iDancePoints; + int iScore; float fSurviveTime; - fscanf(fp, "%d %d %f\n", &iNumTimesPlayed, &iDancePoints, &fSurviveTime); + fscanf(fp, "%d %d %f\n", &iNumTimesPlayed, &iScore, &fSurviveTime); if( pCourse ) { pCourse->m_MemCardScores[c][i].iNumTimesPlayed = iNumTimesPlayed; - pCourse->m_MemCardScores[c][i].iDancePoints = iDancePoints; + pCourse->m_MemCardScores[c][i].iScore = iScore; pCourse->m_MemCardScores[c][i].fSurviveTime = fSurviveTime; } } @@ -385,13 +385,13 @@ void SongManager::ReadCourseRankingsFromFile( CString fn ) for( int j=0; jm_RankingScores[i][j].iDancePoints = iDancePoints; + pCourse->m_RankingScores[i][j].iScore = iScore; pCourse->m_RankingScores[i][j].fSurviveTime = fSurviveTime; pCourse->m_RankingScores[i][j].sName = szName; } @@ -471,7 +471,7 @@ void SongManager::SaveMachineScoresToDisk() for( int j=0; jm_RankingScores[i][j].iDancePoints, + pCourse->m_RankingScores[i][j].iScore, pCourse->m_RankingScores[i][j].fSurviveTime, pCourse->m_RankingScores[i][j].sName.c_str()); } @@ -556,7 +556,7 @@ void SongManager::SaveMachineScoresToDisk() for( int nt=0; ntm_MemCardScores[c][nt].iNumTimesPlayed, - pCourse->m_MemCardScores[c][nt].iDancePoints, + pCourse->m_MemCardScores[c][nt].iScore, pCourse->m_MemCardScores[c][nt].fSurviveTime); } @@ -808,7 +808,7 @@ void SongManager::CleanData() void SongManager::GetNonstopCourses( vector &AddTo, bool bIncludeAutogen ) { for( unsigned i=0; im_bRepeat && m_pCourses[i]->m_iLives <= 0 ) // use bar life meter + if( m_pCourses[i]->IsNonstop() ) if( bIncludeAutogen || !m_pCourses[i]->m_bIsAutogen ) AddTo.push_back( m_pCourses[i] ); } @@ -816,7 +816,7 @@ void SongManager::GetNonstopCourses( vector &AddTo, bool bIncludeAutoge void SongManager::GetOniCourses( vector &AddTo, bool bIncludeAutogen ) { for( unsigned i=0; im_bRepeat && m_pCourses[i]->m_iLives > 0 ) // use battery life meter + if( m_pCourses[i]->IsOni() ) if( bIncludeAutogen || !m_pCourses[i]->m_bIsAutogen ) AddTo.push_back( m_pCourses[i] ); } @@ -824,7 +824,7 @@ void SongManager::GetOniCourses( vector &AddTo, bool bIncludeAutogen ) void SongManager::GetEndlessCourses( vector &AddTo, bool bIncludeAutogen ) { for( unsigned i=0; im_bRepeat ) + if( m_pCourses[i]->IsEndless() ) if( bIncludeAutogen || !m_pCourses[i]->m_bIsAutogen ) AddTo.push_back( m_pCourses[i] ); }