From 8e3a14f516dbcf0dc55819abfe68e5ceb230fdcb Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sun, 16 Feb 2003 23:54:30 +0000 Subject: [PATCH] Still fixing brokenness in Nonstop, Oni, Endless... --- stepmania/Courses/PlayersBest1-4.crs | 2 +- stepmania/Courses/PlayersBest5-8.crs | 2 +- stepmania/Courses/PlayersBest9-12.crs | 2 +- .../{Tricky.crs => TrickyRandomNonstop.crs} | 2 +- stepmania/Courses/TrickyRandomOni.crs | 6 + stepmania/src/Course.cpp | 130 +++++++++++++----- stepmania/src/Course.h | 16 +-- stepmania/src/MusicWheel.cpp | 3 + stepmania/src/SongManager.cpp | 5 + stepmania/src/SongManager.h | 2 + stepmania/src/StepMania.dsp | 6 +- 11 files changed, 121 insertions(+), 55 deletions(-) rename stepmania/Courses/{Tricky.crs => TrickyRandomNonstop.crs} (81%) create mode 100644 stepmania/Courses/TrickyRandomOni.crs diff --git a/stepmania/Courses/PlayersBest1-4.crs b/stepmania/Courses/PlayersBest1-4.crs index 8804f4aca0..d850dcb8c5 100644 --- a/stepmania/Courses/PlayersBest1-4.crs +++ b/stepmania/Courses/PlayersBest1-4.crs @@ -1,4 +1,4 @@ -#COURSE:Players Best 1-4; +#COURSE:Players Best 1-4; #SONG:PlayersBest1:TRICK; #SONG:PlayersBest2:TRICK; #SONG:PlayersBest3:TRICK; diff --git a/stepmania/Courses/PlayersBest5-8.crs b/stepmania/Courses/PlayersBest5-8.crs index 70e840f906..7d6301ca79 100644 --- a/stepmania/Courses/PlayersBest5-8.crs +++ b/stepmania/Courses/PlayersBest5-8.crs @@ -1,4 +1,4 @@ -#COURSE:Players Best 5-8; +#COURSE:Players Best 5-8; #SONG:PlayersBest5:TRICK; #SONG:PlayersBest6:TRICK; #SONG:PlayersBest7:TRICK; diff --git a/stepmania/Courses/PlayersBest9-12.crs b/stepmania/Courses/PlayersBest9-12.crs index ce0f78aabf..c1f96ffca9 100644 --- a/stepmania/Courses/PlayersBest9-12.crs +++ b/stepmania/Courses/PlayersBest9-12.crs @@ -1,4 +1,4 @@ -#COURSE:Players Best 9-12; +#COURSE:Players Best 9-12; #SONG:PlayersBest9:TRICK; #SONG:PlayersBest10:TRICK; #SONG:PlayersBest11:TRICK; diff --git a/stepmania/Courses/Tricky.crs b/stepmania/Courses/TrickyRandomNonstop.crs similarity index 81% rename from stepmania/Courses/Tricky.crs rename to stepmania/Courses/TrickyRandomNonstop.crs index dbbcecf32f..c1815b759a 100644 --- a/stepmania/Courses/Tricky.crs +++ b/stepmania/Courses/TrickyRandomNonstop.crs @@ -1,4 +1,4 @@ -#COURSE:Tricky; +#COURSE:Tricky Random; #SONG:*:TRICK:1.5x,reverse; #SONG:*:TRICK:expand; #SONG:*:TRICK:0.25x,dark; diff --git a/stepmania/Courses/TrickyRandomOni.crs b/stepmania/Courses/TrickyRandomOni.crs new file mode 100644 index 0000000000..76dfc84c3f --- /dev/null +++ b/stepmania/Courses/TrickyRandomOni.crs @@ -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; diff --git a/stepmania/src/Course.cpp b/stepmania/src/Course.cpp index c167b7e508..eb4fcbf23e 100644 --- a/stepmania/src/Course.cpp +++ b/stepmania/src/Course.cpp @@ -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 &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 '/*'.", + 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 '/'.", + 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 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 &apCourses ) diff --git a/stepmania/src/Course.h b/stepmania/src/Course.h index d3c548a263..819d377b5b 100644 --- a/stepmania/src/Course.h +++ b/stepmania/src/Course.h @@ -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; }; diff --git a/stepmania/src/MusicWheel.cpp b/stepmania/src/MusicWheel.cpp index 9b47f9a943..4c435a975e 100644 --- a/stepmania/src/MusicWheel.cpp +++ b/stepmania/src/MusicWheel.cpp @@ -442,6 +442,8 @@ void MusicWheel::BuildWheelItemDatas( vector &arrayWheelItemDatas default: ASSERT(0); } + SortCoursePointerArrayByDifficulty( apCourses ); + for( unsigned c=0; c &arrayWheelItemDatas if( pCourse->IsPlayableIn(GAMESTATE->GetCurrentStyleDef()->m_NotesType) ) arrayWheelItemDatas.push_back( WheelItemData(TYPE_COURSE, NULL, "", pCourse, pCourse->GetColor()) ); } + } break; default: diff --git a/stepmania/src/SongManager.cpp b/stepmania/src/SongManager.cpp index d2260239bb..1a2c8d7bff 100644 --- a/stepmania/src/SongManager.cpp +++ b/stepmania/src/SongManager.cpp @@ -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 diff --git a/stepmania/src/SongManager.h b/stepmania/src/SongManager.h index ecbd225786..a83dc128c8 100644 --- a/stepmania/src/SongManager.h +++ b/stepmania/src/SongManager.h @@ -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 ); diff --git a/stepmania/src/StepMania.dsp b/stepmania/src/StepMania.dsp index b771b7eab2..cfe4dffbb7 100644 --- a/stepmania/src/StepMania.dsp +++ b/stepmania/src/StepMania.dsp @@ -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"