AddHighScore fixes

This commit is contained in:
Glenn Maynard
2003-10-15 01:03:14 +00:00
parent cf381fb553
commit d1d342dbd3
4 changed files with 38 additions and 30 deletions
+17
View File
@@ -383,6 +383,23 @@ void Course::AutogenNonstopFromGroup( CString sGroupName, vector<Song*> &apSongs
m_entries.pop_back(); m_entries.pop_back();
} }
void Course::MemCardData::AddHighScore( HighScore hs, int &iIndexOut )
{
int i;
for( i=0; i<(int)vHighScores.size(); i++ )
{
if( hs > vHighScores[i] )
break;
}
if( i < NUM_RANKING_LINES )
{
vHighScores.insert( vHighScores.begin()+i, hs );
iIndexOut = i;
if( vHighScores.size() > NUM_RANKING_LINES )
vHighScores.erase( vHighScores.begin()+NUM_RANKING_LINES, vHighScores.end() );
}
}
/* /*
* Difficult courses do the following: * Difficult courses do the following:
* *
+2 -15
View File
@@ -152,27 +152,14 @@ public:
fSurviveTime = 0; fSurviveTime = 0;
} }
bool operator>( const HighScore& other ) bool operator>( const HighScore& other ) const
{ {
return iScore > other.iScore; return iScore > other.iScore;
} }
}; };
vector<HighScore> vHighScores; vector<HighScore> vHighScores;
void AddHighScore( HighScore hs, int &iIndexOut ) void AddHighScore( HighScore hs, int &iIndexOut );
{
for( int i=0; i<(int)vHighScores.size() && i<NUM_RANKING_LINES; i++ )
{
if( hs > vHighScores[i] )
{
vHighScores.insert( vHighScores.begin()+i, hs );
iIndexOut = i;
break;
}
}
if( vHighScores.size() > NUM_RANKING_LINES )
vHighScores.erase( vHighScores.begin()+NUM_RANKING_LINES, vHighScores.end() );
}
HighScore GetTopScore() HighScore GetTopScore()
{ {
+17
View File
@@ -97,6 +97,23 @@ SongManager::~SongManager()
FreeSongs(); FreeSongs();
} }
void SongManager::CategoryData::AddHighScore( HighScore hs, int &iIndexOut )
{
int i;
for( i=0; i<(int)vHighScores.size(); i++ )
{
if( hs > vHighScores[i] )
break;
}
if( i < NUM_RANKING_LINES )
{
vHighScores.insert( vHighScores.begin()+i, hs );
iIndexOut = i;
if( vHighScores.size() > NUM_RANKING_LINES )
vHighScores.erase( vHighScores.begin()+NUM_RANKING_LINES, vHighScores.end() );
}
}
void SongManager::Reload() void SongManager::Reload()
{ {
+2 -15
View File
@@ -101,27 +101,14 @@ public:
iScore = 0; iScore = 0;
} }
bool operator>( const HighScore& other ) bool operator>( const HighScore& other ) const
{ {
return iScore > other.iScore; return iScore > other.iScore;
} }
}; };
vector<HighScore> vHighScores; vector<HighScore> vHighScores;
void AddHighScore( HighScore hs, int &iIndexOut ) void AddHighScore( HighScore hs, int &iIndexOut );
{
for( int i=0; i<(int)vHighScores.size() && i<NUM_RANKING_LINES; i++ )
{
if( hs > vHighScores[i] )
{
vHighScores.insert( vHighScores.begin()+i, hs );
iIndexOut = i;
break;
}
}
if( vHighScores.size() > NUM_RANKING_LINES )
vHighScores.erase( vHighScores.begin()+NUM_RANKING_LINES, vHighScores.end() );
}
} m_CategoryDatas[NUM_STEPS_TYPES][NUM_RANKING_CATEGORIES]; } m_CategoryDatas[NUM_STEPS_TYPES][NUM_RANKING_CATEGORIES];