don't bother unloading "unused" note skins; now we just load all the note skins we'll need in advance for a whole round

This commit is contained in:
Glenn Maynard
2005-03-18 04:13:19 +00:00
parent 9a4283c8ee
commit b6b9b11b0f
5 changed files with 11 additions and 35 deletions
+6 -30
View File
@@ -68,38 +68,14 @@ void NoteField::CacheNoteSkin( CString skin )
m_NoteDisplays[ skin ] = nd; m_NoteDisplays[ skin ] = nd;
} }
void NoteField::CacheAllUsedNoteSkins( bool bDeleteUnused ) void NoteField::CacheAllUsedNoteSkins()
{ {
/* Cache note skins. */ /* Cache all note skins that we might need for the whole song, course or battle
* play, so we don't have to load them later (such as between course songs). */
vector<CString> skins; vector<CString> skins;
GAMESTATE->GetAllUsedNoteSkins( skins ); GAMESTATE->GetAllUsedNoteSkins( skins );
for( unsigned i=0; i < skins.size(); ++i ) for( unsigned i=0; i < skins.size(); ++i )
CacheNoteSkin( skins[i] ); CacheNoteSkin( skins[i] );
if( bDeleteUnused )
{
set<CString> setToDelete;
for( map<CString, NoteDisplayCols *>::iterator it = m_NoteDisplays.begin();
it != m_NoteDisplays.end(); ++it )
{
setToDelete.insert( it->first );
}
for( unsigned i=0; i < skins.size(); ++i )
{
CString sSkin = skins[i];
sSkin.ToLower();
setToDelete.erase( sSkin );
}
/* Free note skins that are no longer used. */
for( set<CString>::iterator it = setToDelete.begin(); it != setToDelete.end(); ++it )
{
NoteDisplayCols *pNoteDisplay = m_NoteDisplays[*it];
delete pNoteDisplay;
m_NoteDisplays.erase( *it );
}
}
} }
void NoteField::Load( void NoteField::Load(
@@ -120,9 +96,7 @@ void NoteField::Load(
ASSERT( m_pNoteData->GetNumTracks() == GAMESTATE->GetCurrentStyle()->m_iColsPerPlayer ); ASSERT( m_pNoteData->GetNumTracks() == GAMESTATE->GetCurrentStyle()->m_iColsPerPlayer );
/* If we're in gameplay, we havn't applied course modifiers yet, so we don't know what CacheAllUsedNoteSkins();
* note skins we'll need. Don't delete unused skins yet. */
CacheAllUsedNoteSkins( false );
RefreshBeatToNoteSkin(); RefreshBeatToNoteSkin();
} }
@@ -152,6 +126,8 @@ void NoteField::RefreshBeatToNoteSkin()
map<CString, NoteDisplayCols *>::iterator display = m_NoteDisplays.find( Skin ); map<CString, NoteDisplayCols *>::iterator display = m_NoteDisplays.find( Skin );
if( display == m_NoteDisplays.end() ) if( display == m_NoteDisplays.end() )
{ {
/* Skins should always be loaded by CacheAllUsedNoteSkins. */
LOG->Warn( "NoteField::RefreshBeatToNoteSkin: need note skin \"%s\" which should have been loaded alraedy", Skin.c_str() );
this->CacheNoteSkin( Skin ); this->CacheNoteSkin( Skin );
display = m_NoteDisplays.find( Skin ); display = m_NoteDisplays.find( Skin );
} }
+1 -1
View File
@@ -33,7 +33,7 @@ public:
int m_iBeginMarker, m_iEndMarker; // only used with MODE_EDIT int m_iBeginMarker, m_iEndMarker; // only used with MODE_EDIT
void FadeToFail(); void FadeToFail();
void CacheAllUsedNoteSkins( bool bDeleteUnused ); void CacheAllUsedNoteSkins();
void CacheNoteSkin( CString skin ); void CacheNoteSkin( CString skin );
void Step( int iCol, TapNoteScore score ); void Step( int iCol, TapNoteScore score );
+2 -2
View File
@@ -1393,9 +1393,9 @@ float Player::GetMaxStepDistanceSeconds()
return GAMESTATE->m_SongOptions.m_fMusicRate * ADJUSTED_WINDOW(Boo); return GAMESTATE->m_SongOptions.m_fMusicRate * ADJUSTED_WINDOW(Boo);
} }
void Player::CacheAllUsedNoteSkins( bool bDeleteUnused ) void Player::CacheAllUsedNoteSkins()
{ {
m_pNoteField->CacheAllUsedNoteSkins( bDeleteUnused ); m_pNoteField->CacheAllUsedNoteSkins();
} }
void Player::FadeToFail() void Player::FadeToFail()
+1 -1
View File
@@ -55,7 +55,7 @@ public:
static float GetMaxStepDistanceSeconds(); static float GetMaxStepDistanceSeconds();
void CacheAllUsedNoteSkins( bool bDeleteUnused ); void CacheAllUsedNoteSkins();
NoteData m_NoteData; NoteData m_NoteData;
+1 -1
View File
@@ -868,7 +868,7 @@ void ScreenGameplay::SetupSong( PlayerNumber p, int iSongIndex )
m_Player[p].ApplyWaitingTransforms(); m_Player[p].ApplyWaitingTransforms();
/* Now that course options are applied, load any needed note skins and unload old ones. */ /* Now that course options are applied, load any needed note skins and unload old ones. */
m_Player[p].CacheAllUsedNoteSkins( true ); m_Player[p].CacheAllUsedNoteSkins();
/* Update attack bOn flags. */ /* Update attack bOn flags. */
GAMESTATE->Update(0); GAMESTATE->Update(0);