fix crash after Reload Songs-Courses
This commit is contained in:
@@ -107,8 +107,7 @@ void ScreenOptionsMenu::GoToNextState()
|
|||||||
case OM_MACHINE: SCREENMAN->SetNewScreen("ScreenMachineOptions"); break;
|
case OM_MACHINE: SCREENMAN->SetNewScreen("ScreenMachineOptions"); break;
|
||||||
// case OM_SOUND: SCREENMAN->SetNewScreen("ScreenSoundOptions"); break;
|
// case OM_SOUND: SCREENMAN->SetNewScreen("ScreenSoundOptions"); break;
|
||||||
case OM_RELOAD:
|
case OM_RELOAD:
|
||||||
SONGMAN->ReloadSongs();
|
SONGMAN->Reload();
|
||||||
SONGMAN->ReloadCourses();
|
|
||||||
SCREENMAN->SetNewScreen( "ScreenTitleMenu" );
|
SCREENMAN->SetNewScreen( "ScreenTitleMenu" );
|
||||||
break;
|
break;
|
||||||
default: // Exit
|
default: // Exit
|
||||||
|
|||||||
@@ -95,21 +95,22 @@ SongManager::~SongManager()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SongManager::ReloadSongs()
|
void SongManager::Reload()
|
||||||
{
|
{
|
||||||
FlushDirCache();
|
FlushDirCache();
|
||||||
FreeSongs();
|
|
||||||
InitSongsFromDisk(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SongManager::ReloadCourses()
|
FreeSongs();
|
||||||
{
|
|
||||||
FlushDirCache();
|
|
||||||
FreeCourses();
|
FreeCourses();
|
||||||
|
|
||||||
|
m_sGroupNames.clear();
|
||||||
|
m_sGroupBannerPaths.clear();
|
||||||
|
|
||||||
|
InitSongsFromDisk(NULL);
|
||||||
InitCoursesFromDisk(NULL);
|
InitCoursesFromDisk(NULL);
|
||||||
InitAutogenCourses();
|
InitAutogenCourses();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SongManager::SaveMachineScoresToDisk()
|
void SongManager::SaveMachineScoresToDisk()
|
||||||
{
|
{
|
||||||
SaveCategoryRankingsToFile( CATEGORY_RANKING_FILE );
|
SaveCategoryRankingsToFile( CATEGORY_RANKING_FILE );
|
||||||
@@ -155,10 +156,10 @@ void SongManager::SanityCheckGroupDir( CString sDir ) const
|
|||||||
void SongManager::AddGroup( CString sDir, CString sGroupDirName )
|
void SongManager::AddGroup( CString sDir, CString sGroupDirName )
|
||||||
{
|
{
|
||||||
unsigned j;
|
unsigned j;
|
||||||
for(j = 0; j < m_arrayGroupNames.size(); ++j)
|
for(j = 0; j < m_sGroupNames.size(); ++j)
|
||||||
if( sGroupDirName == m_arrayGroupNames[j] ) break;
|
if( sGroupDirName == m_sGroupNames[j] ) break;
|
||||||
|
|
||||||
if( j != m_arrayGroupNames.size() )
|
if( j != m_sGroupNames.size() )
|
||||||
return; /* the group is already added */
|
return; /* the group is already added */
|
||||||
|
|
||||||
// Look for a group banner in this group folder
|
// Look for a group banner in this group folder
|
||||||
@@ -184,8 +185,8 @@ void SongManager::AddGroup( CString sDir, CString sGroupDirName )
|
|||||||
|
|
||||||
if( sBannerPath != "" )
|
if( sBannerPath != "" )
|
||||||
LOG->Trace( "Group banner for '%s' is '%s'.", sGroupDirName.c_str(), sBannerPath.c_str() );
|
LOG->Trace( "Group banner for '%s' is '%s'.", sGroupDirName.c_str(), sBannerPath.c_str() );
|
||||||
m_arrayGroupNames.push_back( sGroupDirName );
|
m_sGroupNames.push_back( sGroupDirName );
|
||||||
m_GroupBannerPaths.push_back(sBannerPath);
|
m_sGroupBannerPaths.push_back(sBannerPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SongManager::LoadStepManiaSongDir( CString sDir, LoadingWindow *ld )
|
void SongManager::LoadStepManiaSongDir( CString sDir, LoadingWindow *ld )
|
||||||
@@ -263,7 +264,7 @@ void SongManager::FreeSongs()
|
|||||||
SAFE_DELETE( m_pSongs[i] );
|
SAFE_DELETE( m_pSongs[i] );
|
||||||
m_pSongs.clear();
|
m_pSongs.clear();
|
||||||
|
|
||||||
m_GroupBannerPaths.clear();
|
m_sGroupBannerPaths.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -608,23 +609,23 @@ void SongManager::SaveCourseScoresToFile( CString fn, int c )
|
|||||||
CString SongManager::GetGroupBannerPath( CString sGroupName )
|
CString SongManager::GetGroupBannerPath( CString sGroupName )
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
for(i = 0; i < m_arrayGroupNames.size(); ++i)
|
for(i = 0; i < m_sGroupNames.size(); ++i)
|
||||||
if( sGroupName == m_arrayGroupNames[i] ) break;
|
if( sGroupName == m_sGroupNames[i] ) break;
|
||||||
|
|
||||||
if( i == m_arrayGroupNames.size() )
|
if( i == m_sGroupNames.size() )
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
return m_GroupBannerPaths[i];
|
return m_sGroupBannerPaths[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
void SongManager::GetGroupNames( CStringArray &AddTo )
|
void SongManager::GetGroupNames( CStringArray &AddTo )
|
||||||
{
|
{
|
||||||
AddTo.insert(AddTo.end(), m_arrayGroupNames.begin(), m_arrayGroupNames.end() );
|
AddTo.insert(AddTo.end(), m_sGroupNames.begin(), m_sGroupNames.end() );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SongManager::DoesGroupExist( CString sGroupName )
|
bool SongManager::DoesGroupExist( CString sGroupName )
|
||||||
{
|
{
|
||||||
return find( m_arrayGroupNames.begin(), m_arrayGroupNames.end(), sGroupName ) != m_arrayGroupNames.end();
|
return find( m_sGroupNames.begin(), m_sGroupNames.end(), sGroupName ) != m_sGroupNames.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
RageColor SongManager::GetGroupColor( const CString &sGroupName )
|
RageColor SongManager::GetGroupColor( const CString &sGroupName )
|
||||||
@@ -633,12 +634,12 @@ RageColor SongManager::GetGroupColor( const CString &sGroupName )
|
|||||||
|
|
||||||
// search for the group index
|
// search for the group index
|
||||||
unsigned i;
|
unsigned i;
|
||||||
for( i=0; i<m_arrayGroupNames.size(); i++ )
|
for( i=0; i<m_sGroupNames.size(); i++ )
|
||||||
{
|
{
|
||||||
if( m_arrayGroupNames[i] == sGroupName )
|
if( m_sGroupNames[i] == sGroupName )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ASSERT( i != m_arrayGroupNames.size() ); // this is not a valid group
|
ASSERT( i != m_sGroupNames.size() ); // this is not a valid group
|
||||||
|
|
||||||
return g_vGroupColors[i%g_vGroupColors.size()];
|
return g_vGroupColors[i%g_vGroupColors.size()];
|
||||||
}
|
}
|
||||||
@@ -707,7 +708,7 @@ int SongManager::GetNumSongs() const
|
|||||||
|
|
||||||
int SongManager::GetNumGroups() const
|
int SongManager::GetNumGroups() const
|
||||||
{
|
{
|
||||||
return m_arrayGroupNames.size();
|
return m_sGroupNames.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
int SongManager::GetNumCourses() const
|
int SongManager::GetNumCourses() const
|
||||||
|
|||||||
@@ -34,13 +34,13 @@ public:
|
|||||||
|
|
||||||
void InitSongsFromDisk( LoadingWindow *ld );
|
void InitSongsFromDisk( LoadingWindow *ld );
|
||||||
void FreeSongs();
|
void FreeSongs();
|
||||||
void ReloadSongs();
|
|
||||||
void CompressSongs();
|
void CompressSongs();
|
||||||
|
|
||||||
void InitCoursesFromDisk( LoadingWindow *ld );
|
void InitCoursesFromDisk( LoadingWindow *ld );
|
||||||
void InitAutogenCourses();
|
void InitAutogenCourses();
|
||||||
void FreeCourses();
|
void FreeCourses();
|
||||||
void ReloadCourses();
|
|
||||||
|
void Reload(); // songs, courses, groups - everything.
|
||||||
|
|
||||||
|
|
||||||
CString GetGroupBannerPath( CString sGroupName );
|
CString GetGroupBannerPath( CString sGroupName );
|
||||||
@@ -124,8 +124,8 @@ protected:
|
|||||||
|
|
||||||
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;
|
||||||
CStringArray m_arrayGroupNames;
|
CStringArray m_sGroupNames;
|
||||||
CStringArray m_GroupBannerPaths; // each song group has 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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user