From c4f0c0f5c06133c30316ed9c9b1ebb142360ac58 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Mon, 8 Sep 2003 23:08:25 +0000 Subject: [PATCH] Dupe steps sometimes have varying initial whitespace; ignore it. (Don't ignore all whitespace, since newlines are significant in SM data.) --- stepmania/src/Song.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/stepmania/src/Song.cpp b/stepmania/src/Song.cpp index 2c368e9211..b76e39174b 100644 --- a/stepmania/src/Song.cpp +++ b/stepmania/src/Song.cpp @@ -511,26 +511,40 @@ static void GetImageDirListing( CString sPath, CStringArray &AddTo, bool bReturn GetDirListing( sPath + ".gif", AddTo, false, bReturnPathToo ); } +static CString RemoveInitialWhitespace( CString s ) +{ + unsigned i = s.find_first_not_of(" \t\r\n"); + if( i != s.npos ) + s.erase( 0, i ); + return s; +} + /* This is called within TidyUpData, before autogen notes are added. */ static void DeleteDuplicateSteps( Song *song, vector &vSteps ) { /* vSteps have the same StepsType and Difficulty. Delete them if they have the * same m_sDescription, m_iMeter and SMNoteData. */ + CHECKPOINT; for( unsigned i=0; iTrace("comparing %i (%p) ...", i, s1); for( unsigned j=i+1; jTrace(" with %i (%p) ...", j, s2); if( s1->GetDescription() != s2->GetDescription() ) continue; if( s1->GetMeter() != s2->GetMeter() ) continue; - if( s1->GetSMNoteData() != s2->GetSMNoteData() ) + /* Compare, ignoring whitespace. */ + if( RemoveInitialWhitespace(s1->GetSMNoteData()) != RemoveInitialWhitespace(s2->GetSMNoteData()) ) continue; - LOG->Trace("Removed duplicate steps in song \"%s\" with description \"%s\" and meter \"%i\"", - song->GetSongDir().c_str(), s1->GetDescription().c_str(), s1->GetMeter() ); + LOG->Trace("Removed %p duplicate steps in song \"%s\" with description \"%s\" and meter \"%i\"", + s2, song->GetSongDir().c_str(), s1->GetDescription().c_str(), s1->GetMeter() ); /* Don't use RemoveNotes; autogen notes havn't yet been created and it'll * create them. */