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:
Jason Felds
2011-07-17 16:06:40 -04:00
parent bd9e7fa3c4
commit 48226f2027
26 changed files with 900 additions and 536 deletions
+78 -4
View File
@@ -459,13 +459,16 @@ static bool SearchForKeysound( const RString &sPath, RString nDataOriginal, map<
* Do a search. Don't do a wildcard search; if sData is "song.wav",
* we might also have "song.png", which we shouldn't match. */
RString nData = nDataOriginal;
if( !IsAFile(out.GetSongDir()+nData) )
RString dir = out.GetSongDir();
if (dir.empty())
dir = Dirname(sPath);
if( !IsAFile(dir+nData) )
{
const char *exts[] = { "oga", "ogg", "wav", "mp3", NULL }; // XXX: stop duplicating these everywhere
for( unsigned i = 0; exts[i] != NULL; ++i )
{
RString fn = SetExtension( nData, exts[i] );
if( IsAFile(out.GetSongDir()+fn) )
if( IsAFile(dir+fn) )
{
nData = fn;
break;
@@ -473,9 +476,9 @@ static bool SearchForKeysound( const RString &sPath, RString nDataOriginal, map<
}
}
if( !IsAFile(out.GetSongDir()+nData) )
if( !IsAFile(dir+nData) )
{
LOG->UserLog( "Song file", out.GetSongDir(), "references key \"%s\" that can't be found", nData.c_str() );
LOG->UserLog( "Song file", dir, "references key \"%s\" that can't be found", nData.c_str() );
return false;
}
@@ -1067,6 +1070,75 @@ void BMSLoader::GetApplicableFiles( const RString &sPath, vector<RString> &out )
GetDirListing( sPath + RString("*.bml"), out );
}
bool BMSLoader::LoadNoteDataFromSimfile( const RString & cachePath, Steps & out )
{
Song dummy;
// TODO: Simplify this copy/paste from LoadFromDir.
vector<NameToData_t> BMSData;
BMSData.push_back(NameToData_t());
ReadBMSFile(cachePath, BMSData.back());
RString commonSubstring;
GetCommonTagFromMapList( BMSData, "#title", commonSubstring );
Steps *copy = dummy.CreateSteps();
copy->SetDifficulty( Difficulty_Medium );
RString sTag;
if( GetTagFromMap( BMSData[0], "#title", sTag ) && sTag.size() != commonSubstring.size() )
{
sTag = sTag.substr( commonSubstring.size(), sTag.size() - commonSubstring.size() );
sTag.MakeLower();
if( sTag.find('l') != sTag.npos )
{
unsigned lPos = sTag.find('l');
if( lPos > 2 && sTag.substr(lPos-2,4) == "solo" )
{
copy->SetDifficulty( Difficulty_Edit );
}
else
{
copy->SetDifficulty( Difficulty_Easy );
}
}
else if( sTag.find('a') != sTag.npos )
copy->SetDifficulty( Difficulty_Hard );
else if( sTag.find('b') != sTag.npos )
copy->SetDifficulty( Difficulty_Beginner );
}
if( commonSubstring == "" )
{
copy->SetDifficulty(Difficulty_Medium);
RString sTag;
if (GetTagFromMap(BMSData[0], "#title#", sTag))
SearchForDifficulty(sTag, copy);
}
ReadGlobalTags( BMSData[0], dummy );
if( commonSubstring.size() > 2 && commonSubstring[commonSubstring.size() - 2] == ' ' )
{
switch( commonSubstring[commonSubstring.size() - 1] )
{
case '[':
case '(':
case '<':
commonSubstring = commonSubstring.substr(0, commonSubstring.size() - 2);
default:
break;
}
}
map<RString, int> mapFilenameToKeysoundIndex;
const bool ok = LoadFromBMSFile( cachePath, BMSData[0], *copy, dummy, mapFilenameToKeysoundIndex );
if( ok )
{
out.SetNoteData(copy->GetNoteData());
}
return ok;
}
bool BMSLoader::LoadFromDir( const RString &sDir, Song &out )
{
LOG->Trace( "Song::LoadFromBMSDir(%s)", sDir.c_str() );
@@ -1171,6 +1243,7 @@ bool BMSLoader::LoadFromDir( const RString &sDir, Song &out )
iMainDataIndex = i;
ReadGlobalTags( aBMSData[iMainDataIndex], out );
out.m_sSongFileName = out.GetSongDir() + arrayBMSFileNames[iMainDataIndex];
// The brackets before the difficulty are in common substring, so remove them if it's found.
if( commonSubstring.size() > 2 && commonSubstring[commonSubstring.size() - 2] == ' ' )
@@ -1203,6 +1276,7 @@ bool BMSLoader::LoadFromDir( const RString &sDir, Song &out )
if( i == static_cast<unsigned>(iMainDataIndex) )
out.m_SongTiming = pNewNotes->m_Timing;
pNewNotes->SetFilename(out.GetSongDir() + arrayBMSFileNames[i]);
out.AddSteps( pNewNotes );
}
else