Still fixing brokenness in Nonstop, Oni, Endless...

This commit is contained in:
Chris Danford
2003-02-16 23:54:30 +00:00
parent ac6af4624e
commit 8e3a14f516
11 changed files with 121 additions and 55 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
#COURSE:Players Best 1-4;
#COURSE:Players Best 1-4;
#SONG:PlayersBest1:TRICK;
#SONG:PlayersBest2:TRICK;
#SONG:PlayersBest3:TRICK;
+1 -1
View File
@@ -1,4 +1,4 @@
#COURSE:Players Best 5-8;
#COURSE:Players Best 5-8;
#SONG:PlayersBest5:TRICK;
#SONG:PlayersBest6:TRICK;
#SONG:PlayersBest7:TRICK;
+1 -1
View File
@@ -1,4 +1,4 @@
#COURSE:Players Best 9-12;
#COURSE:Players Best 9-12;
#SONG:PlayersBest9:TRICK;
#SONG:PlayersBest10:TRICK;
#SONG:PlayersBest11:TRICK;
@@ -1,4 +1,4 @@
#COURSE:Tricky;
#COURSE:Tricky Random;
#SONG:*:TRICK:1.5x,reverse;
#SONG:*:TRICK:expand;
#SONG:*:TRICK:0.25x,dark;
+6
View File
@@ -0,0 +1,6 @@
#COURSE:Tricky Random;
#LIVES:4;
#SONG:*:TRICK:1.5x,reverse;
#SONG:*:TRICK:expand;
#SONG:*:TRICK:0.25x,dark;
#SONG:*:TRICK:sudden,boost;
+92 -38
View File
@@ -68,45 +68,32 @@ Course::Course()
* songs in "Songs"; we don't want that.
*/
Song *Course::FindSong(CString sSongDir) const
Song *Course::FindSong(CString sGroup, CString sSong) const
{
const vector<Song*> &apSongs = SONGMAN->GetAllSongs();
CStringArray split_SongDir;
sSongDir.Replace("\\", "/");
split( sSongDir, "/", split_SongDir, true );
if( split_SongDir.size() > 2 )
{
LOG->Warn( "Course file \"%s\" path \"%s\" should contain "
"at most one backslash; ignored.",
m_sPath.GetString(), sSongDir.GetString());
return NULL;
}
// foreach song
for( unsigned i = 0; i < apSongs.size(); i++ )
{
CString dir = apSongs[i]->GetSongDir();
dir.Replace("\\", "/");
CStringArray splitted; /* splat! */
split( dir, "/", splitted, true );
bool matches = true;
int split_no = splitted.size()-1;
int SongDir_no = split_SongDir.size()-1;
Song* pSong = apSongs[i];
while( split_no >= 0 && SongDir_no >= 0 ) {
if( stricmp(splitted[split_no--], split_SongDir[SongDir_no--] ) )
matches=false;
if( sGroup.CompareNoCase(pSong->m_sGroupName) == 0)
{
CString sDir = pSong->GetSongDir();
sDir.Replace("\\","/");
CStringArray bits;
split( sDir, "/", bits );
CString sLastBit = bits[bits.size()-1];
CString sFullTitle = pSong->GetFullTranslitTitle();
if( sSong.CompareNoCase(sLastBit)==0 || sSong.CompareNoCase(sFullTitle)==0 ) // match on song dir or title (ala DWI)
return pSong;
}
if(matches)
return apSongs[i];
}
LOG->Trace( "Course \"%s\": couldn't match song \"%s\"",
m_sPath.GetString(), sSongDir.GetString());
LOG->Trace( "Course file '%s' contains a song '%s/%s' that is not present",
m_sPath.GetString(), sGroup.GetString(), sSong.GetString());
return NULL;
}
@@ -154,9 +141,9 @@ void Course::LoadFromCRSFile( CString sPath )
else if( 0 == stricmp(sValueName, "SONG") )
{
// infer entry::Type from the first param
Entry new_entry;
// infer entry::Type from the first param
if( sParams[1].Left(strlen("PlayersBest")) == "PlayersBest" )
{
new_entry.type = Entry::players_best;
@@ -176,15 +163,50 @@ void Course::LoadFromCRSFile( CString sPath )
else if( sParams[1].Right(1) == "*" )
{
new_entry.type = Entry::random_within_group;
CString sThrowAway;
splitrelpath( sParams[1], new_entry.group_name, sThrowAway, sThrowAway );
new_entry.group_name.resize( new_entry.group_name.size()-1 ); // chomp triling slash
CString sSong = sParams[1];
sSong.Replace( "\\", "/" );
CStringArray bits;
split( sSong, "/", bits );
if( bits.size() == 2 )
new_entry.group_name = bits[0];
else
LOG->Warn( "Course file '%s' contains a random_within_group entry '%s' that is invalid. "
"Song should be in the format '<group>/*'.",
m_sPath.GetString(), sSong.GetString());
if( !SONGMAN->DoesGroupExist(new_entry.group_name) )
{
LOG->Warn( "Course file '%s' random_within_group entry '%s' specifies a group that doesn't exist. "
"This entry will be ignored.",
m_sPath.GetString(), sSong.GetString());
continue; // skip this #SONG
}
}
else
{
new_entry.type = Entry::fixed;
CString sThrowAway;
splitrelpath( sParams[1], new_entry.group_name, new_entry.song_name, sThrowAway );
CString sSong = sParams[1];
sSong.Replace( "\\", "/" );
CStringArray bits;
split( sSong, "/", bits );
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.GetString(), sSong.GetString());
continue; // skip this #SONG
}
if( !new_entry.pSong )
{
LOG->Warn( "Course file '%s' contains a fixed song entry '%s' that does not exist. "
"This entry will be ignored.",
m_sPath.GetString(), sSong.GetString());
continue; // skip this #SONG
}
}
new_entry.difficulty = StringToDifficulty( sParams[2] );
@@ -289,12 +311,26 @@ void Course::GetStageInfo(
vector<Song*> vSongsByMostPlayed = SONGMAN->GetAllSongs();
SortSongPointerArrayByMostPlayed( vSongsByMostPlayed );
// filter out songs that don't have both medium and hard steps
for( int j=vSongsByMostPlayed.size()-1; j>=0; j-- )
{
Song* pSong = vSongsByMostPlayed[j];
if( !pSong->GetNotes(nt, DIFFICULTY_MEDIUM) || !pSong->GetNotes(nt, DIFFICULTY_HARD) )
vSongsByMostPlayed.erase( vSongsByMostPlayed.begin()+j );
}
switch( e.type )
{
case Entry::fixed:
pSong = SONGMAN->GetSongFromDir( e.group_name + "/" + e.song_name );
pSong = e.pSong;
if( pSong )
{
if( e.difficulty == DIFFICULTY_INVALID )
pNotes = pSong->GetNotes( nt, e.low_meter, e.high_meter );
else
pNotes = pSong->GetNotes( nt, e.difficulty );
}
break;
case Entry::random:
case Entry::random_within_group:
@@ -541,7 +577,25 @@ void Course::AddScores( NotesType nt, bool bPlayerEnabled[NUM_PLAYERS], int iDan
//
static bool CompareCoursePointersByDifficulty(const Course* pCourse1, const Course* pCourse2)
{
return pCourse1->GetEstimatedNumStages() < pCourse2->GetEstimatedNumStages();
int iNum1 = pCourse1->GetEstimatedNumStages();
int iNum2 = pCourse2->GetEstimatedNumStages();
if( iNum1 < iNum2 )
return true;
else if( iNum1 > iNum2 )
return false;
else // iNum1 == iNum2
{
// HACK: strcmp and other string comparators appear to eat whitespace.
// For example, the string "Players Best 13-16" is sorted between
// "Players Best 1-4" and "Players Best 5-8". Replace the string " "
// with " 0" for comparison only.
CString sName1 = pCourse1->m_sName;
CString sName2 = pCourse2->m_sName;
sName1.Replace( " " , " 0" );
sName2.Replace( " " , " 0" );
return sName1.CompareNoCase( sName2 ) == -1;
}
}
void SortCoursePointerArrayByDifficulty( vector<Course*> &apCourses )
+8 -8
View File
@@ -22,13 +22,13 @@ class Course
{
struct Entry {
enum Type { fixed, random, random_within_group, players_best, players_worst } type;
CString group_name;
CString song_name; // the name of the song folder
Difficulty difficulty; // = DIFFICULTY_INVALID if no difficulty specified
int low_meter; // = -1 if no meter range specified
int high_meter; // = -1 if no meter range specified
int players_index; // ignored if type isn't a players_*
CString modifiers; // set player and song options using these
Song* pSong; // used in type=fixed
CString group_name; // used in type=random_within_group
Difficulty difficulty; // = DIFFICULTY_INVALID if no difficulty specified
int low_meter; // = -1 if no meter range specified
int high_meter; // = -1 if no meter range specified
int players_index; // ignored if type isn't a players_*
CString modifiers; // set player and song options using these
Entry()
{
@@ -98,7 +98,7 @@ public:
private:
Song *FindSong(CString sSongDir) const;
Song *FindSong(CString sGroup, CString sSong) const;
};
+3
View File
@@ -442,6 +442,8 @@ void MusicWheel::BuildWheelItemDatas( vector<WheelItemData> &arrayWheelItemDatas
default: ASSERT(0);
}
SortCoursePointerArrayByDifficulty( apCourses );
for( unsigned c=0; c<apCourses.size(); c++ ) // foreach course
{
Course* pCourse = apCourses[c];
@@ -450,6 +452,7 @@ void MusicWheel::BuildWheelItemDatas( vector<WheelItemData> &arrayWheelItemDatas
if( pCourse->IsPlayableIn(GAMESTATE->GetCurrentStyleDef()->m_NotesType) )
arrayWheelItemDatas.push_back( WheelItemData(TYPE_COURSE, NULL, "", pCourse, pCourse->GetColor()) );
}
}
break;
default:
+5
View File
@@ -519,6 +519,11 @@ void SongManager::GetGroupNames( CStringArray &AddTo )
AddTo.insert(AddTo.end(), m_arrayGroupNames.begin(), m_arrayGroupNames.end() );
}
bool SongManager::DoesGroupExist( CString sGroupName )
{
return find( m_arrayGroupNames.begin(), m_arrayGroupNames.end(), sGroupName ) != m_arrayGroupNames.end();
}
RageColor SongManager::GetGroupColor( const CString &sGroupName )
{
// search for the group index
+2
View File
@@ -33,6 +33,8 @@ public:
CString GetGroupBannerPath( CString sGroupName );
void GetGroupNames( CStringArray &AddTo );
bool DoesGroupExist( CString sGroupName );
RageColor GetGroupColor( const CString &sGroupName );
RageColor GetSongColor( const Song* pSong );
RageColor GetDifficultyColor( Difficulty dc );
+1 -5
View File
@@ -195,10 +195,6 @@ SOURCE=.\RageInput.cpp
# End Source File
# Begin Source File
SOURCE=.\RageInput.cpp
# End Source File
# Begin Source File
SOURCE=.\RageInputDevice.cpp
# End Source File
# Begin Source File
@@ -799,7 +795,7 @@ SOURCE=.\ScreenDimensions.h
# End Source File
# Begin Source File
SOURCE=.\globla.cpp
SOURCE=.\global.cpp
!IF "$(CFG)" == "StepMania - Win32 Release"