Apply speed up loading patch from https://sourceforge.net/tracker/?func=detail&atid=421366&aid=1691830&group_id=37892
This commit is contained in:
@@ -223,7 +223,42 @@ void Course::Init()
|
||||
|
||||
bool Course::IsPlayableIn( StepsType st ) const
|
||||
{
|
||||
return GetTrail( st ) != NULL;
|
||||
// Stripped down version of GetTrailUnsorted
|
||||
FOREACH_CONST( CourseEntry, m_vEntries, e )
|
||||
{
|
||||
SongCriteria soc = e->songCriteria;
|
||||
|
||||
if( e->pSong )
|
||||
{
|
||||
soc.m_bUseSongAllowedList = true;
|
||||
soc.m_vpSongAllowedList.push_back( e->pSong );
|
||||
}
|
||||
soc.m_Tutorial = SongCriteria::Tutorial_No;
|
||||
soc.m_Locked = SongCriteria::Locked_Unlocked;
|
||||
if( !soc.m_bUseSongAllowedList )
|
||||
soc.m_iMaxStagesForSong = 1;
|
||||
|
||||
StepsCriteria stc = e->stepsCriteria;
|
||||
stc.m_st = st;
|
||||
stc.m_Locked = StepsCriteria::Locked_Unlocked;
|
||||
|
||||
const bool bSameSongCriteria = e != m_vEntries.begin() && (e-1)->songCriteria == soc;
|
||||
const bool bSameStepsCriteria = e != m_vEntries.begin() && (e-1)->stepsCriteria == stc;
|
||||
|
||||
if( e->pSong )
|
||||
{
|
||||
if ( StepsUtil::HasMatching(e->pSong, stc) )
|
||||
return true;
|
||||
}
|
||||
else if( !(bSameSongCriteria && bSameStepsCriteria) )
|
||||
{
|
||||
if ( StepsUtil::HasMatching(soc, stc) )
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -222,6 +222,8 @@ void SongManager::LoadStepManiaSongDir( RString sDir, LoadingWindow *ld )
|
||||
(sDir+sGroupDirName).c_str() );
|
||||
int loaded = 0;
|
||||
|
||||
SongPointerVector& index_entry = m_mapSongGroupIndex[sGroupDirName];
|
||||
|
||||
for( unsigned j=0; j< arraySongDirs.size(); ++j ) // for each song dir
|
||||
{
|
||||
RString sSongDirName = arraySongDirs[j];
|
||||
@@ -243,6 +245,7 @@ void SongManager::LoadStepManiaSongDir( RString sDir, LoadingWindow *ld )
|
||||
}
|
||||
|
||||
m_pSongs.push_back( pNewSong );
|
||||
index_entry.push_back( pNewSong );
|
||||
loaded++;
|
||||
}
|
||||
|
||||
@@ -270,6 +273,7 @@ void SongManager::LoadGroupSymLinks(RString sDir, RString sGroupFolder)
|
||||
vector<RString> arraySymLinks;
|
||||
GetDirListing( sDir+sGroupFolder+"/*.include", arraySymLinks, false );
|
||||
SortRStringArray( arraySymLinks );
|
||||
SongPointerVector& index_entry = m_mapSongGroupIndex[sGroupFolder];
|
||||
for( unsigned s=0; s< arraySymLinks.size(); s++ ) // for each symlink in this dir, add it in as a song.
|
||||
{
|
||||
MsdFile msdF;
|
||||
@@ -293,6 +297,7 @@ void SongManager::LoadGroupSymLinks(RString sDir, RString sGroupFolder)
|
||||
pNewSong->m_bIsSymLink = true; // Very important so we don't double-parse later
|
||||
pNewSong->m_sGroupName = sGroupFolder;
|
||||
m_pSongs.push_back( pNewSong );
|
||||
index_entry.push_back( pNewSong );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -338,6 +343,7 @@ void SongManager::FreeSongs()
|
||||
for( unsigned i=0; i<m_pSongs.size(); i++ )
|
||||
SAFE_DELETE( m_pSongs[i] );
|
||||
m_pSongs.clear();
|
||||
m_mapSongGroupIndex.clear();
|
||||
|
||||
m_sSongGroupBannerPaths.clear();
|
||||
|
||||
@@ -525,7 +531,20 @@ static void GetSongsFromVector( const vector<Song*> &Songs, vector<Song*> &vOut,
|
||||
|
||||
void SongManager::GetSongs( vector<Song*> &AddTo, RString sGroupName ) const
|
||||
{
|
||||
GetSongsFromVector( m_pSongs, AddTo, sGroupName );
|
||||
if( sGroupName==GROUP_ALL)
|
||||
GetSongsFromVector( m_pSongs, AddTo, sGroupName );
|
||||
else
|
||||
GetSongsFromVector( GetSongsInGroup(sGroupName), AddTo, GROUP_ALL );
|
||||
}
|
||||
|
||||
const vector<Song*> &SongManager::GetSongsInGroup( RString sGroupName ) const
|
||||
{
|
||||
static vector<Song*> empty;
|
||||
|
||||
map<RString, SongPointerVector>::const_iterator iter = m_mapSongGroupIndex.find( sGroupName );
|
||||
if ( iter != m_mapSongGroupIndex.end() )
|
||||
return iter->second;
|
||||
return empty;
|
||||
}
|
||||
|
||||
void SongManager::GetPopularSongs( vector<Song*> &AddTo, RString sGroupName, ProfileSlot slot ) const
|
||||
|
||||
@@ -73,6 +73,7 @@ public:
|
||||
|
||||
// Lookup
|
||||
const vector<Song*> &GetAllSongs() const { return m_pSongs; }
|
||||
const vector<Song*> &GetSongsInGroup( RString sGroupName ) const;
|
||||
void GetPopularSongs( vector<Song*> &AddTo, 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]; }
|
||||
@@ -140,6 +141,7 @@ protected:
|
||||
vector<SongPointerVector> m_vPreferredSongSort;
|
||||
vector<RString> m_sSongGroupNames;
|
||||
vector<RString> m_sSongGroupBannerPaths; // each song group may have a banner associated with it
|
||||
map<RString,SongPointerVector> m_mapSongGroupIndex;
|
||||
|
||||
vector<Course*> m_pCourses;
|
||||
vector<Course*> m_pPopularCourses[NUM_ProfileSlot][NUM_CourseType];
|
||||
|
||||
@@ -41,7 +41,11 @@ bool StepsCriteria::Matches( const Song *pSong, const Steps *pSteps ) const
|
||||
|
||||
void StepsUtil::GetAllMatching( const SongCriteria &soc, const StepsCriteria &stc, vector<SongAndSteps> &out )
|
||||
{
|
||||
FOREACH_CONST( Song*, SONGMAN->GetAllSongs(), so )
|
||||
const vector<Song*> &songs = soc.m_sGroupName.empty() ?
|
||||
SONGMAN->GetAllSongs() :
|
||||
SONGMAN->GetSongsInGroup(soc.m_sGroupName);
|
||||
|
||||
FOREACH_CONST( Song*, songs, so )
|
||||
{
|
||||
if( !soc.Matches(*so) )
|
||||
continue;
|
||||
@@ -59,6 +63,29 @@ void StepsUtil::GetAllMatching( Song *pSong, const StepsCriteria &stc, vector<So
|
||||
out.push_back( SongAndSteps(pSong, *st) );
|
||||
}
|
||||
|
||||
bool StepsUtil::HasMatching( const SongCriteria &soc, const StepsCriteria &stc )
|
||||
{
|
||||
const vector<Song*> &songs = soc.m_sGroupName.empty()? SONGMAN->GetAllSongs():SONGMAN->GetSongsInGroup( soc.m_sGroupName );
|
||||
|
||||
FOREACH_CONST( Song*, songs, so )
|
||||
{
|
||||
if( soc.Matches(*so) && HasMatching(*so, stc) )
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool StepsUtil::HasMatching( const Song *pSong, const StepsCriteria &stc )
|
||||
{
|
||||
const vector<Steps*> &vSteps = stc.m_st == StepsType_Invalid? pSong->GetAllSteps():pSong->GetStepsByStepsType( stc.m_st );
|
||||
|
||||
FOREACH_CONST( Steps*, vSteps, st )
|
||||
{
|
||||
if( stc.Matches(pSong, *st) )
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// Sorting stuff
|
||||
|
||||
@@ -53,6 +53,8 @@ namespace StepsUtil
|
||||
{
|
||||
void GetAllMatching( const SongCriteria &soc, const StepsCriteria &stc, vector<SongAndSteps> &out ); // look up in SONGMAN
|
||||
void GetAllMatching( Song *pSong, const StepsCriteria &stc, vector<SongAndSteps> &out );
|
||||
bool HasMatching( const SongCriteria &soc, const StepsCriteria &stc );
|
||||
bool HasMatching( const Song *pSong, const StepsCriteria &stc );
|
||||
|
||||
bool CompareNotesPointersByRadarValues(const Steps* pSteps1, const Steps* pSteps2);
|
||||
bool CompareNotesPointersByMeter(const Steps *pSteps1, const Steps* pSteps2);
|
||||
|
||||
Reference in New Issue
Block a user