Move the rest of song searching logic into SONGMAN.

This commit is contained in:
Glenn Maynard
2003-07-22 05:45:30 +00:00
parent fdd00f5dd4
commit 71b2199fb2
5 changed files with 40 additions and 50 deletions
+6 -47
View File
@@ -66,35 +66,6 @@ void Course::SetDefaultScore()
}
}
/*
* GetSongDir() contains a path to the song, possibly a full path, eg:
* Songs\Group\SongName or
* My Other Song Folder\Group\SongName or
* c:\Corny J-pop\Group\SongName
*
* Most course group names are "Group\SongName", so we want to
* match against the last two elements. Let's also support
* "SongName" alone, since the group is only important when it's
* potentially ambiguous.
*
* Let's *not* support "Songs\Group\SongName" in course files.
* That's probably a common error, but that would result in
* course files floating around that only work for people who put
* songs in "Songs"; we don't want that.
*/
Song *Course::FindSong(CString sGroup, CString sSong) const
{
Song *pSong = SONGMAN->FindSong( sGroup, sSong );
if( pSong )
return pSong;
LOG->Trace( "Course file '%s' contains a song '%s%s%s' that is not present",
m_sPath.c_str(), sGroup.c_str(), sGroup.size()? "/":"", sSong.c_str());
return NULL;
}
PlayMode Course::GetPlayMode() const
{
if( IsNonstop() )
@@ -244,27 +215,15 @@ void Course::LoadFromCRSFile( CString sPath )
new_entry.type = Entry::fixed;
CString sSong = sParams[1];
sSong.Replace( "\\", "/" );
CStringArray bits;
split( sSong, "/", bits );
if( bits.size() == 1 )
new_entry.pSong = FindSong( "", bits[0] );
else if( bits.size() == 2 )
new_entry.pSong = FindSong( bits[0], bits[1] );
else
{
LOG->Warn( "Course file '%s' contains a fixed song entry '%s' that is invalid. "
"Song should be in the format '<group>/<song>'.",
m_sPath.c_str(), sSong.c_str());
continue; // skip this #SONG
}
if( !new_entry.pSong )
new_entry.pSong = SONGMAN->FindSong( sSong );
if( new_entry.pSong == NULL )
{
/* XXX: We need a place to put "user warnings". This is too loud for info.txt--
* it obscures important warnings--and regular users never look there, anyway. */
//LOG->Warn( "Course file '%s' contains a fixed song entry '%s' that does not exist. "
// "This entry will be ignored.",
// m_sPath.c_str(), sSong.c_str());
LOG->Trace( "Course file '%s' contains a fixed song entry '%s' that does not exist. "
"This entry will be ignored.",
m_sPath.c_str(), sSong.c_str());
continue; // skip this #SONG
}
}
-1
View File
@@ -122,7 +122,6 @@ public:
private:
Song *FindSong(CString sGroup, CString sSong) const;
void SetDefaultScore();
void GetMeterRange( int stage, int& iMeterLowOut, int& iMeterHighOut ) const;
};
+31
View File
@@ -1076,6 +1076,37 @@ void SongManager::AddScores( NotesType nt, bool bPlayerEnabled[NUM_PLAYERS],
}
}
/*
* GetSongDir() contains a path to the song, possibly a full path, eg:
* Songs\Group\SongName or
* My Other Song Folder\Group\SongName or
* c:\Corny J-pop\Group\SongName
*
* Most course group names are "Group\SongName", so we want to
* match against the last two elements. Let's also support
* "SongName" alone, since the group is only important when it's
* potentially ambiguous.
*
* Let's *not* support "Songs\Group\SongName" in course files.
* That's probably a common error, but that would result in
* course files floating around that only work for people who put
* songs in "Songs"; we don't want that.
*/
Song *SongManager::FindSong( CString sPath )
{
sPath.Replace( "\\", "/" );
CStringArray bits;
split( sPath, "/", bits );
if( bits.size() == 1 )
return FindSong( "", bits[0] );
else if( bits.size() == 2 )
return FindSong( bits[0], bits[1] );
return NULL;
}
Song *SongManager::FindSong( CString sGroup, CString sSong )
{
// foreach song
+2 -1
View File
@@ -67,7 +67,7 @@ public:
void GetSongs( vector<Song*> &AddTo, CString sGroupName, int iMaxStages = 100000 /*inf*/ ) const;
void GetSongs( vector<Song*> &AddTo, int iMaxStages ) const { GetSongs(AddTo,"",iMaxStages); }
void GetSongs( vector<Song*> &AddTo ) const { GetSongs(AddTo,"",100000 /*inf*/ ); }
Song *FindSong( CString sGroup, CString sSong );
Song *FindSong( CString sPath );
Course *FindCourse( CString sName );
int GetNumSongs() const;
int GetNumGroups() const;
@@ -120,6 +120,7 @@ protected:
void ReadCourseScoresFromFile( CString fn, int c );
void ReadCategoryRankingsFromFile( CString fn );
void ReadCourseRankingsFromFile( CString fn );
Song *FindSong( CString sGroup, CString sSong );
vector<Song*> m_pSongs; // all songs that can be played
vector<Song*> m_pBestSongs;
+1 -1
View File
@@ -333,7 +333,7 @@ void UnlockSystem::UpdateSongs()
{
m_SongEntries[i].m_pSong = NULL;
m_SongEntries[i].m_pCourse = NULL;
m_SongEntries[i].m_pSong = SONGMAN->FindSong( "", m_SongEntries[i].m_sSongName );
m_SongEntries[i].m_pSong = SONGMAN->FindSong( m_SongEntries[i].m_sSongName );
if( m_SongEntries[i].m_pSong == NULL )
m_SongEntries[i].m_pCourse = SONGMAN->FindCourse( m_SongEntries[i].m_sSongName );
}