fix "edited steps disappear after leaving editor, re-appear after restart"
This commit is contained in:
+36
-39
@@ -360,7 +360,38 @@ NotesLoader *Song::MakeLoader( CString sDir ) const
|
|||||||
* pull in <set> into Song.h, which is heavily used. */
|
* pull in <set> into Song.h, which is heavily used. */
|
||||||
static set<istring> BlacklistedImages;
|
static set<istring> BlacklistedImages;
|
||||||
|
|
||||||
bool Song::LoadWithoutCache( CString sDir )
|
bool Song::LoadFromSongDir( CString sDir, bool bAllowCache )
|
||||||
|
{
|
||||||
|
// LOG->Trace( "Song::LoadFromSongDir(%s)", sDir.c_str() );
|
||||||
|
ASSERT( sDir != "" );
|
||||||
|
|
||||||
|
// make sure there is a trailing slash at the end of sDir
|
||||||
|
if( sDir.Right(1) != SLASH )
|
||||||
|
sDir += SLASH;
|
||||||
|
|
||||||
|
// save song dir
|
||||||
|
m_sSongDir = sDir;
|
||||||
|
|
||||||
|
// save group name
|
||||||
|
CStringArray sDirectoryParts;
|
||||||
|
split( m_sSongDir, SLASH, sDirectoryParts, false );
|
||||||
|
ASSERT( sDirectoryParts.size() >= 4 ); /* Songs/Slow/Taps/ */
|
||||||
|
m_sGroupName = sDirectoryParts[sDirectoryParts.size()-3]; // second from last item
|
||||||
|
ASSERT( m_sGroupName != "" );
|
||||||
|
|
||||||
|
//
|
||||||
|
// First look in the cache for this song (without loading NoteData)
|
||||||
|
//
|
||||||
|
unsigned uDirHash = SONGINDEX->GetCacheHash(m_sSongDir);
|
||||||
|
if( bAllowCache &&
|
||||||
|
GetHashForDirectory(m_sSongDir) == uDirHash && // this cache is up to date
|
||||||
|
DoesFileExist(GetCacheFilePath()))
|
||||||
|
{
|
||||||
|
// LOG->Trace( "Loading '%s' from cache file '%s'.", m_sSongDir.c_str(), GetCacheFilePath().c_str() );
|
||||||
|
SMLoader ld;
|
||||||
|
ld.LoadFromSMFile( GetCacheFilePath(), *this, true );
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// There was no entry in the cache for this song, or it was out of date.
|
// There was no entry in the cache for this song, or it was out of date.
|
||||||
@@ -385,43 +416,6 @@ bool Song::LoadWithoutCache( CString sDir )
|
|||||||
|
|
||||||
// save a cache file so we don't have to parse it all over again next time
|
// save a cache file so we don't have to parse it all over again next time
|
||||||
SaveToCacheFile();
|
SaveToCacheFile();
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Song::LoadFromSongDir( CString sDir )
|
|
||||||
{
|
|
||||||
// LOG->Trace( "Song::LoadFromSongDir(%s)", sDir.c_str() );
|
|
||||||
ASSERT( sDir != "" );
|
|
||||||
|
|
||||||
// make sure there is a trailing slash at the end of sDir
|
|
||||||
if( sDir.Right(1) != SLASH )
|
|
||||||
sDir += SLASH;
|
|
||||||
|
|
||||||
// save song dir
|
|
||||||
m_sSongDir = sDir;
|
|
||||||
|
|
||||||
// save group name
|
|
||||||
CStringArray sDirectoryParts;
|
|
||||||
split( m_sSongDir, SLASH, sDirectoryParts, false );
|
|
||||||
ASSERT( sDirectoryParts.size() >= 4 ); /* Songs/Slow/Taps/ */
|
|
||||||
m_sGroupName = sDirectoryParts[sDirectoryParts.size()-3]; // second from last item
|
|
||||||
ASSERT( m_sGroupName != "" );
|
|
||||||
|
|
||||||
//
|
|
||||||
// First look in the cache for this song (without loading NoteData)
|
|
||||||
//
|
|
||||||
unsigned uDirHash = SONGINDEX->GetCacheHash(m_sSongDir);
|
|
||||||
if( GetHashForDirectory(m_sSongDir) == uDirHash && // this cache is up to date
|
|
||||||
DoesFileExist(GetCacheFilePath()))
|
|
||||||
{
|
|
||||||
// LOG->Trace( "Loading '%s' from cache file '%s'.", m_sSongDir.c_str(), GetCacheFilePath().c_str() );
|
|
||||||
SMLoader ld;
|
|
||||||
ld.LoadFromSMFile( GetCacheFilePath(), *this, true );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(!LoadWithoutCache(m_sSongDir))
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Load the cached banners, if it's not loaded already. */
|
/* Load the cached banners, if it's not loaded already. */
|
||||||
@@ -489,7 +483,10 @@ void Song::RevertFromDisk()
|
|||||||
|
|
||||||
/* Erase all existing data. */
|
/* Erase all existing data. */
|
||||||
Reset();
|
Reset();
|
||||||
LoadFromSongDir( dir );
|
|
||||||
|
// Don't load from cache, or else we'll get an old version
|
||||||
|
// if they've saved in the editor.
|
||||||
|
LoadFromSongDir( dir, false );
|
||||||
|
|
||||||
if( GAMESTATE->m_pCurSong == this )
|
if( GAMESTATE->m_pCurSong == this )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -76,10 +76,9 @@ public:
|
|||||||
~Song();
|
~Song();
|
||||||
void Reset();
|
void Reset();
|
||||||
|
|
||||||
bool LoadWithoutCache( CString sDir );
|
|
||||||
NotesLoader *MakeLoader( CString sDir ) const;
|
NotesLoader *MakeLoader( CString sDir ) const;
|
||||||
|
|
||||||
bool LoadFromSongDir( CString sDir );
|
bool LoadFromSongDir( CString sDir, bool bAllowCache = true );
|
||||||
void RevertFromDisk();
|
void RevertFromDisk();
|
||||||
|
|
||||||
void TidyUpData(); // call after loading to clean up invalid data
|
void TidyUpData(); // call after loading to clean up invalid data
|
||||||
|
|||||||
Reference in New Issue
Block a user