From 27f76b12efdfbf45dfc5e37b57cbe2ee06eb8729 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 15 Aug 2007 23:35:48 +0000 Subject: [PATCH] fold in UpdateCachedPointers --- stepmania/src/UnlockManager.cpp | 83 +++++++++++++++------------------ stepmania/src/UnlockManager.h | 3 -- 2 files changed, 37 insertions(+), 49 deletions(-) diff --git a/stepmania/src/UnlockManager.cpp b/stepmania/src/UnlockManager.cpp index 35110e9cb3..e020928900 100644 --- a/stepmania/src/UnlockManager.cpp +++ b/stepmania/src/UnlockManager.cpp @@ -481,7 +481,43 @@ void UnlockManager::Load() if( ue != ue2 ) ASSERT_M( ue->m_sEntryID != ue2->m_sEntryID, ssprintf("duplicate unlock entry id %s",ue->m_sEntryID.c_str()) ); - UpdateCachedPointers(); + FOREACH( UnlockEntry, m_UnlockEntries, e ) + { + switch( e->m_Type ) + { + case UnlockRewardType_Song: + e->m_Song.FromSong( SONGMAN->FindSong( e->m_cmd.GetArg(0).s ) ); + if( !e->m_Song.IsValid() ) + LOG->Warn( "Unlock: Cannot find song matching \"%s\"", e->m_cmd.GetArg(0).s.c_str() ); + break; + case UnlockRewardType_Steps: + e->m_Song.FromSong( SONGMAN->FindSong( e->m_cmd.GetArg(0).s ) ); + if( !e->m_Song.IsValid() ) + { + LOG->Warn( "Unlock: Cannot find song matching \"%s\"", e->m_cmd.GetArg(0).s.c_str() ); + break; + } + + e->m_dc = StringToDifficulty( e->m_cmd.GetArg(1).s ); + if( e->m_dc == Difficulty_Invalid ) + { + LOG->Warn( "Unlock: Invalid difficulty \"%s\"", e->m_cmd.GetArg(1).s.c_str() ); + break; + } + + break; + case UnlockRewardType_Course: + e->m_Course.FromCourse( SONGMAN->FindCourse(e->m_cmd.GetArg(0).s) ); + if( !e->m_Course.IsValid() ) + LOG->Warn( "Unlock: Cannot find course matching \"%s\"", e->m_cmd.GetArg(0).s.c_str() ); + break; + case UnlockRewardType_Modifier: + // nothing to cache + break; + default: + ASSERT(0); + } + } // // Log unlocks @@ -533,51 +569,6 @@ float UnlockManager::PointsUntilNextUnlock( UnlockRequirement t ) const return fSmallestPoints - fScores[t]; } -/* Update the cached pointers. Only call this when it's likely to have changed, - * such as on load, or when a song title changes in the editor. */ -void UnlockManager::UpdateCachedPointers() -{ - FOREACH( UnlockEntry, m_UnlockEntries, e ) - { - switch( e->m_Type ) - { - case UnlockRewardType_Song: - e->m_Song.FromSong( SONGMAN->FindSong( e->m_cmd.GetArg(0).s ) ); - if( !e->m_Song.IsValid() ) - LOG->Warn( "Unlock: Cannot find song matching \"%s\"", e->m_cmd.GetArg(0).s.c_str() ); - break; - case UnlockRewardType_Steps: - e->m_Song.FromSong( SONGMAN->FindSong( e->m_cmd.GetArg(0).s ) ); - if( !e->m_Song.IsValid() ) - { - LOG->Warn( "Unlock: Cannot find song matching \"%s\"", e->m_cmd.GetArg(0).s.c_str() ); - break; - } - - e->m_dc = StringToDifficulty( e->m_cmd.GetArg(1).s ); - if( e->m_dc == Difficulty_Invalid ) - { - LOG->Warn( "Unlock: Invalid difficulty \"%s\"", e->m_cmd.GetArg(1).s.c_str() ); - break; - } - - break; - case UnlockRewardType_Course: - e->m_Course.FromCourse( SONGMAN->FindCourse(e->m_cmd.GetArg(0).s) ); - if( !e->m_Course.IsValid() ) - LOG->Warn( "Unlock: Cannot find course matching \"%s\"", e->m_cmd.GetArg(0).s.c_str() ); - break; - case UnlockRewardType_Modifier: - // nothing to cache - break; - default: - ASSERT(0); - } - } -} - - - void UnlockManager::UnlockEntryID( RString sEntryID ) { PROFILEMAN->GetMachineProfile()->m_UnlockedEntryIDs.insert( sEntryID ); diff --git a/stepmania/src/UnlockManager.h b/stepmania/src/UnlockManager.h index cdd41d9aed..7350d0dfcb 100644 --- a/stepmania/src/UnlockManager.h +++ b/stepmania/src/UnlockManager.h @@ -143,9 +143,6 @@ public: // All locked songs are stored here vector m_UnlockEntries; - // If global song or course points change, call to update - void UpdateCachedPointers(); - void GetUnlocksByType( UnlockRewardType t, vector &apEntries ); void GetSongsUnlockedByEntryID( vector &apSongsOut, RString sEntryID ); void GetStepsUnlockedByEntryID( vector &apSongsOut, vector &apStepsOut, RString sEntryID );