don't load duplicate edits

This commit is contained in:
Chris Danford
2004-04-23 01:33:08 +00:00
parent 83fb83d1b4
commit 65ea42f7b2
3 changed files with 39 additions and 10 deletions
+9 -1
View File
@@ -435,7 +435,6 @@ bool SMLoader::LoadEdit( CString sEditFilePath, ProfileSlot slot )
Steps* pNewNotes = new Steps; Steps* pNewNotes = new Steps;
ASSERT( pNewNotes ); ASSERT( pNewNotes );
pSong->m_apNotes.push_back( pNewNotes );
if( iNumParams < 7 ) if( iNumParams < 7 )
{ {
@@ -450,6 +449,15 @@ bool SMLoader::LoadEdit( CString sEditFilePath, ProfileSlot slot )
pNewNotes->SetLoadedFromProfile( slot ); pNewNotes->SetLoadedFromProfile( slot );
pNewNotes->SetDifficulty( DIFFICULTY_EDIT ); 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! return true; // Only allow one Steps per edit file!
} }
else else
+29 -8
View File
@@ -948,11 +948,6 @@ Steps* Song::GetClosestNotes( StepsType nt, Difficulty dc ) const
return pNotes; return pNotes;
} }
void Song::GetEdits( vector<Steps*>& arrayAddTo, StepsType nt ) const
{
}
/* Return whether the song is playable in the given style. */ /* Return whether the song is playable in the given style. */
bool Song::SongCompleteForStyle( const StyleDef *st ) const bool Song::SongCompleteForStyle( const StyleDef *st ) const
{ {
@@ -1135,9 +1130,17 @@ bool Song::IsEasy( StepsType nt ) const
bool Song::HasEdits( StepsType nt ) const bool Song::HasEdits( StepsType nt ) const
{ {
vector<Steps*> vpNotes; for( unsigned i=0; i<m_apNotes.size(); i++ )
this->GetEdits( vpNotes, nt ); {
return vpNotes.size() > 0; Steps* pSteps = m_apNotes[i];
if( pSteps->m_StepsType == nt &&
pSteps->GetDifficulty() == DIFFICULTY_EDIT )
{
return true;
}
}
return false;
} }
Song::SelectionDisplay Song::GetDisplayed() const Song::SelectionDisplay Song::GetDisplayed() const
@@ -1329,6 +1332,24 @@ int Song::GetNumStepsLoadedFromProfile( ProfileSlot slot ) const
return iCount; 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 bool Song::HasSignificantBpmChangesOrStops() const
{ {
// Don't consider BPM changes that only are only for maintaining sync as // Don't consider BPM changes that only are only for maintaining sync as
+1 -1
View File
@@ -191,7 +191,6 @@ public:
Steps* GetStepsByMeter( StepsType nt, int iMeterLow, int iMeterHigh ) const; Steps* GetStepsByMeter( StepsType nt, int iMeterLow, int iMeterHigh ) const;
Steps* GetStepsByDescription( StepsType nt, CString sDescription ) const; Steps* GetStepsByDescription( StepsType nt, CString sDescription ) const;
Steps* GetClosestNotes( StepsType nt, Difficulty dc ) const; Steps* GetClosestNotes( StepsType nt, Difficulty dc ) const;
void GetEdits( vector<Steps*>& arrayAddTo, StepsType nt ) const;
bool IsEasy( StepsType nt ) const; bool IsEasy( StepsType nt ) const;
bool HasEdits( StepsType nt ) const; bool HasEdits( StepsType nt ) const;
SelectionDisplay GetDisplayed() const; SelectionDisplay GetDisplayed() const;
@@ -206,6 +205,7 @@ public:
void FreeAllLoadedFromProfiles(); void FreeAllLoadedFromProfiles();
bool WasLoadedFromProfile() const { return m_LoadedFromProfile != PROFILE_SLOT_INVALID; } bool WasLoadedFromProfile() const { return m_LoadedFromProfile != PROFILE_SLOT_INVALID; }
int GetNumStepsLoadedFromProfile( ProfileSlot slot ) const; int GetNumStepsLoadedFromProfile( ProfileSlot slot ) const;
bool IsEditAlreadyLoaded( Steps* pSteps ) const;
private: private:
void AdjustDuplicateSteps(); // part of TidyUpData void AdjustDuplicateSteps(); // part of TidyUpData