From ec4e38e3aa02ef7e73798a06791c1b69762ca035 Mon Sep 17 00:00:00 2001 From: "Ben \"root\" Anderson" Date: Tue, 4 Feb 2014 12:03:20 -0600 Subject: [PATCH] Un-crackhead-ify NotesLoaderSMA. It works now. --- src/NotesLoaderSMA.cpp | 32 +++++++++++--------------------- src/NotesLoaderSMA.h | 10 ---------- 2 files changed, 11 insertions(+), 31 deletions(-) diff --git a/src/NotesLoaderSMA.cpp b/src/NotesLoaderSMA.cpp index de766ffdbc..57216c60be 100644 --- a/src/NotesLoaderSMA.cpp +++ b/src/NotesLoaderSMA.cpp @@ -161,7 +161,6 @@ bool SMALoader::LoadFromSimfile( const RString &sPath, Song &out, bool bFromCach out.m_SongTiming.m_sFile = sPath; // songs still have their fallback timing. out.m_sSongFileName = sPath; - int state = SMA_GETTING_SONG_INFO; Steps* pNewNotes = NULL; int iRowsPerBeat = -1; // Start with an invalid value: needed for checking. vector< pair > vBPMChanges, vStops; @@ -302,19 +301,15 @@ bool SMALoader::LoadFromSimfile( const RString &sPath, Song &out, bool bFromCach else { // This should generally return song timing - TimingData &timing = (state == SMA_GETTING_STEP_INFO - ? pNewNotes->m_Timing : out.m_SongTiming); + TimingData &timing = ( pNewNotes ? pNewNotes->m_Timing : out.m_SongTiming); ProcessBPMsAndStops(timing, vBPMChanges, vStops); - state = SMA_GETTING_STEP_INFO; - pNewNotes = new Steps(&out); } } else if( sValueName=="BEATSPERMEASURE" ) { - TimingData &timing = (state == SMA_GETTING_STEP_INFO - ? pNewNotes->m_Timing : out.m_SongTiming); + TimingData &timing = ( pNewNotes ? pNewNotes->m_Timing : out.m_SongTiming); ProcessBeatsPerMeasure( timing, sParams[1] ); } @@ -362,8 +357,7 @@ bool SMALoader::LoadFromSimfile( const RString &sPath, Song &out, bool bFromCach else if( sValueName=="OFFSET" ) { - TimingData &timing = (state == SMA_GETTING_STEP_INFO - ? pNewNotes->m_Timing : out.m_SongTiming); + TimingData &timing = ( pNewNotes ? pNewNotes->m_Timing : out.m_SongTiming); timing.m_fBeat0OffsetInSeconds = StringToFloat( sParams[1] ); } @@ -381,22 +375,19 @@ bool SMALoader::LoadFromSimfile( const RString &sPath, Song &out, bool bFromCach else if( sValueName=="DELAYS" ) { - TimingData &timing = (state == SMA_GETTING_STEP_INFO - ? pNewNotes->m_Timing : out.m_SongTiming); + TimingData &timing = ( pNewNotes ? pNewNotes->m_Timing : out.m_SongTiming); ProcessDelays( timing, sParams[1], iRowsPerBeat ); } else if( sValueName=="TICKCOUNT" ) { - TimingData &timing = (state == SMA_GETTING_STEP_INFO - ? pNewNotes->m_Timing : out.m_SongTiming); + TimingData &timing = ( pNewNotes ? pNewNotes->m_Timing : out.m_SongTiming); ProcessTickcounts( timing, sParams[1], iRowsPerBeat ); } else if( sValueName=="SPEED" ) { - TimingData &timing = (state == SMA_GETTING_STEP_INFO - ? pNewNotes->m_Timing : out.m_SongTiming); + TimingData &timing = ( pNewNotes ? pNewNotes->m_Timing : out.m_SongTiming); RString tmp = sParams[1]; Trim( tmp ); ProcessSpeeds( timing, tmp, iRowsPerBeat ); @@ -404,15 +395,13 @@ bool SMALoader::LoadFromSimfile( const RString &sPath, Song &out, bool bFromCach else if( sValueName=="MULTIPLIER" ) { - TimingData &timing = (state == SMA_GETTING_STEP_INFO - ? pNewNotes->m_Timing : out.m_SongTiming); + TimingData &timing = ( pNewNotes ? pNewNotes->m_Timing : out.m_SongTiming); ProcessMultipliers( timing, iRowsPerBeat, sParams[1] ); } else if( sValueName=="FAKES" ) { - TimingData &timing = (state == SMA_GETTING_STEP_INFO - ? pNewNotes->m_Timing : out.m_SongTiming); + TimingData &timing = ( pNewNotes ? pNewNotes->m_Timing : out.m_SongTiming); ProcessFakes( timing, sParams[1], iRowsPerBeat ); } @@ -444,6 +433,8 @@ bool SMALoader::LoadFromSimfile( const RString &sPath, Song &out, bool bFromCach continue; } + pNewNotes = new Steps(&out); + LoadFromTokens( sParams[1], sParams[2], @@ -456,8 +447,7 @@ bool SMALoader::LoadFromSimfile( const RString &sPath, Song &out, bool bFromCach out.AddSteps( pNewNotes ); // Handle timing changes and convert negative bpms/stops - TimingData &timing = (state == SMA_GETTING_STEP_INFO - ? pNewNotes->m_Timing : out.m_SongTiming); + TimingData &timing = ( pNewNotes ? pNewNotes->m_Timing : out.m_SongTiming); ProcessBPMsAndStops(timing, vBPMChanges, vStops); } else if( sValueName=="TIMESIGNATURES" || sValueName=="LEADTRACK" ) diff --git a/src/NotesLoaderSMA.h b/src/NotesLoaderSMA.h index f38acac470..844731905d 100644 --- a/src/NotesLoaderSMA.h +++ b/src/NotesLoaderSMA.h @@ -10,16 +10,6 @@ class Song; class Steps; class TimingData; -/** - * @brief The various states while parsing a .sma file. - */ -enum SMALoadingStates -{ - SMA_GETTING_SONG_INFO, /**< Retrieving song information. */ - SMA_GETTING_STEP_INFO, /**< Retrieving step information. */ - NUM_SMALoadingStates /**< The number of states used. */ -}; - /** @brief Reads a Song from a .SMA file. */ struct SMALoader : public SMLoader {