From b51eec691d1f6267dacf837b8e54e7f163e72130 Mon Sep 17 00:00:00 2001 From: Jason Felds Date: Fri, 24 Jun 2011 11:27:20 -0400 Subject: [PATCH] Step Attacks will be written. The cache won't be incremented until this is given some testing. --- src/NotesLoaderSM.cpp | 22 ++++++++++++---------- src/NotesLoaderSM.h | 14 +++++++++++++- src/NotesLoaderSMA.cpp | 3 ++- src/NotesLoaderSSC.cpp | 6 ++++-- src/NotesWriterSSC.cpp | 13 +++++++++++-- src/Song.cpp | 4 +++- 6 files changed, 45 insertions(+), 17 deletions(-) diff --git a/src/NotesLoaderSM.cpp b/src/NotesLoaderSM.cpp index d28588bdf6..f534e00d97 100644 --- a/src/NotesLoaderSM.cpp +++ b/src/NotesLoaderSM.cpp @@ -10,7 +10,6 @@ #include "Song.h" #include "SongManager.h" #include "Steps.h" -#include "Attack.h" #include "PrefsManager.h" void SMLoader::SetSongTitle(const RString & title) @@ -143,19 +142,21 @@ void SMLoader::ProcessBGChanges( Song &out, const RString &sValueName, const RSt } } -void SMLoader::ProcessAttacks( Song &out, MsdFile::value_t sParams ) +void SMLoader::ProcessAttackString( vector & attacks, MsdFile::value_t params ) +{ + for( unsigned s=1; s < params.params.size(); ++s ) + attacks.push_back( params[s] ); +} + +void SMLoader::ProcessAttacks( AttackArray &attacks, MsdFile::value_t params ) { - // Build the RString vector here so we can write it to file again later - for( unsigned s=1; s < sParams.params.size(); ++s ) - out.m_sAttackString.push_back( sParams[s] ); - Attack attack; float end = -9999; - for( unsigned j=1; j < sParams.params.size(); ++j ) + for( unsigned j=1; j < params.params.size(); ++j ) { vector sBits; - split( sParams[j], "=", sBits, false ); + split( params[j], "=", sBits, false ); // Need an identifer and a value for this to work if( sBits.size() < 2 ) @@ -183,7 +184,7 @@ void SMLoader::ProcessAttacks( Song &out, MsdFile::value_t sParams ) if( attack.fSecsRemaining < 0.0f ) attack.fSecsRemaining = 0.0f; - out.m_Attacks.push_back( attack ); + attacks.push_back( attack ); } } } @@ -913,7 +914,8 @@ bool SMLoader::LoadFromSimfile( const RString &sPath, Song &out, bool bFromCache // Attacks loaded from file else if( sValueName=="ATTACKS" ) { - ProcessAttacks( out, sParams ); + ProcessAttackString(out.m_sAttackString, sParams); + ProcessAttacks(out.m_Attacks, sParams); } else if( sValueName=="NOTES" || sValueName=="NOTES2" ) diff --git a/src/NotesLoaderSM.h b/src/NotesLoaderSM.h index 323fed027c..6654c5bc62 100644 --- a/src/NotesLoaderSM.h +++ b/src/NotesLoaderSM.h @@ -3,6 +3,7 @@ #include "GameConstantsAndTypes.h" #include "BackgroundUtil.h" +#include "Attack.h" #include "MsdFile.h" // we require the struct from here. class Song; @@ -133,7 +134,18 @@ struct SMLoader virtual void ProcessBGChanges( Song &out, const RString &sValueName, const RString &sPath, const RString &sParam ); - void ProcessAttacks( Song &out, MsdFile::value_t sParams ); + + /** + * @brief Put the attacks in the attacks string. + * @param attacks the attack string. + * @param params the params from the simfile. */ + virtual void ProcessAttackString(vector &attacks, MsdFile::value_t params); + + /** + * @brief Put the attacks in the attacks array. + * @param attacks the attacks array. + * @param params the params from the simfile. */ + void ProcessAttacks( AttackArray &attacks, MsdFile::value_t params ); void ProcessInstrumentTracks( Song &out, const RString &sParam ); /** diff --git a/src/NotesLoaderSMA.cpp b/src/NotesLoaderSMA.cpp index 09b9c30aa3..648d54dcca 100644 --- a/src/NotesLoaderSMA.cpp +++ b/src/NotesLoaderSMA.cpp @@ -432,7 +432,8 @@ bool SMALoader::LoadFromSimfile( const RString &sPath, Song &out, bool bFromCach // Attacks loaded from file else if( sValueName=="ATTACKS" ) { - SMLoader::ProcessAttacks( out, sParams ); + ProcessAttackString(out.m_sAttackString, sParams); + ProcessAttacks(out.m_Attacks, sParams); } else if( sValueName=="NOTES" || sValueName=="NOTES2" ) diff --git a/src/NotesLoaderSSC.cpp b/src/NotesLoaderSSC.cpp index 9e94ba4ad7..fe02b9181b 100644 --- a/src/NotesLoaderSSC.cpp +++ b/src/NotesLoaderSSC.cpp @@ -344,7 +344,8 @@ bool SSCLoader::LoadFromSimfile( const RString &sPath, Song &out, bool bFromCach // Attacks loaded from file else if( sValueName=="ATTACKS" ) { - SMLoader::ProcessAttacks( out, sParams ); + ProcessAttackString(out.m_sAttackString, sParams); + ProcessAttacks(out.m_Attacks, sParams); } else if( sValueName=="OFFSET" ) @@ -559,7 +560,8 @@ bool SSCLoader::LoadFromSimfile( const RString &sPath, Song &out, bool bFromCach else if( sValueName=="ATTACKS" ) { - // Step Attacks aren't in yet. + ProcessAttackString(pNewNotes->m_sAttackString, sParams); + ProcessAttacks(pNewNotes->m_Attacks, sParams); } else if( sValueName=="OFFSET" ) diff --git a/src/NotesWriterSSC.cpp b/src/NotesWriterSSC.cpp index cdd0659340..0e94b8e308 100644 --- a/src/NotesWriterSSC.cpp +++ b/src/NotesWriterSSC.cpp @@ -320,8 +320,17 @@ static RString GetSSCNoteData( const Song &song, const Steps &in, bool bSavingCa GetTimingTags( lines, in.m_Timing ); - // For now, attacks are NOT in use for the step. - lines.push_back( "#ATTACKS:;" ); + RString attacks = ""; + for( unsigned a=0; a < in.m_sAttackString.size(); a++ ) + { + RString sData = in.m_sAttackString[a]; + attacks += sData; + + if( a != (in.m_sAttackString.size() - 1) ) + attacks += ":"; // Not the end, so write a divider ':' + } + lines.push_back( ssprintf( "#ATTACKS:%s;", attacks.c_str())); + lines.push_back( ssprintf( "#OFFSET:%.6f;", in.m_Timing.m_fBeat0OffsetInSeconds ) ); RString sNoteData; diff --git a/src/Song.cpp b/src/Song.cpp index ba1069f731..a7ad0e399c 100644 --- a/src/Song.cpp +++ b/src/Song.cpp @@ -154,7 +154,9 @@ Steps *Song::CreateSteps() void Song::InitSteps(Steps *pSteps) { - pSteps->m_Timing = m_SongTiming; + pSteps->m_Timing = this->m_SongTiming; + pSteps->m_sAttackString = this->m_sAttackString; + pSteps->m_Attacks = this->m_Attacks; } void Song::GetDisplayBpms( DisplayBpms &AddTo ) const