Process each file once, not twice.
This commit is contained in:
+35
-67
@@ -84,20 +84,6 @@ void SMLoader::GetApplicableFiles( const RString &sPath, vector<RString> &out )
|
|||||||
GetDirListing( sPath + RString("*.sm"), out );
|
GetDirListing( sPath + RString("*.sm"), out );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SMLoader::LoadTimingFromFile( const RString &fn, TimingData &out )
|
|
||||||
{
|
|
||||||
MsdFile msd;
|
|
||||||
if( !msd.ReadFile( fn, true ) ) // unescape
|
|
||||||
{
|
|
||||||
LOG->UserLog( "Song file", fn, "couldn't be loaded: %s", msd.GetError().c_str() );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
out.m_sFile = fn;
|
|
||||||
LoadTimingFromSMFile( msd, out );
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SMLoader::ProcessBGChanges( Song &out, const RString &sValueName, const RString &sPath, const RString &sParam )
|
void SMLoader::ProcessBGChanges( Song &out, const RString &sValueName, const RString &sPath, const RString &sParam )
|
||||||
{
|
{
|
||||||
BackgroundLayer iLayer = BACKGROUND_LAYER_1;
|
BackgroundLayer iLayer = BACKGROUND_LAYER_1;
|
||||||
@@ -423,53 +409,6 @@ void SMLoader::ProcessTickcounts( TimingData &out, const RString sParam )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SMLoader::LoadTimingFromSMFile( const MsdFile &msd, TimingData &out )
|
|
||||||
{
|
|
||||||
out.m_fBeat0OffsetInSeconds = 0;
|
|
||||||
out.m_BPMSegments.clear();
|
|
||||||
out.m_StopSegments.clear();
|
|
||||||
out.m_WarpSegments.clear();
|
|
||||||
out.m_vTimeSignatureSegments.clear();
|
|
||||||
|
|
||||||
for( unsigned i=0; i<msd.GetNumValues(); i++ )
|
|
||||||
{
|
|
||||||
const MsdFile::value_t &sParams = msd.GetValue(i);
|
|
||||||
RString sValueName = sParams[0];
|
|
||||||
sValueName.MakeUpper();
|
|
||||||
|
|
||||||
if( sValueName=="OFFSET" )
|
|
||||||
{
|
|
||||||
out.m_fBeat0OffsetInSeconds = StringToFloat( sParams[1] );
|
|
||||||
}
|
|
||||||
else if( sValueName=="BPMS" )
|
|
||||||
{
|
|
||||||
ProcessBPMs(out, sParams[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
else if( sValueName=="STOPS" || sValueName=="FREEZES" )
|
|
||||||
{
|
|
||||||
ProcessStops(out, sParams[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
else if( sValueName=="DELAYS" )
|
|
||||||
{
|
|
||||||
ProcessDelays(out, sParams[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
else if( sValueName=="TIMESIGNATURES" )
|
|
||||||
{
|
|
||||||
ProcessTimeSignatures(out, sParams[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
else if( sValueName=="TICKCOUNTS" )
|
|
||||||
{
|
|
||||||
ProcessTickcounts(out, sParams[1]);
|
|
||||||
}
|
|
||||||
// Ensure all of the warps are handled right.
|
|
||||||
sort(out.m_WarpSegments.begin(), out.m_WarpSegments.end());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SMLoader::LoadFromBGChangesString( BackgroundChange &change, const RString &sBGChangeExpression )
|
bool SMLoader::LoadFromBGChangesString( BackgroundChange &change, const RString &sBGChangeExpression )
|
||||||
{
|
{
|
||||||
vector<RString> aBGChangeValues;
|
vector<RString> aBGChangeValues;
|
||||||
@@ -568,7 +507,6 @@ bool SMLoader::LoadFromSMFile( const RString &sPath, Song &out, bool bFromCache
|
|||||||
}
|
}
|
||||||
|
|
||||||
out.m_SongTiming.m_sFile = sPath;
|
out.m_SongTiming.m_sFile = sPath;
|
||||||
LoadTimingFromSMFile( msd, out.m_SongTiming );
|
|
||||||
|
|
||||||
for( unsigned i=0; i<msd.GetNumValues(); i++ )
|
for( unsigned i=0; i<msd.GetNumValues(); i++ )
|
||||||
{
|
{
|
||||||
@@ -620,6 +558,36 @@ bool SMLoader::LoadFromSMFile( const RString &sPath, Song &out, bool bFromCache
|
|||||||
else if( sValueName=="MUSIC" )
|
else if( sValueName=="MUSIC" )
|
||||||
out.m_sMusicFile = sParams[1];
|
out.m_sMusicFile = sParams[1];
|
||||||
|
|
||||||
|
else if( sValueName=="OFFSET" )
|
||||||
|
{
|
||||||
|
out.m_fBeat0OffsetInSeconds = StringToFloat( sParams[1] );
|
||||||
|
}
|
||||||
|
else if( sValueName=="BPMS" )
|
||||||
|
{
|
||||||
|
ProcessBPMs(out.m_SongTiming, sParams[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if( sValueName=="STOPS" || sValueName=="FREEZES" )
|
||||||
|
{
|
||||||
|
ProcessStops(out.m_SongTiming, sParams[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if( sValueName=="DELAYS" )
|
||||||
|
{
|
||||||
|
ProcessDelays(out.m_SongTiming, sParams[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if( sValueName=="TIMESIGNATURES" )
|
||||||
|
{
|
||||||
|
ProcessTimeSignatures(out.m_SongTiming, sParams[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if( sValueName=="TICKCOUNTS" )
|
||||||
|
{
|
||||||
|
ProcessTickcounts(out.m_SongTiming, sParams[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
else if( sValueName=="INSTRUMENTTRACK" )
|
else if( sValueName=="INSTRUMENTTRACK" )
|
||||||
{
|
{
|
||||||
ProcessInstrumentTracks( out, sParams[1] );
|
ProcessInstrumentTracks( out, sParams[1] );
|
||||||
@@ -762,15 +730,15 @@ bool SMLoader::LoadFromSMFile( const RString &sPath, Song &out, bool bFromCache
|
|||||||
|
|
||||||
out.AddSteps( pNewNotes );
|
out.AddSteps( pNewNotes );
|
||||||
}
|
}
|
||||||
/*
|
// XXX: Does anyone know what LEADTRACK is for? -Wolfman2000
|
||||||
* We used to check for timing data in this section. That has
|
else if( sValueName=="LEADTRACK" )
|
||||||
* since been moved to a dedicated function.
|
|
||||||
*/
|
|
||||||
else if( sValueName=="OFFSET" || sValueName=="BPMS" || sValueName=="STOPS" || sValueName=="FREEZES" || sValueName=="DELAYS" || sValueName=="TIMESIGNATURES" || sValueName=="LEADTRACK" || sValueName=="TICKCOUNTS" )
|
|
||||||
;
|
;
|
||||||
else
|
else
|
||||||
LOG->UserLog( "Song file", sPath, "has an unexpected value named \"%s\".", sValueName.c_str() );
|
LOG->UserLog( "Song file", sPath, "has an unexpected value named \"%s\".", sValueName.c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure all warps from negative time changes are in order.
|
||||||
|
sort(out.m_SongTiming.m_WarpSegments.begin(), out.m_SongTiming.m_WarpSegments.end());
|
||||||
TidyUpData( out, bFromCache );
|
TidyUpData( out, bFromCache );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,8 +26,6 @@ namespace SMLoader
|
|||||||
|
|
||||||
bool LoadFromSMFile( const RString &sPath, Song &out, bool bFromCache = false );
|
bool LoadFromSMFile( const RString &sPath, Song &out, bool bFromCache = false );
|
||||||
void GetApplicableFiles( const RString &sPath, vector<RString> &out );
|
void GetApplicableFiles( const RString &sPath, vector<RString> &out );
|
||||||
bool LoadTimingFromFile( const RString &fn, TimingData &out );
|
|
||||||
void LoadTimingFromSMFile( const MsdFile &msd, TimingData &out );
|
|
||||||
bool LoadEditFromFile( RString sEditFilePath, ProfileSlot slot, bool bAddStepsToSong );
|
bool LoadEditFromFile( RString sEditFilePath, ProfileSlot slot, bool bAddStepsToSong );
|
||||||
bool LoadEditFromBuffer( const RString &sBuffer, const RString &sEditFilePath, ProfileSlot slot );
|
bool LoadEditFromBuffer( const RString &sBuffer, const RString &sEditFilePath, ProfileSlot slot );
|
||||||
bool LoadEditFromMsd( const MsdFile &msd, const RString &sEditFilePath, ProfileSlot slot, bool bAddStepsToSong );
|
bool LoadEditFromMsd( const MsdFile &msd, const RString &sEditFilePath, ProfileSlot slot, bool bAddStepsToSong );
|
||||||
|
|||||||
Reference in New Issue
Block a user