API change. SONGMAN->GetSongs( groupName ) returns a const reference to the songs in the group. If you want a copy of the songs, just copy the return value:

vector<Song *> vSongs = SONGMAN->GetSongs( groupName );
If you don't want to change the songs, get a const reference instead to keep it from copying.
This commit is contained in:
Steve Checkoway
2007-04-07 05:10:29 +00:00
parent 8d3dc681f4
commit 54035d6334
2 changed files with 4 additions and 15 deletions
+3 -13
View File
@@ -520,14 +520,7 @@ RageColor SongManager::GetCourseColor( const Course* pCourse )
}
}
void SongManager::GetSongs( vector<Song*> &AddTo, const RString &sGroupName ) const
{
const vector<Song *> &vSongs = GetSongsInGroup( sGroupName );
AddTo.insert( AddTo.end(), vSongs.begin(), vSongs.end() );
}
const vector<Song*> &SongManager::GetSongsInGroup( const RString &sGroupName ) const
const vector<Song*> &SongManager::GetSongs( const RString &sGroupName ) const
{
static const vector<Song*> vEmpty;
@@ -557,7 +550,7 @@ void SongManager::GetPreferredSortSongs( vector<Song*> &AddTo ) const
{
if( m_vPreferredSongSort.empty() )
{
GetSongs( AddTo );
AddTo.insert( AddTo.end(), m_pSongs.begin(), m_pSongs.end() );
return;
}
@@ -738,8 +731,6 @@ void SongManager::InitAutogenCourses()
for( unsigned g=0; g<saGroupNames.size(); g++ ) // foreach Group
{
RString sGroupName = saGroupNames[g];
vector<Song*> apGroupSongs;
GetSongs( apGroupSongs, sGroupName );
// Generate random courses from each group.
pCourse = new Course;
@@ -1081,8 +1072,7 @@ void SongManager::GetExtraStageInfo( bool bExtra2, const Style *sd, Song*& pSong
Song* pExtra2Song = NULL; // a medium-hard Song and Steps. Use this for extra stage 2.
Steps* pExtra2Notes = NULL;
vector<Song*> apSongs;
SONGMAN->GetSongs( apSongs, sGroup );
const vector<Song*> &apSongs = GetSongs( sGroup );
for( unsigned s=0; s<apSongs.size(); s++ ) // foreach song
{
Song* pSong = apSongs[s];
+1 -2
View File
@@ -73,12 +73,11 @@ public:
// Lookup
const vector<Song*> &GetAllSongs() const { return m_pSongs; }
const vector<Song*> &GetSongsInGroup( const RString &sGroupName ) const;
const vector<Song*> &GetSongs( const RString &sGroupName = GROUP_ALL ) const;
void GetPopularSongs( vector<Song*> &AddTo, const RString &sGroupName, ProfileSlot slot=ProfileSlot_Machine ) const;
void GetPreferredSortSongs( vector<Song*> &AddTo ) const;
const vector<Song*> &GetPopularSongs( ProfileSlot slot=ProfileSlot_Machine ) const { return m_pPopularSongs[slot]; }
const vector<Course*> &GetPopularCourses( CourseType ct, ProfileSlot slot=ProfileSlot_Machine ) const { return m_pPopularCourses[slot][ct]; }
void GetSongs( vector<Song*> &AddTo, const RString &sGroupName = GROUP_ALL ) const;
Song *FindSong( RString sPath );
Song *FindSong( RString sGroup, RString sSong );
Course *FindCourse( RString sPath );