don't load duplicate edits
This commit is contained in:
@@ -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
|
||||
|
||||
+29
-8
@@ -948,11 +948,6 @@ Steps* Song::GetClosestNotes( StepsType nt, Difficulty dc ) const
|
||||
return pNotes;
|
||||
}
|
||||
|
||||
void Song::GetEdits( vector<Steps*>& 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<Steps*> vpNotes;
|
||||
this->GetEdits( vpNotes, nt );
|
||||
return vpNotes.size() > 0;
|
||||
for( unsigned i=0; i<m_apNotes.size(); i++ )
|
||||
{
|
||||
Steps* pSteps = m_apNotes[i];
|
||||
if( pSteps->m_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; i<m_apNotes.size(); i++ )
|
||||
{
|
||||
Steps* pOther = m_apNotes[i];
|
||||
if( pOther->GetDifficulty() == 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
|
||||
|
||||
@@ -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<Steps*>& 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
|
||||
|
||||
Reference in New Issue
Block a user