diff --git a/stepmania/src/NotesLoaderSM.cpp b/stepmania/src/NotesLoaderSM.cpp index 87f7458ddd..cd66950229 100644 --- a/stepmania/src/NotesLoaderSM.cpp +++ b/stepmania/src/NotesLoaderSM.cpp @@ -435,7 +435,6 @@ bool SMLoader::LoadEdit( CString sEditFilePath, ProfileSlot slot ) Steps* pNewNotes = new Steps; ASSERT( pNewNotes ); - pSong->m_apNotes.push_back( pNewNotes ); if( iNumParams < 7 ) { @@ -450,6 +449,15 @@ bool SMLoader::LoadEdit( CString sEditFilePath, ProfileSlot slot ) pNewNotes->SetLoadedFromProfile( slot ); pNewNotes->SetDifficulty( DIFFICULTY_EDIT ); + + if( pSong->IsEditAlreadyLoaded(pNewNotes) ) + { + LOG->Warn( "The edit file '%s' is a duplicate of another edit that was already loaded.", sEditFilePath.c_str() ); + SAFE_DELETE( pNewNotes ); + return false; + } + + pSong->m_apNotes.push_back( pNewNotes ); return true; // Only allow one Steps per edit file! } else diff --git a/stepmania/src/Song.cpp b/stepmania/src/Song.cpp index 26ee76bb20..4f3d44c346 100644 --- a/stepmania/src/Song.cpp +++ b/stepmania/src/Song.cpp @@ -948,11 +948,6 @@ Steps* Song::GetClosestNotes( StepsType nt, Difficulty dc ) const return pNotes; } -void Song::GetEdits( vector& arrayAddTo, StepsType nt ) const -{ -} - - /* Return whether the song is playable in the given style. */ bool Song::SongCompleteForStyle( const StyleDef *st ) const { @@ -1135,9 +1130,17 @@ bool Song::IsEasy( StepsType nt ) const bool Song::HasEdits( StepsType nt ) const { - vector vpNotes; - this->GetEdits( vpNotes, nt ); - return vpNotes.size() > 0; + for( unsigned i=0; im_StepsType == nt && + pSteps->GetDifficulty() == DIFFICULTY_EDIT ) + { + return true; + } + } + + return false; } Song::SelectionDisplay Song::GetDisplayed() const @@ -1329,6 +1332,24 @@ int Song::GetNumStepsLoadedFromProfile( ProfileSlot slot ) const return iCount; } +bool Song::IsEditAlreadyLoaded( Steps* pSteps ) const +{ + ASSERT( pSteps->GetDifficulty() == DIFFICULTY_EDIT ); + + for( unsigned i=0; iGetDifficulty() == DIFFICULTY_EDIT && + pOther->m_StepsType == pSteps->m_StepsType && + pOther->GetHash() == pSteps->GetHash() ) + { + return true; + } + } + + return false; +} + bool Song::HasSignificantBpmChangesOrStops() const { // Don't consider BPM changes that only are only for maintaining sync as diff --git a/stepmania/src/song.h b/stepmania/src/song.h index 69a5169c9c..31b120da53 100644 --- a/stepmania/src/song.h +++ b/stepmania/src/song.h @@ -191,7 +191,6 @@ public: Steps* GetStepsByMeter( StepsType nt, int iMeterLow, int iMeterHigh ) const; Steps* GetStepsByDescription( StepsType nt, CString sDescription ) const; Steps* GetClosestNotes( StepsType nt, Difficulty dc ) const; - void GetEdits( vector& arrayAddTo, StepsType nt ) const; bool IsEasy( StepsType nt ) const; bool HasEdits( StepsType nt ) const; SelectionDisplay GetDisplayed() const; @@ -206,6 +205,7 @@ public: void FreeAllLoadedFromProfiles(); bool WasLoadedFromProfile() const { return m_LoadedFromProfile != PROFILE_SLOT_INVALID; } int GetNumStepsLoadedFromProfile( ProfileSlot slot ) const; + bool IsEditAlreadyLoaded( Steps* pSteps ) const; private: void AdjustDuplicateSteps(); // part of TidyUpData