No longer store #NOTES in cache.
Use the #STEPFILENAME tag to access the files as appropriate. To the betting pool fans: file cache version is 192.
This commit is contained in:
+43
-29
@@ -88,6 +88,45 @@ bool Steps::IsNoteDataEmpty() const
|
||||
return this->m_sNoteDataCompressed.empty();
|
||||
}
|
||||
|
||||
bool Steps::GetNoteDataFromSimfile()
|
||||
{
|
||||
// Replace the line below with the Steps' cache file.
|
||||
RString stepFile = this->GetFilename();
|
||||
RString extension = GetExtension(stepFile);
|
||||
if (extension.empty() || extension == "ssc") // remember cache files.
|
||||
{
|
||||
SSCLoader loader;
|
||||
return loader.LoadNoteDataFromSimfile(stepFile, *this);
|
||||
}
|
||||
else if (extension == "sm")
|
||||
{
|
||||
SMLoader loader;
|
||||
return loader.LoadNoteDataFromSimfile(stepFile, *this);
|
||||
}
|
||||
else if (extension == "sma")
|
||||
{
|
||||
SMALoader loader;
|
||||
return loader.LoadNoteDataFromSimfile(stepFile, *this);
|
||||
}
|
||||
else if (extension == "dwi")
|
||||
{
|
||||
return DWILoader::LoadNoteDataFromSimfile(stepFile, *this);
|
||||
}
|
||||
else if (extension == "ksf")
|
||||
{
|
||||
return KSFLoader::LoadNoteDataFromSimfile(stepFile, *this);
|
||||
}
|
||||
else if (extension == "bms" || extension == "bml" || extension == "bme")
|
||||
{
|
||||
return BMSLoader::LoadNoteDataFromSimfile(stepFile, *this);
|
||||
}
|
||||
else if (extension == "pms")
|
||||
{
|
||||
return PMSLoader::LoadNoteDataFromSimfile(stepFile, *this);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Steps::SetNoteData( const NoteData& noteDataNew )
|
||||
{
|
||||
ASSERT( noteDataNew.GetNumTracks() == GAMEMAN->GetStepsTypeInfo(m_StepsType).iNumTracks );
|
||||
@@ -130,7 +169,6 @@ void Steps::SetSMNoteData( const RString ¬es_comp_ )
|
||||
|
||||
m_sNoteDataCompressed = notes_comp_;
|
||||
m_iHash = 0;
|
||||
m_sFilename = RString(); // We can no longer read from the file because it has changed in memory.
|
||||
}
|
||||
|
||||
/* XXX: this function should pull data from m_sFilename, like Decompress() */
|
||||
@@ -293,38 +331,14 @@ void Steps::Decompress()
|
||||
|
||||
if( !m_sFilename.empty() && m_sNoteDataCompressed.empty() )
|
||||
{
|
||||
// We have data on disk and not in memory. Load it.
|
||||
Song s;
|
||||
SSCLoader loaderSSC;
|
||||
bool bLoadedFromSSC = loaderSSC.LoadFromSimfile(m_sFilename, s, true);
|
||||
if( !bLoadedFromSSC )
|
||||
// We have NoteData on disk and not in memory. Load it.
|
||||
if (!this->GetNoteDataFromSimfile())
|
||||
{
|
||||
// try reading from .sm instead
|
||||
SMLoader loaderSM;
|
||||
if( !loaderSM.LoadFromSimfile(m_sFilename, s, true) )
|
||||
{
|
||||
LOG->Warn( "Couldn't load \"%s\"", m_sFilename.c_str() );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Find the steps. */
|
||||
StepsID ID;
|
||||
ID.FromSteps( this );
|
||||
|
||||
/* We're using a StepsID to search in a different copy of a Song than
|
||||
* the one it was created with. Clear the cache before doing this,
|
||||
* or search results will come from cache and point to the original
|
||||
* copy. */
|
||||
CachedObject<Steps>::ClearCacheAll();
|
||||
Steps *pSteps = ID.ToSteps( &s, true );
|
||||
if( pSteps == NULL )
|
||||
{
|
||||
LOG->Warn( "Couldn't find %s in \"%s\"", ID.ToString().c_str(), m_sFilename.c_str() );
|
||||
LOG->Warn("Couldn't load \"%s\"", m_sFilename.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
pSteps->GetSMNoteData( m_sNoteDataCompressed );
|
||||
this->GetSMNoteData( m_sNoteDataCompressed );
|
||||
}
|
||||
|
||||
if( m_sNoteDataCompressed.empty() )
|
||||
|
||||
Reference in New Issue
Block a user