use SongID

This commit is contained in:
Glenn Maynard
2007-08-15 20:56:44 +00:00
parent 3509dfee03
commit 7729701678
6 changed files with 34 additions and 30 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ void ScreenUnlockCelebrate::Init()
g_iUnlockEntryIndexToCelebrate = UNLOCKMAN->GetUnlockEntryIndexToCelebrate(); g_iUnlockEntryIndexToCelebrate = UNLOCKMAN->GetUnlockEntryIndexToCelebrate();
UNLOCKMAN->UnlockEntryIndex( g_iUnlockEntryIndexToCelebrate ); UNLOCKMAN->UnlockEntryIndex( g_iUnlockEntryIndexToCelebrate );
Song* pSong = UNLOCKMAN->m_UnlockEntries[ g_iUnlockEntryIndexToCelebrate ].m_pSong; Song* pSong = UNLOCKMAN->m_UnlockEntries[ g_iUnlockEntryIndexToCelebrate ].m_Song.ToSong();
if( pSong ) if( pSong )
GAMESTATE->m_pCurSong.Set( pSong ); GAMESTATE->m_pCurSong.Set( pSong );
+4 -4
View File
@@ -48,7 +48,7 @@ void ScreenUnlockStatus::Init()
{ {
// get pertaining UnlockEntry // get pertaining UnlockEntry
const UnlockEntry &entry = UNLOCKMAN->m_UnlockEntries[i-1]; const UnlockEntry &entry = UNLOCKMAN->m_UnlockEntries[i-1];
const Song *pSong = entry.m_pSong; const Song *pSong = entry.m_Song.ToSong();
if( pSong == NULL) if( pSong == NULL)
continue; continue;
@@ -104,7 +104,7 @@ void ScreenUnlockStatus::Init()
{ {
case UnlockRewardType_Song: case UnlockRewardType_Song:
{ {
const Song *pSong = entry.m_pSong; const Song *pSong = entry.m_Song.ToSong();
ASSERT( pSong ); ASSERT( pSong );
RString title = pSong->GetDisplayMainTitle(); RString title = pSong->GetDisplayMainTitle();
@@ -139,7 +139,7 @@ void ScreenUnlockStatus::Init()
else else
{ {
// unlocked. change color // unlocked. change color
const Song *pSong = entry.m_pSong; const Song *pSong = entry.m_Song.ToSong();
RageColor color = RageColor(1,1,1,1); RageColor color = RageColor(1,1,1,1);
if( pSong ) if( pSong )
color = SONGMAN->GetSongGroupColor(pSong->m_sGroupName); color = SONGMAN->GetSongGroupColor(pSong->m_sGroupName);
@@ -228,7 +228,7 @@ void ScreenUnlockStatus::Init()
unsigned NextIcon = LastUnlocks[LastUnlocks.size() - i]; unsigned NextIcon = LastUnlocks[LastUnlocks.size() - i];
const UnlockEntry &entry = UNLOCKMAN->m_UnlockEntries[NextIcon-1]; const UnlockEntry &entry = UNLOCKMAN->m_UnlockEntries[NextIcon-1];
const Song *pSong = entry.m_pSong; const Song *pSong = entry.m_Song.ToSong();
if( pSong == NULL ) if( pSong == NULL )
continue; continue;
+2 -2
View File
@@ -1378,8 +1378,8 @@ void SongManager::UpdatePreferredSort()
FOREACH( UnlockEntry, UNLOCKMAN->m_UnlockEntries, ue ) FOREACH( UnlockEntry, UNLOCKMAN->m_UnlockEntries, ue )
{ {
if( ue->m_Type == UnlockRewardType_Song ) if( ue->m_Type == UnlockRewardType_Song )
if( ue->m_pSong ) if( ue->m_Song.ToSong() )
vpUnlockSongs.push_back( ue->m_pSong ); vpUnlockSongs.push_back( ue->m_Song.ToSong() );
} }
FOREACH( SongPointerVector, m_vPreferredSongSort, v ) FOREACH( SongPointerVector, m_vPreferredSongSort, v )
+1 -1
View File
@@ -927,7 +927,7 @@ RString SongID::ToString() const
bool SongID::IsValid() const bool SongID::IsValid() const
{ {
return !sDir.empty(); return ToSong() != NULL;
} }
// lua start // lua start
+24 -20
View File
@@ -193,7 +193,7 @@ bool UnlockManager::ModifierIsLocked( const RString &sOneMod ) const
const UnlockEntry *UnlockManager::FindSong( const Song *pSong ) const const UnlockEntry *UnlockManager::FindSong( const Song *pSong ) const
{ {
FOREACH_CONST( UnlockEntry, m_UnlockEntries, e ) FOREACH_CONST( UnlockEntry, m_UnlockEntries, e )
if( e->m_pSong == pSong && e->m_dc == Difficulty_Invalid ) if( e->m_Song.ToSong() == pSong && e->m_dc == Difficulty_Invalid )
return &(*e); return &(*e);
return NULL; return NULL;
} }
@@ -202,7 +202,7 @@ const UnlockEntry *UnlockManager::FindSteps( const Song *pSong, const Steps *pSt
{ {
ASSERT( pSong && pSteps ); ASSERT( pSong && pSteps );
FOREACH_CONST( UnlockEntry, m_UnlockEntries, e ) FOREACH_CONST( UnlockEntry, m_UnlockEntries, e )
if( e->m_pSong == pSong && e->m_dc == pSteps->GetDifficulty() ) if( e->m_Song.ToSong() == pSong && e->m_dc == pSteps->GetDifficulty() )
return &(*e); return &(*e);
return NULL; return NULL;
} }
@@ -310,10 +310,10 @@ bool UnlockEntry::IsValid() const
switch( m_Type ) switch( m_Type )
{ {
case UnlockRewardType_Song: case UnlockRewardType_Song:
return m_pSong != NULL; return m_Song.IsValid();
case UnlockRewardType_Steps: case UnlockRewardType_Steps:
return m_pSong != NULL && m_dc != Difficulty_Invalid; return m_Song.IsValid() && m_dc != Difficulty_Invalid;
case UnlockRewardType_Course: case UnlockRewardType_Course:
return m_pCourse != NULL; return m_pCourse != NULL;
@@ -339,17 +339,18 @@ UnlockEntryStatus UnlockEntry::GetUnlockEntryStatus() const
if( m_fRequirement[i] && fScores[i] >= m_fRequirement[i] ) if( m_fRequirement[i] && fScores[i] >= m_fRequirement[i] )
return UnlockEntryStatus_RequirementsMet; return UnlockEntryStatus_RequirementsMet;
if( m_bRequirePassHardSteps && m_pSong ) if( m_bRequirePassHardSteps && m_Song.IsValid() )
{ {
Song *pSong = m_Song.ToSong();
vector<Steps*> vp; vector<Steps*> vp;
SongUtil::GetSteps( SongUtil::GetSteps(
m_pSong, pSong,
vp, vp,
StepsType_Invalid, StepsType_Invalid,
Difficulty_Hard Difficulty_Hard
); );
FOREACH_CONST( Steps*, vp, s ) FOREACH_CONST( Steps*, vp, s )
if( PROFILEMAN->GetMachineProfile()->HasPassedSteps( m_pSong, *s ) ) if( PROFILEMAN->GetMachineProfile()->HasPassedSteps(pSong, *s) )
return UnlockEntryStatus_RequirementsMet; return UnlockEntryStatus_RequirementsMet;
} }
@@ -359,15 +360,16 @@ UnlockEntryStatus UnlockEntry::GetUnlockEntryStatus() const
RString UnlockEntry::GetDescription() const RString UnlockEntry::GetDescription() const
{ {
Song *pSong = m_Song.ToSong();
switch( m_Type ) switch( m_Type )
{ {
default: default:
ASSERT(0); ASSERT(0);
return ""; return "";
case UnlockRewardType_Song: case UnlockRewardType_Song:
return m_pSong ? m_pSong->GetDisplayFullTitle() : ""; return pSong ? pSong->GetDisplayFullTitle() : "";
case UnlockRewardType_Steps: case UnlockRewardType_Steps:
return (m_pSong ? m_pSong->GetDisplayFullTitle() : "") + ", " + DifficultyToLocalizedString( m_dc ); return (pSong ? pSong->GetDisplayFullTitle() : "") + ", " + DifficultyToLocalizedString( m_dc );
case UnlockRewardType_Course: case UnlockRewardType_Course:
return m_pCourse ? m_pCourse->GetDisplayFullTitle() : ""; return m_pCourse ? m_pCourse->GetDisplayFullTitle() : "";
case UnlockRewardType_Modifier: case UnlockRewardType_Modifier:
@@ -377,6 +379,7 @@ RString UnlockEntry::GetDescription() const
RString UnlockEntry::GetBannerFile() const RString UnlockEntry::GetBannerFile() const
{ {
Song *pSong = m_Song.ToSong();
switch( m_Type ) switch( m_Type )
{ {
default: default:
@@ -384,7 +387,7 @@ RString UnlockEntry::GetBannerFile() const
return ""; return "";
case UnlockRewardType_Song: case UnlockRewardType_Song:
case UnlockRewardType_Steps: case UnlockRewardType_Steps:
return m_pSong ? m_pSong->GetBannerPath() : ""; return pSong ? pSong->GetBannerPath() : "";
case UnlockRewardType_Course: case UnlockRewardType_Course:
return m_pCourse ? m_pCourse->GetBannerPath() : ""; return m_pCourse ? m_pCourse->GetBannerPath() : "";
case UnlockRewardType_Modifier: case UnlockRewardType_Modifier:
@@ -394,6 +397,7 @@ RString UnlockEntry::GetBannerFile() const
RString UnlockEntry::GetBackgroundFile() const RString UnlockEntry::GetBackgroundFile() const
{ {
Song *pSong = m_Song.ToSong();
switch( m_Type ) switch( m_Type )
{ {
default: default:
@@ -401,7 +405,7 @@ RString UnlockEntry::GetBackgroundFile() const
return ""; return "";
case UnlockRewardType_Song: case UnlockRewardType_Song:
case UnlockRewardType_Steps: case UnlockRewardType_Steps:
return m_pSong ? m_pSong->GetBackgroundPath() : ""; return pSong ? pSong->GetBackgroundPath() : "";
case UnlockRewardType_Course: case UnlockRewardType_Course:
return ""; return "";
case UnlockRewardType_Modifier: case UnlockRewardType_Modifier:
@@ -493,7 +497,7 @@ void UnlockManager::Load()
str += ssprintf( "entryID = %s ", e->m_sEntryID.c_str() ); str += ssprintf( "entryID = %s ", e->m_sEntryID.c_str() );
str += e->IsLocked()? "locked":"unlocked"; str += e->IsLocked()? "locked":"unlocked";
if( e->m_pSong ) if( e->m_Song.IsValid() )
str += ( " (found song)" ); str += ( " (found song)" );
if( e->m_pCourse ) if( e->m_pCourse )
str += ( " (found course)" ); str += ( " (found course)" );
@@ -538,13 +542,13 @@ void UnlockManager::UpdateCachedPointers()
switch( e->m_Type ) switch( e->m_Type )
{ {
case UnlockRewardType_Song: case UnlockRewardType_Song:
e->m_pSong = SONGMAN->FindSong( e->m_cmd.GetArg(0).s ); e->m_Song.FromSong( SONGMAN->FindSong( e->m_cmd.GetArg(0).s ) );
if( e->m_pSong == NULL ) if( !e->m_Song.IsValid() )
LOG->Warn( "Unlock: Cannot find song matching \"%s\"", e->m_cmd.GetArg(0).s.c_str() ); LOG->Warn( "Unlock: Cannot find song matching \"%s\"", e->m_cmd.GetArg(0).s.c_str() );
break; break;
case UnlockRewardType_Steps: case UnlockRewardType_Steps:
e->m_pSong = SONGMAN->FindSong( e->m_cmd.GetArg(0).s ); e->m_Song.FromSong( SONGMAN->FindSong( e->m_cmd.GetArg(0).s ) );
if( e->m_pSong == NULL ) if( !e->m_Song.IsValid() )
{ {
LOG->Warn( "Unlock: Cannot find song matching \"%s\"", e->m_cmd.GetArg(0).s.c_str() ); LOG->Warn( "Unlock: Cannot find song matching \"%s\"", e->m_cmd.GetArg(0).s.c_str() );
break; break;
@@ -594,8 +598,8 @@ void UnlockManager::PreferUnlockEntryID( RString sUnlockEntryID )
if( pEntry.m_sEntryID != sUnlockEntryID ) if( pEntry.m_sEntryID != sUnlockEntryID )
continue; continue;
if( pEntry.m_pSong != NULL ) if( pEntry.m_Song.ToSong() != NULL )
GAMESTATE->m_pPreferredSong = pEntry.m_pSong; GAMESTATE->m_pPreferredSong = pEntry.m_Song.ToSong();
if( pEntry.m_pCourse != NULL ) if( pEntry.m_pCourse != NULL )
GAMESTATE->m_pPreferredCourse = pEntry.m_pCourse; GAMESTATE->m_pPreferredCourse = pEntry.m_pCourse;
} }
@@ -646,7 +650,7 @@ void UnlockManager::GetSongsUnlockedByEntryID( vector<Song *> &apSongsOut, RStri
for( unsigned i = 0; i < apEntries.size(); ++i ) for( unsigned i = 0; i < apEntries.size(); ++i )
if( apEntries[i]->m_sEntryID == sUnlockEntryID ) if( apEntries[i]->m_sEntryID == sUnlockEntryID )
apSongsOut.push_back( apEntries[i]->m_pSong ); apSongsOut.push_back( apEntries[i]->m_Song.ToSong() );
} }
void UnlockManager::GetStepsUnlockedByEntryID( vector<Song *> &apSongsOut, vector<Difficulty> &apDifficultyOut, RString sUnlockEntryID ) void UnlockManager::GetStepsUnlockedByEntryID( vector<Song *> &apSongsOut, vector<Difficulty> &apDifficultyOut, RString sUnlockEntryID )
@@ -658,7 +662,7 @@ void UnlockManager::GetStepsUnlockedByEntryID( vector<Song *> &apSongsOut, vecto
{ {
if( apEntries[i]->m_sEntryID == sUnlockEntryID ) if( apEntries[i]->m_sEntryID == sUnlockEntryID )
{ {
apSongsOut.push_back( apEntries[i]->m_pSong ); apSongsOut.push_back( apEntries[i]->m_Song.ToSong() );
apDifficultyOut.push_back( apEntries[i]->m_dc ); apDifficultyOut.push_back( apEntries[i]->m_dc );
} }
} }
+2 -2
View File
@@ -7,6 +7,7 @@
#include "Command.h" #include "Command.h"
#include <set> #include <set>
#include "Difficulty.h" #include "Difficulty.h"
#include "SongUtil.h"
class Song; class Song;
class Course; class Course;
@@ -54,7 +55,6 @@ public:
{ {
m_Type = UnlockRewardType_Invalid; m_Type = UnlockRewardType_Invalid;
m_pSong = NULL;
m_dc = Difficulty_Invalid; m_dc = Difficulty_Invalid;
m_pCourse = NULL; m_pCourse = NULL;
@@ -69,7 +69,7 @@ public:
/* A cached pointer to the song or course this entry refers to. Only one of /* A cached pointer to the song or course this entry refers to. Only one of
* these will be non-NULL. */ * these will be non-NULL. */
Song *m_pSong; SongID m_Song;
Difficulty m_dc; Difficulty m_dc;
Course *m_pCourse; Course *m_pCourse;