Whoops! We can't revert an autogen course from disk. My bad.

TODO: is there a cheaper way to fix up the autogen courses?
This commit is contained in:
John Bauer
2006-11-28 06:56:33 +00:00
parent e65abee08d
commit dd0d56e4af
2 changed files with 28 additions and 2 deletions
+27 -2
View File
@@ -799,7 +799,6 @@ void SongManager::InitAutogenCourses()
} }
} }
void SongManager::FreeCourses() void SongManager::FreeCourses()
{ {
for( unsigned i=0; i<m_pCourses.size(); i++ ) for( unsigned i=0; i<m_pCourses.size(); i++ )
@@ -814,6 +813,26 @@ void SongManager::FreeCourses()
m_mapCourseGroupToInfo.clear(); m_mapCourseGroupToInfo.clear();
} }
void SongManager::DeleteAutogenCourses()
{
vector<Course*> vNewCourses;
for( vector<Course*>::iterator it = m_pCourses.begin(); it != m_pCourses.end(); ++it )
{
if( (*it)->m_bIsAutogen )
{
delete *it;
}
else
{
vNewCourses.push_back( *it );
}
}
m_pCourses.swap( vNewCourses );
UpdatePopular();
UpdateShuffled();
RefreshCourseGroupInfo();
}
void SongManager::AddCourse( Course *pCourse ) void SongManager::AddCourse( Course *pCourse )
{ {
m_pCourses.push_back( pCourse ); m_pCourses.push_back( pCourse );
@@ -861,15 +880,21 @@ void SongManager::Cleanup()
/* Flush all Song*, Steps* and Course* caches. This is when a Song or its Steps /* Flush all Song*, Steps* and Course* caches. This is when a Song or its Steps
* are removed or changed. This doesn't touch GAMESTATE and StageStats * are removed or changed. This doesn't touch GAMESTATE and StageStats
* pointers. Currently, the only time Steps are altered independantly of the * pointers. Currently, the only time Steps are altered independently of the
* Courses and Songs is in Edit Mode, which updates the other pointers it needs. */ * Courses and Songs is in Edit Mode, which updates the other pointers it needs. */
void SongManager::Invalidate( const Song *pStaleSong ) void SongManager::Invalidate( const Song *pStaleSong )
{ {
// TODO: This is unnecessarily expensive.
// Can we regenerate only the autogen courses that are affected?
DeleteAutogenCourses();
FOREACH( Course*, this->m_pCourses, pCourse ) FOREACH( Course*, this->m_pCourses, pCourse )
{ {
(*pCourse)->Invalidate( pStaleSong ); (*pCourse)->Invalidate( pStaleSong );
} }
InitAutogenCourses();
UpdatePopular(); UpdatePopular();
UpdateShuffled(); UpdateShuffled();
RefreshCourseGroupInfo(); RefreshCourseGroupInfo();
+1
View File
@@ -49,6 +49,7 @@ public:
void FreeCourses(); void FreeCourses();
void AddCourse( Course *pCourse ); // transfers ownership of pCourse void AddCourse( Course *pCourse ); // transfers ownership of pCourse
void DeleteCourse( Course *pCourse ); // transfers ownership of pCourse void DeleteCourse( Course *pCourse ); // transfers ownership of pCourse
void DeleteAutogenCourses(); // deletes every autogen course
void InvalidateCachedTrails(); void InvalidateCachedTrails();
void InitAll( LoadingWindow *ld ); // songs, courses, groups - everything. void InitAll( LoadingWindow *ld ); // songs, courses, groups - everything.