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.
This commit is contained in:
Glenn Maynard
2003-06-30 08:06:47 +00:00
parent 2a0972b8ba
commit 242d99a5df
5 changed files with 62 additions and 34 deletions
+24 -15
View File
@@ -35,13 +35,18 @@ Course::Course()
m_bDifficult = false; m_bDifficult = false;
m_iLives = -1; m_iLives = -1;
SetDefaultScore();
}
void Course::SetDefaultScore()
{
// //
// Init high scores // Init high scores
// //
for( unsigned i=0; i<NUM_NOTES_TYPES; i++ ) for( unsigned i=0; i<NUM_NOTES_TYPES; i++ )
for( int j=0; j<NUM_RANKING_LINES; j++ ) for( int j=0; j<NUM_RANKING_LINES; j++ )
{ {
m_RankingScores[i][j].iDancePoints = 573; m_RankingScores[i][j].iScore = IsOni()? 573: 0;
m_RankingScores[i][j].fSurviveTime = 57.3f; m_RankingScores[i][j].fSurviveTime = 57.3f;
m_RankingScores[i][j].sName = DEFAULT_RANKING_NAME; m_RankingScores[i][j].sName = DEFAULT_RANKING_NAME;
} }
@@ -50,7 +55,7 @@ Course::Course()
for( unsigned i=0; i<NUM_NOTES_TYPES; i++ ) for( unsigned i=0; i<NUM_NOTES_TYPES; i++ )
{ {
m_MemCardScores[m][i].iNumTimesPlayed = 0; m_MemCardScores[m][i].iNumTimesPlayed = 0;
m_MemCardScores[m][i].iDancePoints = 0; m_MemCardScores[m][i].iScore = 0;
m_MemCardScores[m][i].fSurviveTime = 0; m_MemCardScores[m][i].fSurviveTime = 0;
} }
} }
@@ -254,6 +259,8 @@ void Course::LoadFromCRSFile( CString sPath )
CString ignore; CString ignore;
tsub.Subst(m_sName, ignore, ignore, tsub.Subst(m_sName, ignore, ignore,
ignore, ignore, ignore); ignore, ignore, ignore);
SetDefaultScore();
} }
@@ -333,6 +340,8 @@ void Course::AutogenEndlessFromGroup( CString sGroupName, vector<Song*> &apSongs
SONGMAN->GetSongs( vSongs, e.group_name ); SONGMAN->GetSongs( vSongs, e.group_name );
for( unsigned i = 0; i < vSongs.size(); ++i) for( unsigned i = 0; i < vSongs.size(); ++i)
m_entries.push_back( e ); m_entries.push_back( e );
SetDefaultScore();
} }
void Course::AutogenNonstopFromGroup( CString sGroupName, vector<Song*> &apSongsInGroup ) void Course::AutogenNonstopFromGroup( CString sGroupName, vector<Song*> &apSongsInGroup )
@@ -348,6 +357,8 @@ void Course::AutogenNonstopFromGroup( CString sGroupName, vector<Song*> &apSongs
m_entries.push_back( m_entries[0] ); m_entries.push_back( m_entries[0] );
while( m_entries.size() > 4 ) while( m_entries.size() > 4 )
m_entries.pop_back(); m_entries.pop_back();
SetDefaultScore();
} }
@@ -609,14 +620,12 @@ bool Course::GetTotalSeconds( float& fSecondsOut ) const
struct RankingToInsert struct RankingToInsert
{ {
PlayerNumber pn; PlayerNumber pn;
int iDancePoints; int iScore;
float fSurviveTime; 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; return hs1.iScore > hs2.iScore;
else if( hs1.iDancePoints == hs2.iDancePoints ) return 0;
else return +1;
} }
static void SortDescending( vector<RankingToInsert>& vHSout ) static void SortDescending( vector<RankingToInsert>& 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<RankingToInsert> vHS; vector<RankingToInsert> vHS;
for( int p=0; p<NUM_PLAYERS; p++ ) for( int p=0; p<NUM_PLAYERS; p++ )
@@ -640,23 +649,23 @@ void Course::AddScores( NotesType nt, bool bPlayerEnabled[NUM_PLAYERS], int iDan
m_MemCardScores[p][nt].iNumTimesPlayed++; m_MemCardScores[p][nt].iNumTimesPlayed++;
m_MemCardScores[MEMORY_CARD_MACHINE][nt].iNumTimesPlayed++; m_MemCardScores[MEMORY_CARD_MACHINE][nt].iNumTimesPlayed++;
if( iDancePoints[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]; m_MemCardScores[p][nt].fSurviveTime = fSurviveTime[p];
bNewRecordOut[p] = true; 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]; m_MemCardScores[MEMORY_CARD_MACHINE][nt].fSurviveTime = fSurviveTime[p];
} }
// Update Ranking // Update Ranking
RankingToInsert hs; RankingToInsert hs;
hs.iDancePoints = iDancePoints[p]; hs.iScore = iScore[p];
hs.fSurviveTime = fSurviveTime[p]; hs.fSurviveTime = fSurviveTime[p];
hs.pn = (PlayerNumber)p; hs.pn = (PlayerNumber)p;
vHS.push_back( hs ); vHS.push_back( hs );
@@ -672,14 +681,14 @@ void Course::AddScores( NotesType nt, bool bPlayerEnabled[NUM_PLAYERS], int iDan
RankingScore* rankingScores = m_RankingScores[nt]; RankingScore* rankingScores = m_RankingScores[nt];
for( int i=0; i<NUM_RANKING_LINES; i++ ) for( int i=0; i<NUM_RANKING_LINES; i++ )
{ {
if( newHS.iDancePoints > rankingScores[i].iDancePoints ) if( newHS.iScore > rankingScores[i].iScore )
{ {
// We found the insert point. Shift down. // We found the insert point. Shift down.
for( int j=NUM_RANKING_LINES-1; j>i; j-- ) for( int j=NUM_RANKING_LINES-1; j>i; j-- )
rankingScores[j] = rankingScores[j-1]; rankingScores[j] = rankingScores[j-1];
// insert // insert
rankingScores[i].fSurviveTime = newHS.fSurviveTime; rankingScores[i].fSurviveTime = newHS.fSurviveTime;
rankingScores[i].iDancePoints = newHS.iDancePoints; rankingScores[i].iScore = newHS.iScore;
rankingScores[i].sName = DEFAULT_RANKING_NAME; rankingScores[i].sName = DEFAULT_RANKING_NAME;
iRankingIndexOut[newHS.pn] = i; iRankingIndexOut[newHS.pn] = i;
break; break;
+7 -2
View File
@@ -79,6 +79,9 @@ public:
bool ContainsAnyMysterySongs() const; bool ContainsAnyMysterySongs() const;
bool GetTotalSeconds( float& fSecondsOut ) 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 LoadFromCRSFile( CString sPath );
void Save(); void Save();
@@ -89,14 +92,15 @@ public:
// Statistics // Statistics
struct RankingScore struct RankingScore
{ {
int iDancePoints; /* Dance points for oni, regular score for nonstop. */
int iScore;
float fSurviveTime; float fSurviveTime;
CString sName; CString sName;
} m_RankingScores[NUM_NOTES_TYPES][NUM_RANKING_LINES]; // sorted highest to lowest by iDancePoints } m_RankingScores[NUM_NOTES_TYPES][NUM_RANKING_LINES]; // sorted highest to lowest by iDancePoints
struct MemCardScore struct MemCardScore
{ {
int iNumTimesPlayed; int iNumTimesPlayed;
int iDancePoints; int iScore;
float fSurviveTime; float fSurviveTime;
} m_MemCardScores[NUM_MEMORY_CARDS][NUM_NOTES_TYPES]; } m_MemCardScores[NUM_MEMORY_CARDS][NUM_NOTES_TYPES];
@@ -105,6 +109,7 @@ public:
private: private:
Song *FindSong(CString sGroup, CString sSong) const; Song *FindSong(CString sGroup, CString sSong) const;
void SetDefaultScore();
}; };
+7 -1
View File
@@ -246,7 +246,13 @@ ScreenEvaluation::ScreenEvaluation( CString sClassName, Type type ) : Screen(sCl
int iRankingIndex[NUM_PLAYERS]; int iRankingIndex[NUM_PLAYERS];
Course* pCourse = GAMESTATE->m_pCurCourse; 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 ); COPY( GAMESTATE->m_iRankingIndex, iRankingIndex );
GAMESTATE->m_pRankingCourse = pCourse; GAMESTATE->m_pRankingCourse = pCourse;
GAMESTATE->m_RankingNotesType = nt; GAMESTATE->m_RankingNotesType = nt;
+13 -5
View File
@@ -245,15 +245,23 @@ void ScreenRanking::SetPage( PageToShow pts )
{ {
m_sprBullets[l].SetDiffuse( RageColor(1,1,1,1) ); m_sprBullets[l].SetDiffuse( RageColor(1,1,1,1) );
CString sName = pts.pCourse->m_RankingScores[pts.nt][l].sName; CString sName = pts.pCourse->m_RankingScores[pts.nt][l].sName;
int iDancePoints = pts.pCourse->m_RankingScores[pts.nt][l].iDancePoints; const int iScore = pts.pCourse->m_RankingScores[pts.nt][l].iScore;
float fSurviveTime = pts.pCourse->m_RankingScores[pts.nt][l].fSurviveTime; const float fSurviveTime = pts.pCourse->m_RankingScores[pts.nt][l].fSurviveTime;
m_textNames[l].SetText( sName ); m_textNames[l].SetText( sName );
m_textScores[l].SetText( "" ); if( pts.pCourse->IsOni() )
m_textPoints[l].SetText( ssprintf("%04d",iDancePoints) ); {
m_textTime[l].SetText( SecondsToTime(fSurviveTime) ); 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_textNames[l].SetDiffuse( TEXT_COLOR(pts.colorIndex) );
m_textPoints[l].SetDiffuse( TEXT_COLOR(pts.colorIndex) ); m_textPoints[l].SetDiffuse( TEXT_COLOR(pts.colorIndex) );
m_textTime[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; p<NUM_PLAYERS; p++ ) for( int p=0; p<NUM_PLAYERS; p++ )
{ {
if( pts.pCourse == GAMESTATE->m_pRankingCourse && if( pts.pCourse == GAMESTATE->m_pRankingCourse &&
+11 -11
View File
@@ -324,13 +324,13 @@ void SongManager::ReadCourseScoresFromFile( CString fn, int c )
if( !feof(fp) ) if( !feof(fp) )
{ {
int iNumTimesPlayed; int iNumTimesPlayed;
int iDancePoints; int iScore;
float fSurviveTime; float fSurviveTime;
fscanf(fp, "%d %d %f\n", &iNumTimesPlayed, &iDancePoints, &fSurviveTime); fscanf(fp, "%d %d %f\n", &iNumTimesPlayed, &iScore, &fSurviveTime);
if( pCourse ) if( pCourse )
{ {
pCourse->m_MemCardScores[c][i].iNumTimesPlayed = iNumTimesPlayed; 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; pCourse->m_MemCardScores[c][i].fSurviveTime = fSurviveTime;
} }
} }
@@ -385,13 +385,13 @@ void SongManager::ReadCourseRankingsFromFile( CString fn )
for( int j=0; j<NUM_RANKING_LINES; j++ ) for( int j=0; j<NUM_RANKING_LINES; j++ )
if( !feof(fp) ) if( !feof(fp) )
{ {
int iDancePoints; int iScore;
float fSurviveTime; float fSurviveTime;
char szName[256]; char szName[256];
fscanf(fp, "%d %f %[^\n]\n", &iDancePoints, &fSurviveTime, szName); fscanf(fp, "%d %f %[^\n]\n", &iScore, &fSurviveTime, szName);
if( pCourse ) if( pCourse )
{ {
pCourse->m_RankingScores[i][j].iDancePoints = iDancePoints; pCourse->m_RankingScores[i][j].iScore = iScore;
pCourse->m_RankingScores[i][j].fSurviveTime = fSurviveTime; pCourse->m_RankingScores[i][j].fSurviveTime = fSurviveTime;
pCourse->m_RankingScores[i][j].sName = szName; pCourse->m_RankingScores[i][j].sName = szName;
} }
@@ -471,7 +471,7 @@ void SongManager::SaveMachineScoresToDisk()
for( int j=0; j<NUM_RANKING_LINES; j++ ) for( int j=0; j<NUM_RANKING_LINES; j++ )
{ {
fprintf(fp, "%d %f %s\n", fprintf(fp, "%d %f %s\n",
pCourse->m_RankingScores[i][j].iDancePoints, pCourse->m_RankingScores[i][j].iScore,
pCourse->m_RankingScores[i][j].fSurviveTime, pCourse->m_RankingScores[i][j].fSurviveTime,
pCourse->m_RankingScores[i][j].sName.c_str()); pCourse->m_RankingScores[i][j].sName.c_str());
} }
@@ -556,7 +556,7 @@ void SongManager::SaveMachineScoresToDisk()
for( int nt=0; nt<NUM_NOTES_TYPES; nt++ ) for( int nt=0; nt<NUM_NOTES_TYPES; nt++ )
fprintf(fp, "%d %d %f\n", fprintf(fp, "%d %d %f\n",
pCourse->m_MemCardScores[c][nt].iNumTimesPlayed, pCourse->m_MemCardScores[c][nt].iNumTimesPlayed,
pCourse->m_MemCardScores[c][nt].iDancePoints, pCourse->m_MemCardScores[c][nt].iScore,
pCourse->m_MemCardScores[c][nt].fSurviveTime); pCourse->m_MemCardScores[c][nt].fSurviveTime);
} }
@@ -808,7 +808,7 @@ void SongManager::CleanData()
void SongManager::GetNonstopCourses( vector<Course*> &AddTo, bool bIncludeAutogen ) void SongManager::GetNonstopCourses( vector<Course*> &AddTo, bool bIncludeAutogen )
{ {
for( unsigned i=0; i<m_pCourses.size(); i++ ) for( unsigned i=0; i<m_pCourses.size(); i++ )
if( !m_pCourses[i]->m_bRepeat && m_pCourses[i]->m_iLives <= 0 ) // use bar life meter if( m_pCourses[i]->IsNonstop() )
if( bIncludeAutogen || !m_pCourses[i]->m_bIsAutogen ) if( bIncludeAutogen || !m_pCourses[i]->m_bIsAutogen )
AddTo.push_back( m_pCourses[i] ); AddTo.push_back( m_pCourses[i] );
} }
@@ -816,7 +816,7 @@ void SongManager::GetNonstopCourses( vector<Course*> &AddTo, bool bIncludeAutoge
void SongManager::GetOniCourses( vector<Course*> &AddTo, bool bIncludeAutogen ) void SongManager::GetOniCourses( vector<Course*> &AddTo, bool bIncludeAutogen )
{ {
for( unsigned i=0; i<m_pCourses.size(); i++ ) for( unsigned i=0; i<m_pCourses.size(); i++ )
if( !m_pCourses[i]->m_bRepeat && m_pCourses[i]->m_iLives > 0 ) // use battery life meter if( m_pCourses[i]->IsOni() )
if( bIncludeAutogen || !m_pCourses[i]->m_bIsAutogen ) if( bIncludeAutogen || !m_pCourses[i]->m_bIsAutogen )
AddTo.push_back( m_pCourses[i] ); AddTo.push_back( m_pCourses[i] );
} }
@@ -824,7 +824,7 @@ void SongManager::GetOniCourses( vector<Course*> &AddTo, bool bIncludeAutogen )
void SongManager::GetEndlessCourses( vector<Course*> &AddTo, bool bIncludeAutogen ) void SongManager::GetEndlessCourses( vector<Course*> &AddTo, bool bIncludeAutogen )
{ {
for( unsigned i=0; i<m_pCourses.size(); i++ ) for( unsigned i=0; i<m_pCourses.size(); i++ )
if( m_pCourses[i]->m_bRepeat ) if( m_pCourses[i]->IsEndless() )
if( bIncludeAutogen || !m_pCourses[i]->m_bIsAutogen ) if( bIncludeAutogen || !m_pCourses[i]->m_bIsAutogen )
AddTo.push_back( m_pCourses[i] ); AddTo.push_back( m_pCourses[i] );
} }