{\r
RageTimer tm;\r
\r
- /* this loads the songs into m_pMachineSongs */\r
LoadStepManiaSongDir( SONGS_DIR, ld );\r
\r
- /* now, copy them into m_pSongs */\r
- m_pSongs.insert( m_pSongs.begin(), m_pMachineSongs.begin(), m_pMachineSongs.end() );\r
-\r
LOG->Trace( "Found %d songs in %f seconds.", (int)m_pSongs.size(), tm.GetDeltaTime() );\r
}\r
\r
continue;\r
}\r
\r
- m_pMachineSongs.push_back( pNewSong );\r
+ m_pSongs.push_back( pNewSong );\r
loaded++;\r
}\r
\r
\r
LOG->Trace( "Loading custom song '%s'...", pNewSong->m_sMainTitle.c_str() );\r
\r
- // TODO: load everything into m_pCustomSongs, then insert() into m_pSongs,\r
- // instead of manually inserting the song into both arrays.\r
- m_pCustomSongs.push_back( pNewSong );\r
m_pSongs.push_back( pNewSong );\r
iSongsLoaded++;\r
}\r
\r
pNewSong->m_bIsSymLink = true; // Very important so we don't double-parse later\r
pNewSong->m_sGroupName = sGroupFolder;\r
- m_pMachineSongs.push_back( pNewSong );\r
+ m_pSongs.push_back( pNewSong );\r
}\r
}\r
}\r
m_sSongGroupNames.clear();\r
m_sSongGroupBannerPaths.clear();\r
\r
- for( unsigned i=0; i<m_pCustomSongs.size(); i++ )\r
- SAFE_DELETE( m_pCustomSongs[i] );\r
- m_pCustomSongs.clear();\r
-\r
- for( unsigned i=0; i<m_pMachineSongs.size(); i++ )\r
- SAFE_DELETE( m_pMachineSongs[i] );\r
- m_pMachineSongs.clear();\r
-\r
- // m_pSongs is simply cleared because all its pointers\r
- // were already freed in the two previous vectors\r
- m_pSongs.clear();\r
+ for( unsigned i=0; i<m_pSongs.size(); i++ )\r
+ SAFE_DELETE( m_pSongs[i] );\r
\r
m_sSongGroupBannerPaths.clear();\r
\r
\r
void SongManager::FreeAllLoadedPlayerSongs()\r
{\r
- // if we don't have any songs to free, don't bother\r
- if( m_pCustomSongs.empty() )\r
- return;\r
-\r
LOG->Trace( "SongManager::FreeAllLoadedPlayerSongs()" );\r
\r
- /* free the previously loaded song data */\r
- for( unsigned i = 0; i < m_pCustomSongs.size(); i++ )\r
- SAFE_DELETE( m_pCustomSongs[i] );\r
- m_pCustomSongs.clear();\r
-\r
- /* Now, we just need to rebuild m_pSongs from m_pMachineSongs. */\r
- m_pSongs.clear();\r
- m_pSongs.insert( m_pSongs.begin(), m_pMachineSongs.begin(), m_pMachineSongs.end() );\r
+ for(unsigned i = 0; i < m_pSongs.size(); i++)\r
+ {\r
+ if (m_pSongs[i]->m_SongOwner != PLAYER_INVALID)\r
+ {\r
+ SAFE_DELETE(m_pSongs[i]);\r
+ m_pSongs.erase( m_pSongs.begin()+i );\r
+ }\r
+ }\r
}\r
\r
void SongManager::FreeAllLoadedFromProfile( ProfileSlot slot )\r
Song *FindSong( CString sGroup, CString sSong );
- /* m_pMachineSongs holds all the songs that are loaded by default to the machine.
- * m_pCustomSongs holds songs that were loaded from a USB drive; they can safely be deleted after a round.
- * m_pSongs is the combination of the above two, and must be rebuilt after a round ends. */
- vector<Song*> m_pMachineSongs; // all songs that are on by default
- vector<Song*> m_pCustomSongs;
vector<Song*> m_pSongs; // all songs that can be played
vector<Song*> m_pBestSongs[NUM_PROFILE_SLOTS];
vector<Song*> m_pShuffledSongs; // used by GetRandomSong