diff --git a/stepmania/src/NotesWriterSM.cpp b/stepmania/src/NotesWriterSM.cpp index 04fa907f69..0d902659ea 100644 --- a/stepmania/src/NotesWriterSM.cpp +++ b/stepmania/src/NotesWriterSM.cpp @@ -195,7 +195,7 @@ static RString GetSMNotesTag( const Song &song, const Steps &in, bool bSavingCac return JoinLineList( lines ); } -bool NotesWriterSM::Write( RString sPath, const Song &out, bool bSavingCache ) +bool NotesWriterSM::Write( RString sPath, const Song &out, const vector& vpStepsToSave, bool bSavingCache ) { /* Flush dir cache when writing steps, so the old size isn't cached. */ FILEMAN->FlushDirCache( Dirname(sPath) ); @@ -229,19 +229,11 @@ bool NotesWriterSM::Write( RString sPath, const Song &out, bool bSavingCache ) } // - // Save all Steps for this file + // Save specified Steps to this file // - const vector& vpSteps = out.GetAllSteps(); - FOREACH_CONST( Steps*, vpSteps, s ) + FOREACH_CONST( Steps*, vpStepsToSave, s ) { const Steps* pSteps = *s; - if( pSteps->IsAutogen() ) - continue; /* don't write autogen notes */ - - /* Only save steps that weren't loaded from a profile. */ - if( pSteps->WasLoadedFromProfile() ) - continue; - RString sTag = GetSMNotesTag( out, *pSteps, bSavingCache ); f.PutLine( sTag ); } diff --git a/stepmania/src/NotesWriterSM.h b/stepmania/src/NotesWriterSM.h index 3244ec1374..c32368c3dd 100644 --- a/stepmania/src/NotesWriterSM.h +++ b/stepmania/src/NotesWriterSM.h @@ -7,7 +7,7 @@ class Song; class Steps; namespace NotesWriterSM { - bool Write( RString sPath, const Song &out, bool bSavingCache ); + bool Write( RString sPath, const Song &out, const vector& vpStepsToSave, bool bSavingCache ); void GetEditFileContents( const Song *pSong, const Steps *pSteps, RString &sOut ); RString GetEditFileName( const Song *pSong, const Steps *pSteps ); bool WriteEditFileToMachine( const Song *pSong, Steps *pSteps, RString &sErrorOut ); diff --git a/stepmania/src/ScreenEdit.cpp b/stepmania/src/ScreenEdit.cpp index d3eecd372c..a3c38961e7 100644 --- a/stepmania/src/ScreenEdit.cpp +++ b/stepmania/src/ScreenEdit.cpp @@ -2551,7 +2551,6 @@ void ScreenEdit::HandleScreenMessage( const ScreenMessage SM ) else if( SM == SM_SaveSuccessful ) { LOG->Trace( "Save successful." ); - m_pSteps->SetSavedToDisk( true ); CopyToLastSave(); SetDirty( false ); SONGMAN->Invalidate( GAMESTATE->m_pCurSong ); @@ -2806,6 +2805,8 @@ void ScreenEdit::HandleMainMenuChoice( MainMenuChoice c, const vector &iAns break; } + m_pSteps->SetSavedToDisk( true ); + // HACK: clear undo, so "exit" below knows we don't need to save. // This only works because important non-steps data can't be changed in // home mode (BPMs, stops). diff --git a/stepmania/src/Song.cpp b/stepmania/src/Song.cpp index d1e339bf74..dae9a8cd01 100644 --- a/stepmania/src/Song.cpp +++ b/stepmania/src/Song.cpp @@ -819,7 +819,31 @@ bool Song::SaveToSMFile( RString sPath, bool bSavingCache ) if( !bSavingCache && IsAFile(sPath) ) FileCopy( sPath, sPath + ".old" ); - return NotesWriterSM::Write( sPath, *this, bSavingCache ); + vector vpStepsToSave; + FOREACH_CONST( Steps*, m_vpSteps, s ) + { + Steps *pSteps = *s; + if( pSteps->IsAutogen() ) + continue; /* don't write autogen notes */ + + /* Only save steps that weren't loaded from a profile. */ + if( pSteps->WasLoadedFromProfile() ) + continue; + + vpStepsToSave.push_back( pSteps ); + } + + if( !NotesWriterSM::Write(sPath, *this, vpStepsToSave, bSavingCache) ) + return false; + + if( !bSavingCache ) + { + /* Mark these steps saved to disk. */ + FOREACH( Steps*, vpStepsToSave, s ) + (*s)->SetSavedToDisk( true ); + } + + return true; } bool Song::SaveToCacheFile()