fold in UpdateCachedPointers
This commit is contained in:
@@ -481,7 +481,43 @@ void UnlockManager::Load()
|
|||||||
if( ue != ue2 )
|
if( ue != ue2 )
|
||||||
ASSERT_M( ue->m_sEntryID != ue2->m_sEntryID, ssprintf("duplicate unlock entry id %s",ue->m_sEntryID.c_str()) );
|
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
|
// Log unlocks
|
||||||
@@ -533,51 +569,6 @@ float UnlockManager::PointsUntilNextUnlock( UnlockRequirement t ) const
|
|||||||
return fSmallestPoints - fScores[t];
|
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 )
|
void UnlockManager::UnlockEntryID( RString sEntryID )
|
||||||
{
|
{
|
||||||
PROFILEMAN->GetMachineProfile()->m_UnlockedEntryIDs.insert( sEntryID );
|
PROFILEMAN->GetMachineProfile()->m_UnlockedEntryIDs.insert( sEntryID );
|
||||||
|
|||||||
@@ -143,9 +143,6 @@ public:
|
|||||||
// All locked songs are stored here
|
// All locked songs are stored here
|
||||||
vector<UnlockEntry> m_UnlockEntries;
|
vector<UnlockEntry> m_UnlockEntries;
|
||||||
|
|
||||||
// If global song or course points change, call to update
|
|
||||||
void UpdateCachedPointers();
|
|
||||||
|
|
||||||
void GetUnlocksByType( UnlockRewardType t, vector<UnlockEntry *> &apEntries );
|
void GetUnlocksByType( UnlockRewardType t, vector<UnlockEntry *> &apEntries );
|
||||||
void GetSongsUnlockedByEntryID( vector<Song *> &apSongsOut, RString sEntryID );
|
void GetSongsUnlockedByEntryID( vector<Song *> &apSongsOut, RString sEntryID );
|
||||||
void GetStepsUnlockedByEntryID( vector<Song *> &apSongsOut, vector<Difficulty> &apStepsOut, RString sEntryID );
|
void GetStepsUnlockedByEntryID( vector<Song *> &apSongsOut, vector<Difficulty> &apStepsOut, RString sEntryID );
|
||||||
|
|||||||
Reference in New Issue
Block a user