From 4b89c0fae76025e833f738a257ab2bd680a29fad Mon Sep 17 00:00:00 2001 From: Jason Felds Date: Sat, 14 May 2011 17:41:08 -0400 Subject: [PATCH] [splittiming] Abstraction, prep work. --- src/NotesLoaderSM.cpp | 31 ++++++++++++++++++------------- src/NotesLoaderSM.h | 1 + src/NotesLoaderSMA.cpp | 22 +++++++--------------- src/NotesLoaderSSC.cpp | 14 +------------- 4 files changed, 27 insertions(+), 41 deletions(-) diff --git a/src/NotesLoaderSM.cpp b/src/NotesLoaderSM.cpp index 9e980aac14..80d56ee33f 100644 --- a/src/NotesLoaderSM.cpp +++ b/src/NotesLoaderSM.cpp @@ -173,6 +173,23 @@ void SMLoader::ProcessAttacks( Song &out, MsdFile::value_t sParams ) } } +void SMLoader::ProcessInstrumentTracks( Song &out, const RString &sParam ) +{ + vector vs1; + split( sParam, ",", vs1 ); + FOREACH_CONST( RString, vs1, s ) + { + vector vs2; + split( *s, "=", vs2 ); + if( vs2.size() >= 2 ) + { + InstrumentTrack it = StringToInstrumentTrack( vs2[0] ); + if( it != InstrumentTrack_Invalid ) + out.m_sInstrumentTrackFile[it] = vs2[1]; + } + } +} + bool SMLoader::ProcessBPMs( TimingData &out, const RString sParam ) { vector arrayBPMChangeExpressions; @@ -597,19 +614,7 @@ bool SMLoader::LoadFromSMFile( const RString &sPath, Song &out, bool bFromCache else if( sValueName=="INSTRUMENTTRACK" ) { - vector vs1; - split( sParams[1], ",", vs1 ); - FOREACH_CONST( RString, vs1, s ) - { - vector vs2; - split( *s, "=", vs2 ); - if( vs2.size() >= 2 ) - { - InstrumentTrack it = StringToInstrumentTrack( vs2[0] ); - if( it != InstrumentTrack_Invalid ) - out.m_sInstrumentTrackFile[it] = vs2[1]; - } - } + ProcessInstrumentTracks( out, sParams[1] ); } else if( sValueName=="MUSICLENGTH" ) diff --git a/src/NotesLoaderSM.h b/src/NotesLoaderSM.h index b6bc97cd60..8628d7dde2 100644 --- a/src/NotesLoaderSM.h +++ b/src/NotesLoaderSM.h @@ -35,6 +35,7 @@ namespace SMLoader void ProcessBGChanges( Song &out, const RString &sValueName, const RString &sPath, const RString &sParam ); void ProcessAttacks( Song &out, MsdFile::value_t sParams ); + void ProcessInstrumentTracks( Song &out, const RString &sParam ); } #endif diff --git a/src/NotesLoaderSMA.cpp b/src/NotesLoaderSMA.cpp index 6fe8620bf3..ec6a8deb6f 100644 --- a/src/NotesLoaderSMA.cpp +++ b/src/NotesLoaderSMA.cpp @@ -120,8 +120,12 @@ bool SMALoader::LoadFromSMAFile( const RString &sPath, Song &out ) return false; } - out.m_SongTiming.m_sFile = sPath; - LoadTimingFromSMAFile( msd, out.m_SongTiming ); + out.m_SongTiming.m_sFile = sPath; // songs still have their fallback timing. + + int state = SMA_GETTING_SONG_INFO; + Steps* pNewNotes = NULL; + TimingData stepsTiming; + int iRowsPerBeat = -1; // Start with an invalid value: needed for checking. for( unsigned i=0; i vs1; - split( sParams[1], ",", vs1 ); - FOREACH_CONST( RString, vs1, s ) - { - vector vs2; - split( *s, "=", vs2 ); - if( vs2.size() >= 2 ) - { - InstrumentTrack it = StringToInstrumentTrack( vs2[0] ); - if( it != InstrumentTrack_Invalid ) - out.m_sInstrumentTrackFile[it] = vs2[1]; - } - } + SMLoader::ProcessInstrumentTracks( out, sParams[1] ); } else if( sValueName=="MUSICLENGTH" ) diff --git a/src/NotesLoaderSSC.cpp b/src/NotesLoaderSSC.cpp index d50942c74d..abb5a72adf 100644 --- a/src/NotesLoaderSSC.cpp +++ b/src/NotesLoaderSSC.cpp @@ -232,19 +232,7 @@ bool SSCLoader::LoadFromSSCFile( const RString &sPath, Song &out, bool bFromCach else if( sValueName=="INSTRUMENTTRACK" ) { - vector vs1; - split( sParams[1], ",", vs1 ); - FOREACH_CONST( RString, vs1, s ) - { - vector vs2; - split( *s, "=", vs2 ); - if( vs2.size() >= 2 ) - { - InstrumentTrack it = StringToInstrumentTrack( vs2[0] ); - if( it != InstrumentTrack_Invalid ) - out.m_sInstrumentTrackFile[it] = vs2[1]; - } - } + SMLoader::ProcessInstrumentTracks( out, sParams[1] ); } else if( sValueName=="MUSICLENGTH" )