From e9070532fa6432ad176c48499378c6663da2769c Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 17 Apr 2004 01:47:55 +0000 Subject: [PATCH] Only slide duplicate difficulties when loading BMS files; in other cases, just move the duplicates to EDIT. This should fix the common glitch of users with eg. two beginner steps for a song having all difficulties bumped up; instead, just move the extra step to an edit. --- stepmania/src/NotesLoaderBMS.cpp | 32 ++++++++++++++ stepmania/src/NotesLoaderBMS.h | 5 ++- stepmania/src/Song.cpp | 71 +++++++++++++++++++------------- stepmania/src/song.h | 4 ++ 4 files changed, 82 insertions(+), 30 deletions(-) diff --git a/stepmania/src/NotesLoaderBMS.cpp b/stepmania/src/NotesLoaderBMS.cpp index 6e20fe5d00..e31d177eb7 100644 --- a/stepmania/src/NotesLoaderBMS.cpp +++ b/stepmania/src/NotesLoaderBMS.cpp @@ -430,6 +430,8 @@ bool BMSLoader::LoadFromDir( CString sDir, Song &out ) delete pNewNotes; } + SlideDuplicateDifficulties( out ); + CString sPath = out.GetSongDir() + arrayBMSFileNames[0]; RageFile file(sPath); @@ -703,3 +705,33 @@ bool BMSLoader::LoadFromDir( CString sDir, Song &out ) } +void BMSLoader::SlideDuplicateDifficulties( Song &p ) +{ + /* BMS files have to guess the Difficulty from the meter; this is inaccurate, + * and often leads to duplicates. Slide duplicate difficulties upwards. We + * only do this with BMS files, since a very common bug was having *all* + * difficulties slid upwards due to (for example) having two beginner steps. + * We do a second pass in Song::TidyUpData to eliminate any remaining duplicates + * after this. */ + for( int i=0; i vSteps; + p.GetSteps( vSteps, st, dc ); + + SortNotesArrayByDifficulty( vSteps ); + for( unsigned k=1; kSetDifficulty( dc2 ); + } + } + } +} diff --git a/stepmania/src/NotesLoaderBMS.h b/stepmania/src/NotesLoaderBMS.h index d34adba35e..8137c0f97c 100644 --- a/stepmania/src/NotesLoaderBMS.h +++ b/stepmania/src/NotesLoaderBMS.h @@ -5,13 +5,16 @@ #include "Steps.h" #include "NotesLoader.h" -class BMSLoader: public NotesLoader { +class BMSLoader: public NotesLoader +{ bool LoadFromBMSFile( const CString &sPath, Steps &out1 ); void mapBMSTrackToDanceNote( int iBMSTrack, int &iDanceColOut, char &cNoteCharOut ); void PushTrackNumForMagic( int iTrackNum ); StepsType CheckTracksMagic( void ); void ResetTracksMagic( void ); + void SlideDuplicateDifficulties( Song &p ); + public: void GetApplicableFiles( CString sPath, CStringArray &out ); bool LoadFromDir( CString sDir, Song &out ); diff --git a/stepmania/src/Song.cpp b/stepmania/src/Song.cpp index 88fadc79da..6a7c8e4eb5 100644 --- a/stepmania/src/Song.cpp +++ b/stepmania/src/Song.cpp @@ -348,6 +348,7 @@ void Song::RevertFromDisk( bool bAllowNotesLoss ) PREFSMAN->m_bFastLoad = false; LoadFromSongDir( dir ); + /* XXX: reload edits? */ PREFSMAN->m_bFastLoad = OldVal; @@ -437,6 +438,45 @@ static void DeleteDuplicateSteps( Song *song, vector &vSteps ) } } +/* Make any duplicate difficulties edits. (Note that BMS files do a first pass + * on this; see BMSLoader::SlideDuplicateDifficulties.) */ +void Song::AdjustDuplicateSteps() +{ + for( int i=0; i vSteps; + this->GetSteps( vSteps, st, dc ); + + /* Delete steps that are completely identical. This happened due to a + * bug in an earlier version. */ + DeleteDuplicateSteps( this, vSteps ); + + CHECKPOINT; + SortNotesArrayByDifficulty( vSteps ); + CHECKPOINT; + for( unsigned k=1; kSetDifficulty( DIFFICULTY_EDIT ); + if( vSteps[k]->GetDescription() == "" ) + { + /* "Hard Edit" */ + CString EditName = Capitalize( DifficultyToString(dc) ) + " Edit"; + vSteps[k]->SetDescription( EditName ); + } + } + } + + /* XXX: Don't allow edits to have descriptions that look like regular difficulties. + * These are confusing, and they're ambiguous when passed to GetStepsByID. */ + } +} + /* Fix up song paths. If there's a leading "./", be sure to keep it: it's * a signal that the path is from the root directory, not the song directory. * Other than a leading "./", song paths must never contain "." or "..". */ @@ -747,35 +787,8 @@ void Song::TidyUpData() /* Don't allow multiple Steps of the same StepsType and Difficulty (except for edits). - * This happens a lot reading BMS files because they we have to guess - * the Difficulty from the meter. */ - for( i=0; i vSteps; - this->GetSteps( vSteps, st, dc ); - - /* Delete steps that are completely identical. This happened due to a - * bug in an earlier version. */ - DeleteDuplicateSteps( this, vSteps ); - - CHECKPOINT; - SortNotesArrayByDifficulty( vSteps ); - CHECKPOINT; - for( unsigned k=1; kSetDifficulty( dc2 ); - } - } - } + * We should be able to use difficulty names as unique identifiers for steps. */ + AdjustDuplicateSteps(); { /* Generated filename; this doesn't always point to a loadable file, diff --git a/stepmania/src/song.h b/stepmania/src/song.h index 1ac564744e..88bb99a7eb 100644 --- a/stepmania/src/song.h +++ b/stepmania/src/song.h @@ -203,6 +203,10 @@ public: void FreeAllLoadedFromProfiles(); bool WasLoadedFromProfile() const { return m_LoadedFromProfile != PROFILE_SLOT_INVALID; } + +private: + void AdjustDuplicateSteps(); // part of TidyUpData + CString GetUniqueSongDescription( StepsType st ); }; CString MakeSortString( CString s );