add AllowMultipleHighScoreWithSameName

This commit is contained in:
Chris Danford
2005-04-25 09:03:24 +00:00
parent 1f76af4df2
commit 9a9f67eff0
7 changed files with 81 additions and 17 deletions
+31 -2
View File
@@ -129,8 +129,13 @@ void HighScoreList::AddHighScore( HighScore hs, int &iIndexOut, bool bIsMachine
{
vHighScores.insert( vHighScores.begin()+i, hs );
iIndexOut = i;
if( vHighScores.size() > unsigned(iMaxScores) )
vHighScores.erase( vHighScores.begin()+iMaxScores, vHighScores.end() );
// Delete extra machine high scores in RemoveAllButOneOfEachNameAndClampSize
// and not here so that we don't end up with less than iMaxScores after
// removing HighScores with duplicate names.
//
if( !bIsMachine )
ClampSize( bIsMachine );
}
}
@@ -187,6 +192,30 @@ void HighScoreList::LoadFromNode( const XNode* pHighScoreList )
}
}
void HighScoreList::RemoveAllButOneOfEachName()
{
FOREACH( HighScore, vHighScores, i )
{
for( vector<HighScore>::iterator j = i+1; j != vHighScores.end(); j++ )
{
if( i->sName == j->sName )
{
j--;
vHighScores.erase( j+1 );
}
}
}
}
void HighScoreList::ClampSize( bool bIsMachine )
{
const int iMaxScores = bIsMachine ?
PREFSMAN->m_iMaxHighScoresPerListForMachine :
PREFSMAN->m_iMaxHighScoresPerListForPlayer;
if( vHighScores.size() > unsigned(iMaxScores) )
vHighScores.erase( vHighScores.begin()+iMaxScores, vHighScores.end() );
}
XNode* Screenshot::CreateNode() const
{
XNode* pNode = new XNode;