diff --git a/src/NotesLoaderJson.cpp b/src/NotesLoaderJson.cpp index dab70f29ee..b80ea41753 100644 --- a/src/NotesLoaderJson.cpp +++ b/src/NotesLoaderJson.cpp @@ -31,8 +31,9 @@ static void Deserialize(StopSegment &seg, const Json::Value &root) static void Deserialize(TimingData &td, const Json::Value &root) { - JsonUtil::DeserializeVectorObjects( td.m_BPMSegments, Deserialize, root["BpmSegments"] ); - JsonUtil::DeserializeVectorObjects( td.m_StopSegments, Deserialize, root["StopSegments"] ); + vector &bpms = td.allTimingSegments[SEGMENT_BPM]; +// JsonUtil::DeserializeVectorObjects( &bpms, Deserialize, root["BpmSegments"] ); +// JsonUtil::DeserializeVectorObjects( *(td).allTimingSegments[SEGMENT_STOP_DELAY], Deserialize, root["StopSegments"] ); } static void Deserialize(LyricSegment &o, const Json::Value &root) diff --git a/src/NotesLoaderSM.cpp b/src/NotesLoaderSM.cpp index ef764b97d0..8085594f81 100644 --- a/src/NotesLoaderSM.cpp +++ b/src/NotesLoaderSM.cpp @@ -932,7 +932,8 @@ bool SMLoader::LoadFromSimfile( const RString &sPath, Song &out, bool bFromCache } // Ensure all warps from negative time changes are in order. - sort(out.m_SongTiming.m_WarpSegments.begin(), out.m_SongTiming.m_WarpSegments.end()); + vector &warps = out.m_SongTiming.allTimingSegments[SEGMENT_WARP]; + sort(warps.begin(), warps.end()); TidyUpData( out, bFromCache ); return true; } diff --git a/src/NotesWriterDWI.cpp b/src/NotesWriterDWI.cpp index 4c451d836a..e64ecd17cd 100644 --- a/src/NotesWriterDWI.cpp +++ b/src/NotesWriterDWI.cpp @@ -352,9 +352,13 @@ bool NotesWriterDWI::Write( RString sPath, const Song &out ) /* Write transliterations, if we have them, since DWI doesn't support UTF-8. */ f.PutLine( ssprintf("#TITLE:%s;", DwiEscape(out.GetTranslitFullTitle()).c_str()) ); f.PutLine( ssprintf("#ARTIST:%s;", DwiEscape(out.GetTranslitArtist()).c_str()) ); - ASSERT( out.m_SongTiming.m_BPMSegments[0].GetRow() == 0 ); + + const vector &bpms = out.m_SongTiming.allTimingSegments[SEGMENT_BPM]; + + ASSERT_M(bpms[0]->GetRow() == 0, + ssprintf("The first BPM Segment must be defined at row 0, not %d!", bpms[0]->GetRow()) ); f.PutLine( ssprintf("#FILE:%s;", DwiEscape(out.m_sMusicFile).c_str()) ); - f.PutLine( ssprintf("#BPM:%.3f;", out.m_SongTiming.m_BPMSegments[0].GetBPM()) ); + f.PutLine( ssprintf("#BPM:%.3f;", static_cast(bpms[0])->GetBPM()) ); f.PutLine( ssprintf("#GAP:%ld;", -lrintf( out.m_SongTiming.m_fBeat0OffsetInSeconds*1000 )) ); f.PutLine( ssprintf("#SAMPLESTART:%.3f;", out.m_fMusicSampleStartSeconds) ); f.PutLine( ssprintf("#SAMPLELENGTH:%.3f;", out.m_fMusicSampleLengthSeconds) ); @@ -376,29 +380,30 @@ bool NotesWriterDWI::Write( RString sPath, const Song &out ) break; } - if( !out.m_SongTiming.m_StopSegments.empty() ) + const vector &stops = out.m_SongTiming.allTimingSegments[SEGMENT_STOP_DELAY]; + if( !stops.empty() ) { f.Write( "#FREEZE:" ); - for( unsigned i=0; i(stops[i]); + f.Write( ssprintf("%.3f=%.3f", fs->GetRow() * 4.0f / ROWS_PER_BEAT, + roundf(fs->GetPause()*1000)) ); + if( i != stops.size()-1 ) f.Write( "," ); } f.PutLine( ";" ); } - if( out.m_SongTiming.m_BPMSegments.size() > 1) + if( bpms.size() > 1) { f.Write( "#CHANGEBPM:" ); - for( unsigned i=1; i(bpms[i]); + f.Write( ssprintf("%.3f=%.3f", bs->GetRow() * 4.0f / ROWS_PER_BEAT, bs->GetBPM() ) ); + if( i != bpms.size()-1 ) f.Write( "," ); } f.PutLine( ";" ); diff --git a/src/TimingData.cpp b/src/TimingData.cpp index 5ecfa97a96..8724632daa 100644 --- a/src/TimingData.cpp +++ b/src/TimingData.cpp @@ -8,14 +8,10 @@ #include -TimingData::TimingData() : - m_fBeat0OffsetInSeconds(0) -{ -} - TimingData::TimingData(float fOffset) : m_fBeat0OffsetInSeconds(fOffset) -{ +{ + // allTimingSegments[SEGMENT_BPM] = new vector(); } void TimingData::GetActualBPM( float &fMinBPMOut, float &fMaxBPMOut, float highest ) const diff --git a/src/TimingData.h b/src/TimingData.h index 27656363ed..27a3946ef4 100644 --- a/src/TimingData.h +++ b/src/TimingData.h @@ -16,14 +16,10 @@ struct lua_State; class TimingData { public: - /** - * @brief Sets up initial timing data. - */ - TimingData(); /** * @brief Sets up initial timing data with a defined offset. * @param fOffset the offset from the 0th beat. */ - TimingData(float fOffset); + TimingData(float fOffset = 0); /** * @brief Gets the actual BPM of the song, * while respecting a limit. @@ -1303,36 +1299,14 @@ public: */ bool operator==( const TimingData &other ) { - COMPARE( m_BPMSegments.size() ); - for( unsigned i=0; i m_BPMSegments; - /** - * @brief The collection of StopSegments & DelaySegments. - */ - vector m_StopSegments; - /** - * @brief The collection of TimeSignatureSegments. - */ - vector m_vTimeSignatureSegments; - /** - * @brief The collection of WarpSegments. - */ - vector m_WarpSegments; - /** - * @brief The collection of TickcountSegments. - */ - vector m_TickcountSegments; - /** - * @brief The collection of ComboSegments. - */ - vector m_ComboSegments; - /** - * @brief The collection of LabelSegments. - */ - vector m_LabelSegments; - /** @brief The collection of SpeedSegments. */ - vector m_SpeedSegments; - /** @brief The collection of ScrollSegments. */ - vector m_ScrollSegments; - /** @brief The collection of FakeSegments. */ - vector m_FakeSegments; + + + vector allTimingSegments[NUM_TimingSegmentTypes]; /** * @brief The initial offset of a song.