Course::pSong to SongID
This commit is contained in:
+20
-14
@@ -60,6 +60,7 @@ const int MAX_BOTTOM_RANGE = 10;
|
||||
RString CourseEntry::GetTextDescription() const
|
||||
{
|
||||
vector<RString> vsEntryDescription;
|
||||
Song *pSong = songID.ToSong();
|
||||
if( pSong )
|
||||
vsEntryDescription.push_back( pSong->GetTranslitFullTitle() );
|
||||
else
|
||||
@@ -105,8 +106,8 @@ class LunaCourseEntry: public Luna<CourseEntry>
|
||||
public:
|
||||
static int GetSong( T* p, lua_State *L )
|
||||
{
|
||||
if( p->pSong )
|
||||
p->pSong->PushSelf(L);
|
||||
if( p->songID.ToSong() )
|
||||
p->songID.ToSong()->PushSelf(L);
|
||||
else
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
@@ -232,10 +233,11 @@ bool Course::IsPlayableIn( StepsType st ) const
|
||||
{
|
||||
SongCriteria soc = e->songCriteria;
|
||||
|
||||
if( e->pSong )
|
||||
Song *pSong = e->songID.ToSong();
|
||||
if( pSong )
|
||||
{
|
||||
soc.m_bUseSongAllowedList = true;
|
||||
soc.m_vpSongAllowedList.push_back( e->pSong );
|
||||
soc.m_vpSongAllowedList.push_back( pSong );
|
||||
}
|
||||
soc.m_Tutorial = SongCriteria::Tutorial_No;
|
||||
soc.m_Locked = SongCriteria::Locked_Unlocked;
|
||||
@@ -249,14 +251,14 @@ bool Course::IsPlayableIn( StepsType st ) const
|
||||
const bool bSameSongCriteria = e != m_vEntries.begin() && (e-1)->songCriteria == soc;
|
||||
const bool bSameStepsCriteria = e != m_vEntries.begin() && (e-1)->stepsCriteria == stc;
|
||||
|
||||
if( e->pSong )
|
||||
if( pSong )
|
||||
{
|
||||
if ( StepsUtil::HasMatching(e->pSong, stc) )
|
||||
if( StepsUtil::HasMatching(pSong, stc) )
|
||||
return true;
|
||||
}
|
||||
else if( !(bSameSongCriteria && bSameStepsCriteria) )
|
||||
{
|
||||
if ( StepsUtil::HasMatching(soc, stc) )
|
||||
if( StepsUtil::HasMatching(soc, stc) )
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -495,10 +497,11 @@ bool Course::GetTrailUnsorted( StepsType st, CourseDifficulty cd, Trail &trail )
|
||||
SongAndSteps resolved; // fill this in
|
||||
SongCriteria soc = e->songCriteria;
|
||||
|
||||
if( e->pSong )
|
||||
Song *pSong = e->songID.ToSong();
|
||||
if( pSong )
|
||||
{
|
||||
soc.m_bUseSongAllowedList = true;
|
||||
soc.m_vpSongAllowedList.push_back( e->pSong );
|
||||
soc.m_vpSongAllowedList.push_back( pSong );
|
||||
}
|
||||
soc.m_Tutorial = SongCriteria::Tutorial_No;
|
||||
soc.m_Locked = SongCriteria::Locked_Unlocked;
|
||||
@@ -512,9 +515,9 @@ bool Course::GetTrailUnsorted( StepsType st, CourseDifficulty cd, Trail &trail )
|
||||
const bool bSameSongCriteria = e != entries.begin() && (e-1)->songCriteria == soc;
|
||||
const bool bSameStepsCriteria = e != entries.begin() && (e-1)->stepsCriteria == stc;
|
||||
|
||||
if( e->pSong )
|
||||
if( pSong )
|
||||
{
|
||||
StepsUtil::GetAllMatching( e->pSong, stc, vSongAndSteps );
|
||||
StepsUtil::GetAllMatching( pSong, stc, vSongAndSteps );
|
||||
}
|
||||
else if( vSongAndSteps.empty() || !(bSameSongCriteria && bSameStepsCriteria) )
|
||||
{
|
||||
@@ -749,7 +752,8 @@ void Course::Invalidate( const Song *pStaleSong )
|
||||
{
|
||||
FOREACH_CONST( CourseEntry, m_vEntries, e )
|
||||
{
|
||||
if( e->pSong == pStaleSong ) // a fixed entry that references the stale Song
|
||||
Song *pSong = e->songID.ToSong();
|
||||
if( pSong == pStaleSong ) // a fixed entry that references the stale Song
|
||||
{
|
||||
RevertFromDisk();
|
||||
return;
|
||||
@@ -876,7 +880,8 @@ void Course::UpdateCourseStats( StepsType st )
|
||||
// courses with random/players best-worst songs should go at the end
|
||||
for(unsigned i = 0; i < m_vEntries.size(); i++)
|
||||
{
|
||||
if ( m_vEntries[i].pSong != NULL )
|
||||
Song *pSong = m_vEntries[i].songID.ToSong();
|
||||
if( pSong != NULL )
|
||||
continue;
|
||||
|
||||
if ( m_SortOrder_Ranking == 2 )
|
||||
@@ -916,7 +921,8 @@ const CourseEntry *Course::FindFixedSong( const Song *pSong ) const
|
||||
FOREACH_CONST( CourseEntry, m_vEntries, e )
|
||||
{
|
||||
const CourseEntry &entry = *e;
|
||||
if( entry.pSong == pSong )
|
||||
Song *pSong = entry.songID.ToSong();
|
||||
if( pSong == pSong )
|
||||
return &entry;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,8 +57,7 @@ public:
|
||||
bool bSecret; // show "??????" instead of an exact song
|
||||
|
||||
// filter criteria, applied from top to bottom
|
||||
// TODO: change this to be a SongID
|
||||
Song* pSong; // don't filter if NULL
|
||||
SongID songID; // don't filter if unset
|
||||
SongCriteria songCriteria;
|
||||
StepsCriteria stepsCriteria;
|
||||
bool bNoDifficult; // if true, CourseDifficulty doesn't affect this entry
|
||||
@@ -74,8 +73,6 @@ public:
|
||||
CourseEntry()
|
||||
{
|
||||
bSecret = false;
|
||||
|
||||
pSong = NULL;
|
||||
bNoDifficult = false;
|
||||
|
||||
songSort = SongSort_Randomize;
|
||||
@@ -86,7 +83,7 @@ public:
|
||||
iGainLives = -1;
|
||||
}
|
||||
|
||||
bool IsFixedSong() const { return pSong != NULL; }
|
||||
bool IsFixedSong() const { return songID.IsValid(); }
|
||||
|
||||
RString GetTextDescription() const;
|
||||
int GetNumModChanges() const;
|
||||
|
||||
@@ -196,17 +196,19 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
|
||||
vector<RString> bits;
|
||||
split( sSong, "/", bits );
|
||||
|
||||
Song *pSong = NULL;
|
||||
if( bits.size() == 2 )
|
||||
{
|
||||
new_entry.songCriteria.m_sGroupName = bits[0];
|
||||
new_entry.pSong = SONGMAN->FindSong( bits[0], bits[1] );
|
||||
pSong = SONGMAN->FindSong( bits[0], bits[1] );
|
||||
}
|
||||
else if( bits.size() == 1 )
|
||||
{
|
||||
new_entry.pSong = SONGMAN->FindSong( "", sSong );
|
||||
pSong = SONGMAN->FindSong( "", sSong );
|
||||
}
|
||||
new_entry.songID.FromSong( pSong );
|
||||
|
||||
if( new_entry.pSong == NULL )
|
||||
if( pSong == NULL )
|
||||
{
|
||||
LOG->UserLog( "Course file", sPath, "contains a fixed song entry \"%s\" that does not exist. "
|
||||
"This entry will be ignored.", sSong.c_str());
|
||||
|
||||
@@ -192,7 +192,7 @@ void CourseUtil::SortByMostRecentlyPlayedForMachine( vector<Course*> &vpCoursesI
|
||||
|
||||
void CourseUtil::MakeDefaultEditCourseEntry( CourseEntry& out )
|
||||
{
|
||||
out.pSong = GAMESTATE->GetDefaultSong();
|
||||
out.songID.FromSong( GAMESTATE->GetDefaultSong() );
|
||||
out.stepsCriteria.m_difficulty = Difficulty_Medium;
|
||||
}
|
||||
|
||||
@@ -286,7 +286,7 @@ void CourseUtil::AutogenOniFromArtist( const RString &sArtistName, RString sArti
|
||||
|
||||
for( unsigned i = 0; i < aSongs.size(); ++i )
|
||||
{
|
||||
e.pSong = aSongs[i];
|
||||
e.songID.FromSong( aSongs[i] );
|
||||
out.m_vEntries.push_back( e );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,9 +115,10 @@ bool CourseWriterCRS::Write( const Course &course, RageFileBasic &f, bool bSavin
|
||||
{
|
||||
f.Write( ssprintf( "#SONG:WORST%d", entry.iChooseIndex+1 ) );
|
||||
}
|
||||
else if( entry.pSong )
|
||||
else if( entry.songID.ToSong() )
|
||||
{
|
||||
const RString &sSong = Basename( entry.pSong->GetSongDir() );
|
||||
Song *pSong = entry.songID.ToSong();
|
||||
const RString &sSong = Basename( pSong->GetSongDir() );
|
||||
|
||||
f.Write( "#SONG:" );
|
||||
if( !entry.songCriteria.m_sGroupName.empty() )
|
||||
|
||||
@@ -1736,7 +1736,7 @@ void ScreenEdit::InputEdit( const InputEventPlus &input, EditButton EditB )
|
||||
bool bUsesThisSong = false;
|
||||
for( unsigned e = 0; e < crs->m_vEntries.size(); ++e )
|
||||
{
|
||||
if( crs->m_vEntries[e].pSong != m_pSong )
|
||||
if( crs->m_vEntries[e].songID.ToSong() != m_pSong )
|
||||
continue;
|
||||
bUsesThisSong = true;
|
||||
}
|
||||
@@ -2502,7 +2502,7 @@ void ScreenEdit::HandleScreenMessage( const ScreenMessage SM )
|
||||
int iCourseEntryIndex = -1;
|
||||
FOREACH_CONST( CourseEntry, pCourse->m_vEntries, i )
|
||||
{
|
||||
if( i->pSong == GAMESTATE->m_pCurSong.Get() )
|
||||
if( i->songID.ToSong() == GAMESTATE->m_pCurSong.Get() )
|
||||
iCourseEntryIndex = i - pCourse->m_vEntries.begin();
|
||||
}
|
||||
|
||||
@@ -3487,7 +3487,7 @@ void ScreenEdit::SetupCourseAttacks()
|
||||
|
||||
for( unsigned e = 0; e < GAMESTATE->m_pCurCourse->m_vEntries.size(); ++e )
|
||||
{
|
||||
if( GAMESTATE->m_pCurCourse->m_vEntries[e].pSong != m_pSong )
|
||||
if( GAMESTATE->m_pCurCourse->m_vEntries[e].songID.ToSong() != m_pSong )
|
||||
continue;
|
||||
|
||||
Attacks = GAMESTATE->m_pCurCourse->m_vEntries[e].attacks;
|
||||
|
||||
@@ -39,7 +39,7 @@ void ScreenJukebox::SetSong()
|
||||
if( pCourse != NULL )
|
||||
for ( unsigned i = 0; i < pCourse->m_vEntries.size(); i++ )
|
||||
if( pCourse->m_vEntries[i].IsFixedSong() )
|
||||
vSongs.push_back( pCourse->m_vEntries[i].pSong );
|
||||
vSongs.push_back( pCourse->m_vEntries[i].songID.ToSong() );
|
||||
|
||||
if ( vSongs.size() == 0 )
|
||||
vSongs = SONGMAN->GetSongs( GAMESTATE->m_sPreferredSongGroup );
|
||||
|
||||
@@ -246,7 +246,8 @@ void ScreenOptionsEditCourse::ImportOptions( int iRow, const vector<PlayerNumber
|
||||
}
|
||||
else
|
||||
{
|
||||
vector<Song *>::const_iterator iter = find( m_vpDisplayedSongs.begin(), m_vpDisplayedSongs.end(), ce.pSong );
|
||||
Song *pSong = ce.songID.ToSong();
|
||||
vector<Song *>::const_iterator iter = find( m_vpDisplayedSongs.begin(), m_vpDisplayedSongs.end(), pSong );
|
||||
|
||||
if( iter == m_vpDisplayedSongs.end() ) // This song isn't being displayed, set to "RANDOM"
|
||||
row.SetOneSharedSelection( 0 );
|
||||
@@ -288,9 +289,9 @@ void ScreenOptionsEditCourse::ExportOptions( int iRow, const vector<PlayerNumber
|
||||
CourseEntry& ce = pCourse->m_vEntries[iRow - NUM_EditCourseRow];
|
||||
|
||||
if( iSel == 0 )
|
||||
ce.pSong = NULL;
|
||||
ce.songID.FromSong( NULL );
|
||||
else
|
||||
ce.pSong = m_vpDisplayedSongs[iSel - 1];
|
||||
ce.songID.FromSong( m_vpDisplayedSongs[iSel - 1] );
|
||||
}
|
||||
|
||||
void ScreenOptionsEditCourse::ProcessMenuStart( const InputEventPlus &input )
|
||||
|
||||
@@ -237,7 +237,7 @@ void ScreenOptionsEditCourseEntry::HandleScreenMessage( const ScreenMessage SM )
|
||||
/* We can't rely on the trail here since it depends on what steps are available.
|
||||
* Use the course entry directly instead. */
|
||||
CourseEntry& ce = pCourse->m_vEntries[GAMESTATE->m_iEditCourseEntryIndex];
|
||||
Song *pSong = ce.pSong;
|
||||
Song *pSong = ce.songID.ToSong();
|
||||
Steps *pSteps;
|
||||
StepsType st = GAMESTATE->m_stEdit;
|
||||
CourseDifficulty cd = ( ce.stepsCriteria.m_difficulty == Difficulty_Invalid ?
|
||||
@@ -378,7 +378,7 @@ void ScreenOptionsEditCourseEntry::ImportOptions( int iRow, const vector<PlayerN
|
||||
break;
|
||||
case ROW_SONG:
|
||||
{
|
||||
GAMESTATE->m_pCurSong.Set( ce.pSong );
|
||||
GAMESTATE->m_pCurSong.Set( ce.songID.ToSong() );
|
||||
|
||||
// XXX: copy and pasted from ScreenOptionsMaster
|
||||
FOREACH_CONST( PlayerNumber, vpns, pn )
|
||||
@@ -466,7 +466,7 @@ void ScreenOptionsEditCourseEntry::ExportOptions( int iRow, const vector<PlayerN
|
||||
}
|
||||
row.ExportOptions( vpns, bRowHasFocus );
|
||||
|
||||
ce.pSong = GAMESTATE->m_pCurSong;
|
||||
ce.songID.FromSong( GAMESTATE->m_pCurSong );
|
||||
break;
|
||||
}
|
||||
case ROW_BASE_DIFFICULTY:
|
||||
|
||||
Reference in New Issue
Block a user