diff --git a/src/GameSoundManager.cpp b/src/GameSoundManager.cpp index 0e36042116..9034b86a34 100644 --- a/src/GameSoundManager.cpp +++ b/src/GameSoundManager.cpp @@ -6,7 +6,7 @@ #include "RageUtil.h" #include "GameState.h" #include "TimingData.h" -#include "NotesLoaderSM.h" +#include "NotesLoaderSSC.h" #include "PrefsManager.h" #include "RageDisplay.h" #include "AnnouncerManager.h" @@ -141,7 +141,7 @@ static void StartMusic( MusicToPlay &ToPlay ) { LOG->Trace( "Found '%s'", ToPlay.m_sTimingFile.c_str() ); Song song; - if( SMLoader::LoadFromSMFile(ToPlay.m_sTimingFile, song) ) + if( SSCLoader::LoadFromSSCFile(ToPlay.m_sTimingFile, song) ) { ToPlay.HasTiming = true; ToPlay.m_TimingData = song.m_Timing; diff --git a/src/NotesLoader.cpp b/src/NotesLoader.cpp index 6d12e2cb75..0d257c3c81 100644 --- a/src/NotesLoader.cpp +++ b/src/NotesLoader.cpp @@ -1,6 +1,7 @@ #include "global.h" #include "NotesLoader.h" #include "NotesLoaderSM.h" +#include "NotesLoaderSSC.h" #include "NotesLoaderDWI.h" #include "NotesLoaderBMS.h" #include "NotesLoaderPMS.h" @@ -30,14 +31,17 @@ bool NotesLoader::LoadFromDir( const RString &sPath, Song &out, set &Bl vector list; BlacklistedImages.clear(); - SMLoader::GetApplicableFiles( sPath, list ); + SSCLoader::GetApplicableFiles( sPath, list ); if( !list.empty() ) { - if( !SMLoader::LoadFromDir(sPath, out) ) + if( !SSCLoader::LoadFromDir( sPath, out ) ) return false; - SMLoader::TidyUpData( out, false ); + SSCLoader::TidyUpData( out, false ); return true; } + SMLoader::GetApplicableFiles( sPath, list ); + if (!list.empty() ) + return SMLoader::LoadFromDir( sPath, out ); DWILoader::GetApplicableFiles( sPath, list ); if( !list.empty() ) return DWILoader::LoadFromDir( sPath, out, BlacklistedImages ); diff --git a/src/NotesWriterSSC.h b/src/NotesWriterSSC.h index e8d544d43e..118a37987a 100644 --- a/src/NotesWriterSSC.h +++ b/src/NotesWriterSSC.h @@ -1,4 +1,4 @@ -/* NotesWriterSM - Writes a Song to an .SSC file. */ +/* NotesWriterSSC - Writes a Song to an .SSC file. */ #ifndef NOTES_WRITER_SSC_H #define NOTES_WRITER_SSC_H diff --git a/src/ScreenGameplaySyncMachine.cpp b/src/ScreenGameplaySyncMachine.cpp index ed6bee0814..30d7dad981 100644 --- a/src/ScreenGameplaySyncMachine.cpp +++ b/src/ScreenGameplaySyncMachine.cpp @@ -1,6 +1,6 @@ #include "global.h" #include "ScreenGameplaySyncMachine.h" -#include "NotesLoaderSM.h" +#include "NotesLoaderSSC.h" #include "GameState.h" #include "GameManager.h" #include "PrefsManager.h" @@ -19,7 +19,7 @@ void ScreenGameplaySyncMachine::Init() AdjustSync::ResetOriginalSyncData(); RString sFile = THEME->GetPathO("ScreenGameplaySyncMachine","music.sm"); - SMLoader::LoadFromSMFile( sFile, m_Song ); + SSCLoader::LoadFromSSCFile( sFile, m_Song ); m_Song.SetSongDir( Dirname(sFile) ); m_Song.TidyUpData(); diff --git a/src/ScreenHowToPlay.cpp b/src/ScreenHowToPlay.cpp index 552eee8783..d5627f66d9 100644 --- a/src/ScreenHowToPlay.cpp +++ b/src/ScreenHowToPlay.cpp @@ -4,7 +4,7 @@ #include "GameState.h" #include "Steps.h" #include "GameManager.h" -#include "NotesLoaderSM.h" +#include "NotesLoaderSSC.h" #include "GameSoundManager.h" #include "Model.h" #include "ThemeMetric.h" @@ -132,7 +132,7 @@ void ScreenHowToPlay::Init() ActorUtil::LoadAllCommandsAndSetXY( m_pLifeMeterBar, m_sName ); m_pLifeMeterBar->FillForHowToPlay( NUM_W2S, NUM_MISSES ); - SMLoader::LoadFromSMFile( THEME->GetPathO(m_sName, "steps"), m_Song, false ); + SSCLoader::LoadFromSSCFile( THEME->GetPathO(m_sName, "steps"), m_Song, false ); m_Song.AddAutoGenNotes(); const Style* pStyle = GAMESTATE->GetCurrentStyle(); diff --git a/src/ScreenServiceAction.cpp b/src/ScreenServiceAction.cpp index 638d8bd4b1..d223c52299 100644 --- a/src/ScreenServiceAction.cpp +++ b/src/ScreenServiceAction.cpp @@ -15,7 +15,7 @@ #include "PlayerState.h" #include "LocalizedString.h" #include "StepMania.h" -#include "NotesLoaderSM.h" +#include "NotesLoaderSSC.h" static LocalizedString BOOKKEEPING_DATA_CLEARED( "ScreenServiceAction", "Bookkeeping data cleared." ); static RString ClearBookkeepingData() @@ -197,7 +197,7 @@ static void CopyEdits( const RString &sFromProfileDir, const RString &sToProfile iNumErrored++; // Test whether the song we need for this edit is present and ignore this edit if not present. - if( !SMLoader::LoadEditFromFile( sFromDir+*i, ProfileSlot_Machine, false ) ) + if( !SSCLoader::LoadEditFromFile( sFromDir+*i, ProfileSlot_Machine, false ) ) { iNumIgnored++; continue; diff --git a/src/Song.cpp b/src/Song.cpp index 9baf705190..55d0545c8b 100644 --- a/src/Song.cpp +++ b/src/Song.cpp @@ -25,8 +25,10 @@ #include "SpecialFiles.h" #include "NotesLoader.h" #include "NotesLoaderSM.h" +#include "NotesLoaderSSC.h" #include "NotesWriterDWI.h" #include "NotesWriterSM.h" +#include "NotesWriterSSC.h" #include "UnlockManager.h" #include "LyricsLoader.h" @@ -34,7 +36,7 @@ #include #include -const int FILE_CACHE_VERSION = 162; // increment this to invalidate cache +const int FILE_CACHE_VERSION = 163; // increment this to invalidate cache const float DEFAULT_MUSIC_SAMPLE_LENGTH = 12.f; @@ -214,8 +216,8 @@ bool Song::LoadFromSongDir( RString sDir ) if( bUseCache ) { // LOG->Trace( "Loading '%s' from cache file '%s'.", m_sSongDir.c_str(), GetCacheFilePath().c_str() ); - SMLoader::LoadFromSMFile( sCacheFilePath, *this, true ); - SMLoader::TidyUpData( *this, true ); + SSCLoader::LoadFromSSCFile( sCacheFilePath, *this, true ); + SSCLoader::TidyUpData( *this, true ); } else { @@ -844,9 +846,10 @@ void Song::Save() TranslateTitles(); // Save the new files. These calls make backups on their own. - if( !SaveToSMFile(GetSongFilePath(), false) ) + if( !SaveToSSCFile(GetSongFilePath(), false) ) return; - SaveToDWIFile(); + SaveToSMFile(); + //SaveToDWIFile(); SaveToCacheFile(); /* We've safely written our files and created backups. Rename non-SM and @@ -871,10 +874,21 @@ void Song::Save() } } - -bool Song::SaveToSMFile( RString sPath, bool bSavingCache ) +bool Song::SaveToSMFile() { - LOG->Trace( "Song::SaveToSMFile('%s')", sPath.c_str() ); + const RString sPath = SetExtension( GetSongFilePath(), "sm" ); + LOG->Trace( "Song::SaveToSMFile(%s)", sPath.c_str() ); + + // If the file exists, make a backup. + if( IsAFile(sPath) ) + FileCopy( sPath, sPath + ".old" ); + return NotesWriterSM::Write( sPath, *this ); + +} + +bool Song::SaveToSSCFile( RString sPath, bool bSavingCache ) +{ + LOG->Trace( "Song::SaveToSSCFile('%s')", sPath.c_str() ); // If the file exists, make a backup. if( !bSavingCache && IsAFile(sPath) ) @@ -894,7 +908,7 @@ bool Song::SaveToSMFile( RString sPath, bool bSavingCache ) vpStepsToSave.push_back( pSteps ); } - if( !NotesWriterSM::Write(sPath, *this, vpStepsToSave, bSavingCache) ) + if( !NotesWriterSSC::Write(sPath, *this, vpStepsToSave, bSavingCache) ) return false; if( !bSavingCache && g_BackUpAllSongSaves.Get() ) @@ -932,7 +946,7 @@ bool Song::SaveToCacheFile() { SONGINDEX->AddCacheIndex(m_sSongDir, GetHashForDirectory(m_sSongDir)); const RString sPath = GetCacheFilePath(); - if( !SaveToSMFile(sPath, true) ) + if( !SaveToSSCFile(sPath, true) ) return false; FOREACH( Steps*, m_vpSteps, pSteps ) diff --git a/src/Song.h b/src/Song.h index cb439ef08c..3aa36f025b 100644 --- a/src/Song.h +++ b/src/Song.h @@ -61,7 +61,7 @@ public: enum SelectionDisplay { SHOW_ALWAYS, // always - SHOW_NEVER // never (unless song hiding is turned off) + SHOW_NEVER // never (unless song hiding is turned off) } m_SelectionDisplay; Song(); @@ -78,9 +78,10 @@ public: void ReCalculateRadarValuesAndLastBeat(); // called by TidyUpData, and after saving void TranslateTitles(); // called by TidyUpData - bool SaveToSMFile( RString sPath, bool bSavingCache ); - void Save(); // saves SM and DWI + bool SaveToSSCFile( RString sPath, bool bSavingCache ); + void Save(); // saves SSC and SM guaranteed. bool SaveToCacheFile(); + bool SaveToSMFile(); bool SaveToDWIFile(); const RString &GetSongFilePath() const; @@ -93,9 +94,10 @@ public: // Directory this song data came from: const RString &GetSongDir() const { return m_sSongDir; } - /* Filename associated with this file. This will always have an .SM extension. - * If we loaded an .SM, this will point to it, but if we loaded any other - * type, this will point to a generated .SM filename. */ + /* Filename associated with this file. This will always have a + * .SSC extension. If we loaded a .SSC, this will point to it, + * but if we loaded any other type, this will point to a + * generated .SSC filename. */ RString m_sSongFileName; RString m_sGroupName; diff --git a/src/SongManager.cpp b/src/SongManager.cpp index 5679bb821c..2d9bb1f737 100644 --- a/src/SongManager.cpp +++ b/src/SongManager.cpp @@ -15,7 +15,7 @@ #include "MsdFile.h" #include "NoteSkinManager.h" #include "NotesLoaderDWI.h" -#include "NotesLoaderSM.h" +#include "NotesLoaderSSC.h" #include "PrefsManager.h" #include "Profile.h" #include "ProfileManager.h" @@ -1653,7 +1653,7 @@ void SongManager::LoadStepEditsFromProfileDir( const RString &sProfileDir, Profi { RString fn = vsFiles[i]; - SMLoader::LoadEditFromFile( fn, slot, true ); + SSCLoader::LoadEditFromFile( fn, slot, true ); } } } diff --git a/src/Steps.cpp b/src/Steps.cpp index e4349e0aea..70815cf0fe 100644 --- a/src/Steps.cpp +++ b/src/Steps.cpp @@ -20,7 +20,7 @@ #include "NoteData.h" #include "GameManager.h" #include "NoteDataUtil.h" -#include "NotesLoaderSM.h" +#include "NotesLoaderSSC.h" #include @@ -231,7 +231,7 @@ void Steps::Decompress() const { /* We have data on disk and not in memory. Load it. */ Song s; - if( !SMLoader::LoadFromSMFile(m_sFilename, s, true) ) + if( !SSCLoader::LoadFromSSCFile(m_sFilename, s, true) ) { LOG->Warn( "Couldn't load \"%s\"", m_sFilename.c_str() ); return;