per-memcard SONGMAN->GetBestSongs

This commit is contained in:
Glenn Maynard
2003-11-14 21:52:05 +00:00
parent f4f21b1b6e
commit 92dc51e328
4 changed files with 19 additions and 17 deletions
+10 -11
View File
@@ -1235,7 +1235,7 @@ Steps::MemCardData::HighScore Song::GetHighScoreForDifficulty( const StyleDef *s
bool Song::IsNew() const bool Song::IsNew() const
{ {
return GetNumTimesPlayed()==0; return GetNumTimesPlayed(MEMORY_CARD_MACHINE) == 0;
} }
bool Song::IsEasy( StepsType nt ) const bool Song::IsEasy( StepsType nt ) const
@@ -1456,9 +1456,9 @@ void SortSongPointerArrayByGroupAndTitle( vector<Song*> &arraySongPointers )
sort( arraySongPointers.begin(), arraySongPointers.end(), CompareSongPointersByGroupAndTitle ); sort( arraySongPointers.begin(), arraySongPointers.end(), CompareSongPointersByGroupAndTitle );
} }
bool CompareSongPointersByMostPlayed(const Song *pSong1, const Song *pSong2) //bool CompareSongPointersByMostPlayed(const Song *pSong1, const Song *pSong2)
{ //{
return pSong1->GetNumTimesPlayed() < pSong2->GetNumTimesPlayed(); // return pSong1->GetNumTimesPlayed() < pSong2->GetNumTimesPlayed();
/* /*
Comparing titles is slow, and this makes course selection choppy. Turning this Comparing titles is slow, and this makes course selection choppy. Turning this
off means we don't get consistent orderings of songs that have been played off means we don't get consistent orderings of songs that have been played
@@ -1479,7 +1479,7 @@ that have all been played 0 times.
return false; return false;
return CompareSongPointersByTitle( pSong1, pSong2 ); return CompareSongPointersByTitle( pSong1, pSong2 );
*/ */
} //}
/* Actually, just calculating GetNumTimesPlayed within the sort is pretty /* Actually, just calculating GetNumTimesPlayed within the sort is pretty
* slow, so let's precompute it. (This could be generalized with a template.) */ * slow, so let's precompute it. (This could be generalized with a template.) */
map<const Song*, CString> song_sort_val; map<const Song*, CString> song_sort_val;
@@ -1489,10 +1489,10 @@ bool CompareSongPointersBySortVal(const Song *pSong1, const Song *pSong2)
return song_sort_val[pSong1] < song_sort_val[pSong2]; return song_sort_val[pSong1] < song_sort_val[pSong2];
} }
void SortSongPointerArrayByMostPlayed( vector<Song*> &arraySongPointers ) void SortSongPointerArrayByMostPlayed( vector<Song*> &arraySongPointers, MemoryCard card )
{ {
for(unsigned i = 0; i < arraySongPointers.size(); ++i) for(unsigned i = 0; i < arraySongPointers.size(); ++i)
song_sort_val[arraySongPointers[i]] = ssprintf("%9i", arraySongPointers[i]->GetNumTimesPlayed()); song_sort_val[arraySongPointers[i]] = ssprintf("%9i", arraySongPointers[i]->GetNumTimesPlayed(card));
stable_sort( arraySongPointers.begin(), arraySongPointers.end(), CompareSongPointersBySortVal ); stable_sort( arraySongPointers.begin(), arraySongPointers.end(), CompareSongPointersBySortVal );
reverse( arraySongPointers.begin(), arraySongPointers.end() ); reverse( arraySongPointers.begin(), arraySongPointers.end() );
song_sort_val.clear(); song_sort_val.clear();
@@ -1543,13 +1543,12 @@ bool Song::HasBackground() const {return m_sBackgroundFile != "" && IsAFile(G
bool Song::HasCDTitle() const {return m_sCDTitleFile != "" && IsAFile(GetCDTitlePath()); } bool Song::HasCDTitle() const {return m_sCDTitleFile != "" && IsAFile(GetCDTitlePath()); }
bool Song::HasBGChanges() const {return !m_BackgroundChanges.empty(); } bool Song::HasBGChanges() const {return !m_BackgroundChanges.empty(); }
int Song::GetNumTimesPlayed() const int Song::GetNumTimesPlayed( MemoryCard card ) const
{ {
int iTotalNumTimesPlayed = 0; int iTotalNumTimesPlayed = 0;
for( unsigned i=0; i<m_apNotes.size(); i++ ) for( unsigned i=0; i<m_apNotes.size(); i++ )
{ iTotalNumTimesPlayed += m_apNotes[i]->GetNumTimesPlayed( card );
iTotalNumTimesPlayed += m_apNotes[i]->GetNumTimesPlayed(MEMORY_CARD_MACHINE);
}
return iTotalNumTimesPlayed; return iTotalNumTimesPlayed;
} }
+5 -2
View File
@@ -1321,8 +1321,11 @@ Course *SongManager::FindCourse( CString sName )
void SongManager::UpdateBest() void SongManager::UpdateBest()
{ {
m_pBestSongs = m_pSongs; for( int i = 0; i < NUM_MEMORY_CARDS; ++i )
SortSongPointerArrayByMostPlayed( m_pBestSongs ); {
m_pBestSongs[i] = m_pSongs;
SortSongPointerArrayByMostPlayed( m_pBestSongs[i], (MemoryCard) i );
}
} }
void SongManager::UpdateRankingCourses() void SongManager::UpdateRankingCourses()
+2 -2
View File
@@ -58,7 +58,7 @@ public:
// Lookup // Lookup
const vector<Song*> &GetAllSongs() const { return m_pSongs; } const vector<Song*> &GetAllSongs() const { return m_pSongs; }
const vector<Song*> &GetBestSongs() const { return m_pBestSongs; } const vector<Song*> &GetBestSongs( MemoryCard card=MEMORY_CARD_MACHINE ) const { return m_pBestSongs[MEMORY_CARD_MACHINE]; }
void GetSongs( vector<Song*> &AddTo, CString sGroupName, int iMaxStages = 100000 /*inf*/ ) const; void GetSongs( vector<Song*> &AddTo, CString sGroupName, int iMaxStages = 100000 /*inf*/ ) const;
void GetSongs( vector<Song*> &AddTo, int iMaxStages ) const { GetSongs(AddTo,"",iMaxStages); } void GetSongs( vector<Song*> &AddTo, int iMaxStages ) const { GetSongs(AddTo,"",iMaxStages); }
void GetSongs( vector<Song*> &AddTo ) const { GetSongs(AddTo,"",100000 /*inf*/ ); } void GetSongs( vector<Song*> &AddTo ) const { GetSongs(AddTo,"",100000 /*inf*/ ); }
@@ -144,7 +144,7 @@ protected:
void WriteStatsWebPage(); void WriteStatsWebPage();
vector<Song*> m_pSongs; // all songs that can be played vector<Song*> m_pSongs; // all songs that can be played
vector<Song*> m_pBestSongs; vector<Song*> m_pBestSongs[NUM_MEMORY_CARDS];
CStringArray m_sGroupNames; CStringArray m_sGroupNames;
CStringArray m_sGroupBannerPaths; // each song group may have a banner associated with it CStringArray m_sGroupBannerPaths; // each song group may have a banner associated with it
vector<Course*> m_pCourses; vector<Course*> m_pCourses;
+2 -2
View File
@@ -249,7 +249,7 @@ public:
Steps* GetStepsByDescription( StepsType nt, CString sDescription, bool bIncludeAutoGen = true ) const; Steps* GetStepsByDescription( StepsType nt, CString sDescription, bool bIncludeAutoGen = true ) const;
Steps* GetClosestNotes( StepsType nt, Difficulty dc, bool bIncludeAutoGen = true ) const; Steps* GetClosestNotes( StepsType nt, Difficulty dc, bool bIncludeAutoGen = true ) const;
void GetEdits( vector<Steps*>& arrayAddTo, StepsType nt, bool bIncludeAutoGen = true ) const; void GetEdits( vector<Steps*>& arrayAddTo, StepsType nt, bool bIncludeAutoGen = true ) const;
int GetNumTimesPlayed() const; int GetNumTimesPlayed( MemoryCard card ) const;
bool IsNew() const; bool IsNew() const;
bool IsEasy( StepsType nt ) const; bool IsEasy( StepsType nt ) const;
bool HasEdits( StepsType nt ) const; bool HasEdits( StepsType nt ) const;
@@ -270,7 +270,7 @@ void SortSongPointerArrayByGrade( vector<Song*> &arraySongPointers );
void SortSongPointerArrayByArtist( vector<Song*> &arraySongPointers ); void SortSongPointerArrayByArtist( vector<Song*> &arraySongPointers );
void SortSongPointerArrayByGroupAndDifficulty( vector<Song*> &arraySongPointers ); void SortSongPointerArrayByGroupAndDifficulty( vector<Song*> &arraySongPointers );
void SortSongPointerArrayByGroupAndTitle( vector<Song*> &arraySongPointers ); void SortSongPointerArrayByGroupAndTitle( vector<Song*> &arraySongPointers );
void SortSongPointerArrayByMostPlayed( vector<Song*> &arraySongPointers ); void SortSongPointerArrayByMostPlayed( vector<Song*> &arraySongPointers, MemoryCard card );
void SortSongPointerArrayByMeter( vector<Song*> &arraySongPointers, Difficulty dc ); void SortSongPointerArrayByMeter( vector<Song*> &arraySongPointers, Difficulty dc );