From 6f5ab98deced7fb3ab0088e67a551a8b4259675d Mon Sep 17 00:00:00 2001 From: Jason Felds Date: Thu, 14 Jul 2011 23:15:48 -0400 Subject: [PATCH] [timing] More respect of pointers. Again going to trust virtual functions to do the right thing. --- src/NotesLoaderSM.cpp | 8 +- src/Player.cpp | 4 +- src/ScoreKeeperNormal.cpp | 14 +-- src/ScreenEdit.cpp | 26 +++--- src/ScreenSyncOverlay.cpp | 4 +- src/TimingData.cpp | 181 ++++++++++++++++++-------------------- src/TimingData.h | 48 +++++----- 7 files changed, 139 insertions(+), 146 deletions(-) diff --git a/src/NotesLoaderSM.cpp b/src/NotesLoaderSM.cpp index 33a1791033..ba3ea24e50 100644 --- a/src/NotesLoaderSM.cpp +++ b/src/NotesLoaderSM.cpp @@ -310,8 +310,8 @@ void SMLoader::ProcessStops( TimingData &out, const RString line, const int rows // Process the prior stop. if( negPause > 0 ) { - BPMSegment oldBPM = out.GetBPMSegmentAtRow(BeatToNoteRow(negBeat)); - float fSecondsPerBeat = 60 / oldBPM.GetBPM(); + BPMSegment * oldBPM = out.GetBPMSegmentAtRow(BeatToNoteRow(negBeat)); + float fSecondsPerBeat = 60 / oldBPM->GetBPM(); float fSkipBeats = negPause / fSecondsPerBeat; if( negBeat + fSkipBeats > fFreezeBeat ) @@ -339,8 +339,8 @@ void SMLoader::ProcessStops( TimingData &out, const RString line, const int rows // Process the prior stop if there was one. if( negPause > 0 ) { - BPMSegment oldBPM = out.GetBPMSegmentAtBeat(negBeat); - float fSecondsPerBeat = 60 / oldBPM.GetBPM(); + BPMSegment * oldBPM = out.GetBPMSegmentAtBeat(negBeat); + float fSecondsPerBeat = 60 / oldBPM->GetBPM(); float fSkipBeats = negPause / fSecondsPerBeat; out.AddSegment(SEGMENT_WARP, new WarpSegment(negBeat, fSkipBeats)); diff --git a/src/Player.cpp b/src/Player.cpp index 8638d33cff..01220e9067 100644 --- a/src/Player.cpp +++ b/src/Player.cpp @@ -2956,10 +2956,10 @@ void Player::CrossedRows( int iLastRowCrossed, const RageTimer &now ) } else if( CHECKPOINTS_USE_TIME_SIGNATURES ) { - TimeSignatureSegment & tSignature = m_Timing->GetTimeSignatureSegmentAtRow( iLastRowCrossed ); + TimeSignatureSegment * tSignature = m_Timing->GetTimeSignatureSegmentAtRow( iLastRowCrossed ); // Most songs are in 4/4 time. The frequency for checking tick counts should reflect that. - iCheckpointFrequencyRows = ROWS_PER_BEAT * tSignature.GetDen() / (tSignature.GetNum() * 4); + iCheckpointFrequencyRows = ROWS_PER_BEAT * tSignature->GetDen() / (tSignature->GetNum() * 4); } if( iCheckpointFrequencyRows > 0 ) diff --git a/src/ScoreKeeperNormal.cpp b/src/ScoreKeeperNormal.cpp index 07b2cbd213..695c640a28 100644 --- a/src/ScoreKeeperNormal.cpp +++ b/src/ScoreKeeperNormal.cpp @@ -429,14 +429,14 @@ void ScoreKeeperNormal::HandleTapNoteScoreInternal( TapNoteScore tns, TapNoteSco // update judged row totals. Respect Combo segments here. TimingData &td = GAMESTATE->m_pCurSteps[m_pPlayerState->m_PlayerNumber]->m_Timing; - ComboSegment &cs = td.GetComboSegmentAtRow(row); + ComboSegment *cs = td.GetComboSegmentAtRow(row); if (tns == TNS_CheckpointHit || tns >= m_MinScoreToContinueCombo) { - m_pPlayerStageStats->m_iTapNoteScores[tns] += cs.GetCombo(); + m_pPlayerStageStats->m_iTapNoteScores[tns] += cs->GetCombo(); } else if (tns == TNS_CheckpointMiss || tns < m_MinScoreToMaintainCombo) { - m_pPlayerStageStats->m_iTapNoteScores[tns] += cs.GetMissCombo(); + m_pPlayerStageStats->m_iTapNoteScores[tns] += cs->GetMissCombo(); } else { @@ -464,13 +464,13 @@ void ScoreKeeperNormal::HandleComboInternal( int iNumHitContinueCombo, int iNumH TimingData td = GAMESTATE->m_pCurSteps[m_pPlayerState->m_PlayerNumber]->m_Timing; if( iNumBreakCombo == 0 ) { - int multiplier = ( iRow == -1 ? 1 : td.GetComboSegmentAtRow( iRow ).GetCombo() ); + int multiplier = ( iRow == -1 ? 1 : td.GetComboSegmentAtRow( iRow )->GetCombo() ); m_pPlayerStageStats->m_iCurCombo += iNumHitContinueCombo * multiplier; } else { m_pPlayerStageStats->m_iCurCombo = 0; - int multiplier = ( iRow == -1 ? 1 : td.GetComboSegmentAtRow(iRow).GetMissCombo()); + int multiplier = ( iRow == -1 ? 1 : td.GetComboSegmentAtRow(iRow)->GetMissCombo()); m_pPlayerStageStats->m_iCurMissCombo += ( m_MissComboIsPerRow ? 1 : iNumBreakCombo ) * multiplier; } } @@ -485,7 +485,7 @@ void ScoreKeeperNormal::HandleRowComboInternal( TapNoteScore tns, int iNumTapsIn if ( tns >= m_MinScoreToContinueCombo ) { m_pPlayerStageStats->m_iCurMissCombo = 0; - int multiplier = ( iRow == -1 ? 1 : td.GetComboSegmentAtRow( iRow ).GetCombo() ); + int multiplier = ( iRow == -1 ? 1 : td.GetComboSegmentAtRow( iRow )->GetCombo() ); m_pPlayerStageStats->m_iCurCombo += iNumTapsInRow * multiplier; } else if ( tns < m_MinScoreToMaintainCombo ) @@ -494,7 +494,7 @@ void ScoreKeeperNormal::HandleRowComboInternal( TapNoteScore tns, int iNumTapsIn if( tns <= m_MaxScoreToIncrementMissCombo ) { - int multiplier = ( iRow == -1 ? 1 : td.GetComboSegmentAtRow(iRow).GetMissCombo()); + int multiplier = ( iRow == -1 ? 1 : td.GetComboSegmentAtRow(iRow)->GetMissCombo()); m_pPlayerStageStats->m_iCurMissCombo += ( m_MissComboIsPerRow ? 1 : iNumTapsInRow ) * multiplier; } } diff --git a/src/ScreenEdit.cpp b/src/ScreenEdit.cpp index c7b7039ae8..a7d5cec57d 100644 --- a/src/ScreenEdit.cpp +++ b/src/ScreenEdit.cpp @@ -1465,7 +1465,7 @@ void ScreenEdit::InputEdit( const InputEventPlus &input, EditButton EditB ) } TimingData &sTiming = GetAppropriateTiming(); float playerBeat = GetAppropriatePosition().m_fSongBeat; - int beatsPerMeasure = sTiming.GetTimeSignatureSegmentAtBeat( playerBeat ).GetNum(); + int beatsPerMeasure = sTiming.GetTimeSignatureSegmentAtBeat( playerBeat )->GetNum(); switch( EditB ) { @@ -3648,7 +3648,7 @@ void ScreenEdit::DisplayTimingMenu() { float fBeat = GetBeat(); TimingData &pTime = GetAppropriateTiming(); - bool bHasSpeedOnThisRow = pTime.GetSpeedSegmentAtBeat( fBeat ).GetBeat() == fBeat; + bool bHasSpeedOnThisRow = pTime.GetSpeedSegmentAtBeat( fBeat )->GetBeat() == fBeat; g_TimingDataInformation.rows[beat_0_offset].SetOneUnthemedChoice( ssprintf("%.6f", pTime.m_fBeat0OffsetInSeconds) ); g_TimingDataInformation.rows[bpm].SetOneUnthemedChoice( ssprintf("%.6f", pTime.GetBPMAtBeat( fBeat ) ) ); @@ -4647,11 +4647,11 @@ void ScreenEdit::HandleTimingDataInformationChoice( TimingDataInformationChoice break; case time_signature: { - TimeSignatureSegment &ts = GetAppropriateTiming().GetTimeSignatureSegmentAtBeat( GetBeat() ); + TimeSignatureSegment * ts = GetAppropriateTiming().GetTimeSignatureSegmentAtBeat( GetBeat() ); ScreenTextEntry::TextEntry( SM_BackFromTimeSignatureChange, ENTER_TIME_SIGNATURE_VALUE, - ssprintf( "%d/%d", ts.GetNum(), ts.GetDen() ), + ssprintf( "%d/%d", ts->GetNum(), ts->GetDen() ), 8 ); break; @@ -4666,12 +4666,12 @@ void ScreenEdit::HandleTimingDataInformationChoice( TimingDataInformationChoice break; case combo: { - ComboSegment &cs = GetAppropriateTiming().GetComboSegmentAtBeat(GetBeat()); + ComboSegment *cs = GetAppropriateTiming().GetComboSegmentAtBeat(GetBeat()); ScreenTextEntry::TextEntry(SM_BackFromComboChange, ENTER_COMBO_VALUE, ssprintf( "%d/%d", - cs.GetCombo(), - cs.GetMissCombo()), + cs->GetCombo(), + cs->GetMissCombo()), 7); break; } @@ -4695,7 +4695,7 @@ void ScreenEdit::HandleTimingDataInformationChoice( TimingDataInformationChoice ScreenTextEntry::TextEntry( SM_BackFromSpeedPercentChange, ENTER_SPEED_PERCENT_VALUE, - ssprintf( "%.6f", GetAppropriateTiming().GetSpeedSegmentAtBeat( GetBeat() ).GetRatio() ), + ssprintf( "%.6f", GetAppropriateTiming().GetSpeedSegmentAtBeat( GetBeat() )->GetRatio() ), 10 ); break; @@ -4703,7 +4703,7 @@ void ScreenEdit::HandleTimingDataInformationChoice( TimingDataInformationChoice ScreenTextEntry::TextEntry( SM_BackFromScrollChange, ENTER_SCROLL_VALUE, - ssprintf( "%.6f", GetAppropriateTiming().GetScrollSegmentAtBeat( GetBeat() ).GetRatio() ), + ssprintf( "%.6f", GetAppropriateTiming().GetScrollSegmentAtBeat( GetBeat() )->GetRatio() ), 10 ); break; @@ -4711,7 +4711,7 @@ void ScreenEdit::HandleTimingDataInformationChoice( TimingDataInformationChoice ScreenTextEntry::TextEntry( SM_BackFromSpeedWaitChange, ENTER_SPEED_WAIT_VALUE, - ssprintf( "%.6f", GetAppropriateTiming().GetSpeedSegmentAtBeat( GetBeat() ).GetLength() ), + ssprintf( "%.6f", GetAppropriateTiming().GetSpeedSegmentAtBeat( GetBeat() )->GetLength() ), 10 ); break; @@ -4982,8 +4982,8 @@ void ScreenEdit::CheckNumberOfNotesAndUndo() if( EDIT_MODE.GetValue() != EditMode_Home ) return; - TimeSignatureSegment &curTime = GAMESTATE->m_pCurSong->m_SongTiming.GetTimeSignatureSegmentAtBeat( GAMESTATE->m_pPlayerState[PLAYER_1]->m_Position.m_fSongBeat ); - int rowsPerMeasure = curTime.GetDen() * curTime.GetNum(); + TimeSignatureSegment * curTime = GAMESTATE->m_pCurSong->m_SongTiming.GetTimeSignatureSegmentAtBeat( GAMESTATE->m_pPlayerState[PLAYER_1]->m_Position.m_fSongBeat ); + int rowsPerMeasure = curTime->GetDen() * curTime->GetNum(); for( int row=0; row<=m_NoteDataEdit.GetLastRow(); row+=rowsPerMeasure ) { @@ -5037,7 +5037,7 @@ float ScreenEdit::GetMaximumBeatForNewNote() const * beats. */ TimingData &timing = s.m_SongTiming; float playerBeat = GetAppropriatePosition().m_fSongBeat; - int beatsPerMeasure = timing.GetTimeSignatureSegmentAtBeat( playerBeat ).GetNum(); + int beatsPerMeasure = timing.GetTimeSignatureSegmentAtBeat( playerBeat )->GetNum(); fEndBeat += beatsPerMeasure; fEndBeat = ftruncf( fEndBeat, (float)beatsPerMeasure ); diff --git a/src/ScreenSyncOverlay.cpp b/src/ScreenSyncOverlay.cpp index e91cf6569d..a0d9f6c6a8 100644 --- a/src/ScreenSyncOverlay.cpp +++ b/src/ScreenSyncOverlay.cpp @@ -221,8 +221,8 @@ bool ScreenSyncOverlay::OverlayInput( const InputEventPlus &input ) } if( GAMESTATE->m_pCurSong != NULL ) { - BPMSegment& seg = GAMESTATE->m_pCurSong->m_SongTiming.GetBPMSegmentAtBeat( GAMESTATE->m_Position.m_fSongBeat ); - seg.SetBPS( seg.GetBPS() + fDelta ); + BPMSegment * seg = GAMESTATE->m_pCurSong->m_SongTiming.GetBPMSegmentAtBeat( GAMESTATE->m_Position.m_fSongBeat ); + seg->SetBPS( seg->GetBPS() + fDelta ); } } break; diff --git a/src/TimingData.cpp b/src/TimingData.cpp index 7afa848e2d..2ee7737f92 100644 --- a/src/TimingData.cpp +++ b/src/TimingData.cpp @@ -160,13 +160,13 @@ void TimingData::SetTimeSignatureNumeratorAtRow( int iRow, int iNumerator ) { this->SetTimeSignatureAtRow(iRow, iNumerator, - GetTimeSignatureSegmentAtRow(iRow).GetDen()); + GetTimeSignatureSegmentAtRow(iRow)->GetDen()); } void TimingData::SetTimeSignatureDenominatorAtRow( int iRow, int iDenominator ) { this->SetTimeSignatureAtRow(iRow, - GetTimeSignatureSegmentAtRow(iRow).GetNum(), + GetTimeSignatureSegmentAtRow(iRow)->GetNum(), iDenominator); } @@ -258,13 +258,13 @@ void TimingData::SetHitComboAtRow(int iRow, int iCombo) { this->SetComboAtRow(iRow, iCombo, - this->GetComboSegmentAtRow(iRow).GetMissCombo()); + this->GetComboSegmentAtRow(iRow)->GetMissCombo()); } void TimingData::SetMissComboAtRow(int iRow, int iMiss) { this->SetComboAtRow(iRow, - this->GetComboSegmentAtRow(iRow).GetCombo(), + this->GetComboSegmentAtRow(iRow)->GetCombo(), iMiss); } @@ -390,23 +390,23 @@ void TimingData::SetSpeedPercentAtRow( int iRow, float fPercent ) { SetSpeedAtRow( iRow, fPercent, - GetSpeedSegmentAtBeat( NoteRowToBeat( iRow ) ).GetLength(), - GetSpeedSegmentAtBeat( NoteRowToBeat( iRow ) ).GetUnit()); + GetSpeedSegmentAtRow( iRow )->GetLength(), + GetSpeedSegmentAtRow( iRow )->GetUnit()); } void TimingData::SetSpeedWaitAtRow( int iRow, float fWait ) { SetSpeedAtRow( iRow, - GetSpeedSegmentAtBeat( NoteRowToBeat( iRow ) ).GetRatio(), + GetSpeedSegmentAtRow( iRow )->GetRatio(), fWait, - GetSpeedSegmentAtBeat( NoteRowToBeat( iRow ) ).GetUnit()); + GetSpeedSegmentAtRow( iRow )->GetUnit()); } void TimingData::SetSpeedModeAtRow( int iRow, unsigned short usMode ) { SetSpeedAtRow( iRow, - GetSpeedSegmentAtBeat( NoteRowToBeat( iRow ) ).GetRatio(), - GetSpeedSegmentAtBeat( NoteRowToBeat( iRow ) ).GetLength(), + GetSpeedSegmentAtRow( iRow )->GetRatio(), + GetSpeedSegmentAtRow( iRow )->GetLength(), usMode ); } @@ -472,22 +472,22 @@ float TimingData::GetWarpAtRow( int iWarpRow ) const float TimingData::GetSpeedPercentAtRow( int iRow ) { - return GetSpeedSegmentAtRow( iRow ).GetRatio(); + return GetSpeedSegmentAtRow( iRow )->GetRatio(); } float TimingData::GetSpeedWaitAtRow( int iRow ) { - return GetSpeedSegmentAtRow( iRow ).GetLength(); + return GetSpeedSegmentAtRow( iRow )->GetLength(); } unsigned short TimingData::GetSpeedModeAtRow( int iRow ) { - return GetSpeedSegmentAtRow( iRow ).GetUnit(); + return GetSpeedSegmentAtRow( iRow )->GetUnit(); } float TimingData::GetScrollAtRow( int iRow ) { - return GetScrollSegmentAtRow( iRow ).GetRatio(); + return GetScrollSegmentAtRow( iRow )->GetRatio(); } float TimingData::GetFakeAtRow( int iFakeRow ) const @@ -597,114 +597,122 @@ bool TimingData::IsFakeAtRow( int iNoteRow ) const return false; } -BPMSegment& TimingData::GetBPMSegmentAtRow( int iNoteRow ) +BPMSegment* TimingData::GetBPMSegmentAtRow( int iNoteRow ) { + vector &bpms = this->allTimingSegments[SEGMENT_BPM]; static BPMSegment empty; - if( m_BPMSegments.empty() ) - return empty; + if( bpms.empty() ) + return new BPMSegment(); int i = GetSegmentIndexAtRow( SEGMENT_BPM, iNoteRow ); - return m_BPMSegments[i]; + return static_cast(bpms[i]); } -TimeSignatureSegment& TimingData::GetTimeSignatureSegmentAtRow( int iRow ) +TimeSignatureSegment* TimingData::GetTimeSignatureSegmentAtRow( int iRow ) { unsigned i; - for( i=0; i iRow ) + vector &tSigs = this->allTimingSegments[SEGMENT_TIME_SIG]; + for( i=0; iGetRow() > iRow ) break; - return m_vTimeSignatureSegments[i]; + return static_cast(tSigs[i]); } -SpeedSegment& TimingData::GetSpeedSegmentAtRow( int iRow ) +SpeedSegment* TimingData::GetSpeedSegmentAtRow( int iRow ) { unsigned i; - for( i=0; i iRow ) + vector &speeds = this->allTimingSegments[SEGMENT_SPEED]; + for( i=0; iGetRow() > iRow ) break; - return m_SpeedSegments[i]; + return static_cast(speeds[i]); } -ScrollSegment& TimingData::GetScrollSegmentAtRow( int iRow ) +ScrollSegment* TimingData::GetScrollSegmentAtRow( int iRow ) { unsigned i; - for( i=0; i iRow ) + vector &scrolls = this->allTimingSegments[SEGMENT_SCROLL]; + for( i=0; iGetRow() > iRow ) break; - return m_ScrollSegments[i]; + return static_cast(scrolls[i]); } int TimingData::GetTimeSignatureNumeratorAtRow( int iRow ) { - return GetTimeSignatureSegmentAtRow( iRow ).GetNum(); + return GetTimeSignatureSegmentAtRow( iRow )->GetNum(); } int TimingData::GetTimeSignatureDenominatorAtRow( int iRow ) { - return GetTimeSignatureSegmentAtRow( iRow ).GetDen(); + return GetTimeSignatureSegmentAtRow( iRow )->GetDen(); } -ComboSegment& TimingData::GetComboSegmentAtRow( int iRow ) +ComboSegment* TimingData::GetComboSegmentAtRow( int iRow ) { unsigned i; - for( i=0; i iRow ) + vector &combos = this->allTimingSegments[SEGMENT_COMBO]; + for( i=0; iGetRow() > iRow ) break; - return m_ComboSegments[i]; + return static_cast(combos[i]); } -LabelSegment& TimingData::GetLabelSegmentAtRow( int iRow ) +LabelSegment* TimingData::GetLabelSegmentAtRow( int iRow ) { unsigned i; - for( i=0; i iRow ) + vector &labels = this->allTimingSegments[SEGMENT_LABEL]; + for( i=0; iGetRow() > iRow ) break; - return m_LabelSegments[i]; + return static_cast(labels[i]); } -StopSegment& TimingData::GetStopSegmentAtRow( int iNoteRow, bool bDelay ) +StopSegment* TimingData::GetStopSegmentAtRow( int iNoteRow, bool bDelay ) { - static StopSegment empty; - if( m_StopSegments.empty() ) - return empty; + vector &stops = this->allTimingSegments[SEGMENT_STOP_DELAY]; + if( stops.empty() ) + return new StopSegment(); int i = GetSegmentIndexAtRow( SEGMENT_STOP_DELAY, iNoteRow, bDelay ); - return m_StopSegments[i]; + return static_cast(stops[i]); } -WarpSegment& TimingData::GetWarpSegmentAtRow( int iRow ) +WarpSegment* TimingData::GetWarpSegmentAtRow( int iRow ) { - static WarpSegment empty; - if( m_WarpSegments.empty() ) - return empty; + vector &warps = this->allTimingSegments[SEGMENT_WARP]; + if( warps.empty() ) + return new WarpSegment(); int i = GetSegmentIndexAtRow( SEGMENT_WARP, iRow ); - return m_WarpSegments[i]; + return static_cast(warps[i]); } -FakeSegment& TimingData::GetFakeSegmentAtRow( int iRow ) +FakeSegment* TimingData::GetFakeSegmentAtRow( int iRow ) { - static FakeSegment empty; - if( m_FakeSegments.empty() ) - return empty; + vector &fakes = this->allTimingSegments[SEGMENT_FAKE]; + if( fakes.empty() ) + return new FakeSegment(); int i = GetSegmentIndexAtRow( SEGMENT_FAKE, iRow ); - return m_FakeSegments[i]; + return static_cast(fakes[i]); } -TickcountSegment& TimingData::GetTickcountSegmentAtRow( int iRow ) +TickcountSegment* TimingData::GetTickcountSegmentAtRow( int iRow ) { - static TickcountSegment empty; - if( m_TickcountSegments.empty() ) - return empty; + vector &ticks = this->allTimingSegments[SEGMENT_TICKCOUNT]; + if( ticks.empty() ) + return new TickcountSegment(); int i = GetSegmentIndexAtRow( SEGMENT_TICKCOUNT, iRow ); - return m_TickcountSegments[i]; + return static_cast(ticks[i]); } int TimingData::GetTickcountAtRow( int iRow ) const { - return m_TickcountSegments[GetSegmentIndexAtRow( SEGMENT_TICKCOUNT, iRow )].GetTicks(); + const vector &ticks = this->allTimingSegments[SEGMENT_TICKCOUNT]; + const int index = GetSegmentIndexAtRow( SEGMENT_TICKCOUNT, iRow ); + return static_cast(ticks[index])->GetTicks(); } float TimingData::GetPreviousBPMSegmentBeatAtRow( int iRow ) const @@ -1017,9 +1025,10 @@ float TimingData::GetNextLabelSegmentBeatAtRow( int iRow ) const bool TimingData::DoesLabelExist( RString sLabel ) const { - FOREACH_CONST( LabelSegment, m_LabelSegments, seg ) + const vector &labels = this->allTimingSegments[SEGMENT_LABEL]; + for (unsigned i = 0; i < labels.size(); i++) { - if( seg->GetLabel() == sLabel ) + if (static_cast(labels[i])->GetLabel() == sLabel) return true; } return false; @@ -1264,35 +1273,15 @@ void TimingData::ScaleRegion( float fScale, int iStartIndex, int iEndIndex, bool int length = iEndIndex - iStartIndex; int newLength = lrintf( fScale * length ); - for ( unsigned i = 0; i < m_BPMSegments.size(); i++ ) - m_BPMSegments[i].Scale( iStartIndex, length, newLength ); - - for( unsigned i = 0; i < m_StopSegments.size(); i++ ) - m_StopSegments[i].Scale( iStartIndex, length, newLength ); - - for( unsigned i = 0; i < m_vTimeSignatureSegments.size(); i++ ) - m_vTimeSignatureSegments[i].Scale( iStartIndex, length, newLength ); - - for( unsigned i = 0; i < m_WarpSegments.size(); i++ ) - m_WarpSegments[i].Scale( iStartIndex, length, newLength ); - - for ( unsigned i = 0; i < m_TickcountSegments.size(); i++ ) - m_TickcountSegments[i].Scale( iStartIndex, length, newLength ); - - for ( unsigned i = 0; i < m_ComboSegments.size(); i++ ) - m_ComboSegments[i].Scale( iStartIndex, length, newLength ); - - for ( unsigned i = 0; i < m_LabelSegments.size(); i++ ) - m_LabelSegments[i].Scale( iStartIndex, length, newLength ); - - for ( unsigned i = 0; i < m_SpeedSegments.size(); i++ ) - m_SpeedSegments[i].Scale( iStartIndex, length, newLength ); - - for( unsigned i = 0; i < m_FakeSegments.size(); i++ ) - m_FakeSegments[i].Scale( iStartIndex, length, newLength ); - - for( unsigned i = 0; i < m_ScrollSegments.size(); i++ ) - m_ScrollSegments[i].Scale( iStartIndex, length, newLength ); + // TODO: Confirm this works as intended. + for (unsigned i = 0; i < NUM_TimingSegmentTypes; i++) + { + vector &segs = this->allTimingSegments[i]; + for (unsigned j = 0; j < segs.size(); j++) + { + segs[i][j].Scale(iStartIndex, length, newLength); + } + } // adjust BPM changes to preserve timing if( bAdjustBPM ) @@ -1512,12 +1501,16 @@ bool TimingData::HasFakes() const bool TimingData::HasSpeedChanges() const { - return m_SpeedSegments.size()>1 || m_SpeedSegments[0].GetRatio() != 1; + const vector &speeds = this->allTimingSegments[SEGMENT_SPEED]; + return (speeds.size()>1 || + static_cast(speeds[0])->GetRatio() != 1); } bool TimingData::HasScrollChanges() const { - return m_ScrollSegments.size()>1 || m_ScrollSegments[0].GetRatio() != 1; + const vector &scrolls = this->allTimingSegments[SEGMENT_SCROLL]; + return (scrolls.size()>1 || + static_cast(scrolls[0])->GetRatio() != 1); } void TimingData::NoteRowToMeasureAndBeat( int iNoteRow, int &iMeasureIndexOut, int &iBeatIndexOut, int &iRowsRemainder ) const diff --git a/src/TimingData.h b/src/TimingData.h index 795ab57d07..d9ee7e2c6f 100644 --- a/src/TimingData.h +++ b/src/TimingData.h @@ -72,13 +72,13 @@ public: * @param iNoteRow the row that has a BPMSegment. * @return the BPMSegment in question. */ - BPMSegment& GetBPMSegmentAtRow( int iNoteRow ); + BPMSegment* GetBPMSegmentAtRow( int iNoteRow ); /** * @brief Retrieve the BPMSegment at the specified beat. * @param fBeat the beat that has a BPMSegment. * @return the BPMSegment in question. */ - BPMSegment& GetBPMSegmentAtBeat( float fBeat ) { return GetBPMSegmentAtRow( (int)BeatToNoteRow(fBeat)); } + BPMSegment* GetBPMSegmentAtBeat( float fBeat ) { return GetBPMSegmentAtRow( (int)BeatToNoteRow(fBeat)); } /** * @brief Retrieve the next beat that contains a BPMSegment. @@ -201,39 +201,39 @@ public: * @param iNoteRow the row that has a StopSegment. * @return the StopSegment in question. */ - StopSegment& GetStopSegmentAtRow( int iNoteRow ) { return GetStopSegmentAtRow( iNoteRow, false ); } + StopSegment* GetStopSegmentAtRow( int iNoteRow ) { return GetStopSegmentAtRow( iNoteRow, false ); } /** * @brief Retrieve the StopSegment at the specified beat. * @param fBeat the beat that has a StopSegment. * @return the StopSegment in question. */ - StopSegment& GetStopSegmentAtBeat( float fBeat ) { return GetStopSegmentAtRow( BeatToNoteRow(fBeat), false); } + StopSegment* GetStopSegmentAtBeat( float fBeat ) { return GetStopSegmentAtRow( BeatToNoteRow(fBeat), false); } /** * @brief Retrieve the StopSegment at the specified row. * @param iNoteRow the row that has a StopSegment. * @param bDelay If true, this is actually a DelaySegment. * @return the StopSegment in question. */ - StopSegment& GetStopSegmentAtRow( int iNoteRow, bool bDelay ); + StopSegment* GetStopSegmentAtRow( int iNoteRow, bool bDelay ); /** * @brief Retrieve the StopSegment at the specified beat. * @param fBeat the beat that has a StopSegment. * @param bDelay If true, this is actually a DelaySegment. * @return the StopSegment in question. */ - StopSegment& GetStopSegmentAtBeat( float fBeat, bool bDelay ) { return GetStopSegmentAtRow( BeatToNoteRow(fBeat), bDelay ); } + StopSegment* GetStopSegmentAtBeat( float fBeat, bool bDelay ) { return GetStopSegmentAtRow( BeatToNoteRow(fBeat), bDelay ); } /** * @brief Retrieve the DelaySegment at the specified row. * @param iNoteRow the row that has a DelaySegment. * @return the DelaySegment in question. */ - StopSegment& GetDelaySegmentAtRow( int iNoteRow ) { return GetStopSegmentAtRow( iNoteRow, true ); } + StopSegment* GetDelaySegmentAtRow( int iNoteRow ) { return GetStopSegmentAtRow( iNoteRow, true ); } /** * @brief Retrieve the DelaySegment at the specified beat. * @param fBeat the beat that has a DelaySegment. * @return the DelaySegment in question. */ - StopSegment& GetDelaySegmentAtBeat( float fBeat ) { return GetStopSegmentAtRow( BeatToNoteRow(fBeat), true); } + StopSegment* GetDelaySegmentAtBeat( float fBeat ) { return GetStopSegmentAtRow( BeatToNoteRow(fBeat), true); } /** * @brief Retrieve the index of the StopSegments at the specified row. * @param iNoteRow the row that has a StopSegment. @@ -363,13 +363,13 @@ public: * @param iNoteRow the row that has a TimeSignatureSegment. * @return the TimeSignatureSegment in question. */ - TimeSignatureSegment& GetTimeSignatureSegmentAtRow( int iNoteRow ); + TimeSignatureSegment* GetTimeSignatureSegmentAtRow( int iNoteRow ); /** * @brief Retrieve the TimeSignatureSegment at the specified beat. * @param fBeat the beat that has a TimeSignatureSegment. * @return the TimeSignatureSegment in question. */ - TimeSignatureSegment& GetTimeSignatureSegmentAtBeat( float fBeat ) { return GetTimeSignatureSegmentAtRow( BeatToNoteRow(fBeat) ); } + TimeSignatureSegment* GetTimeSignatureSegmentAtBeat( float fBeat ) { return GetTimeSignatureSegmentAtRow( BeatToNoteRow(fBeat) ); } /** @@ -432,13 +432,13 @@ public: * @param iRow the row to focus on. * @return the WarpSegment in question. */ - WarpSegment& GetWarpSegmentAtRow( int iRow ); + WarpSegment* GetWarpSegmentAtRow( int iRow ); /** * @brief Retrieve the WarpSegment at the specified beat. * @param fBeat the beat to focus on. * @return the WarpSegment in question. */ - WarpSegment& GetWarpSegmentAtBeat( float fBeat ) { return GetWarpSegmentAtRow( BeatToNoteRow( fBeat ) ); } + WarpSegment* GetWarpSegmentAtBeat( float fBeat ) { return GetWarpSegmentAtRow( BeatToNoteRow( fBeat ) ); } /** * @brief Checks if the row is inside a warp. * @param iRow the row to focus on. @@ -513,13 +513,13 @@ public: * @param iNoteRow the row that has a TickcountSegment. * @return the TickcountSegment in question. */ - TickcountSegment& GetTickcountSegmentAtRow( int iNoteRow ); + TickcountSegment* GetTickcountSegmentAtRow( int iNoteRow ); /** * @brief Retrieve the TickcountSegment at the specified beat. * @param fBeat the beat that has a TickcountSegment. * @return the TickcountSegment in question. */ - TickcountSegment& GetTickcountSegmentAtBeat( float fBeat ) { return GetTickcountSegmentAtRow( BeatToNoteRow(fBeat) ); } + TickcountSegment* GetTickcountSegmentAtBeat( float fBeat ) { return GetTickcountSegmentAtRow( BeatToNoteRow(fBeat) ); } /** * @brief Retrieve the next beat that contains a TickcountSegment. @@ -632,13 +632,13 @@ public: * @param iNoteRow the row that has a ComboSegment. * @return the ComboSegment in question. */ - ComboSegment& GetComboSegmentAtRow( int iNoteRow ); + ComboSegment* GetComboSegmentAtRow( int iNoteRow ); /** * @brief Retrieve the ComboSegment at the specified beat. * @param fBeat the beat that has a ComboSegment. * @return the ComboSegment in question. */ - ComboSegment& GetComboSegmentAtBeat( float fBeat ) { return GetComboSegmentAtRow( BeatToNoteRow(fBeat) ); } + ComboSegment* GetComboSegmentAtBeat( float fBeat ) { return GetComboSegmentAtRow( BeatToNoteRow(fBeat) ); } /** * @brief Retrieve the next beat that contains a ComboSegment. @@ -701,13 +701,13 @@ public: * @param iNoteRow the row that has a LabelSegment. * @return the LabelSegment in question. */ - LabelSegment& GetLabelSegmentAtRow( int iNoteRow ); + LabelSegment* GetLabelSegmentAtRow( int iNoteRow ); /** * @brief Retrieve the LabelSegment at the specified beat. * @param fBeat the beat that has a LabelSegment. * @return the LabelSegment in question. */ - LabelSegment& GetLabelSegmentAtBeat( float fBeat ) { return GetLabelSegmentAtRow( BeatToNoteRow(fBeat) ); } + LabelSegment* GetLabelSegmentAtBeat( float fBeat ) { return GetLabelSegmentAtRow( BeatToNoteRow(fBeat) ); } /** * @brief Retrieve the previous beat that contains a LabelSegment. @@ -841,13 +841,13 @@ public: * @param iNoteRow the row that has a SpeedSegment. * @return the SpeedSegment in question. */ - SpeedSegment& GetSpeedSegmentAtRow( int iNoteRow ); + SpeedSegment* GetSpeedSegmentAtRow( int iNoteRow ); /** * @brief Retrieve the SpeedSegment at the specified beat. * @param fBeat the beat that has a SpeedSegment. * @return the SpeedSegment in question. */ - SpeedSegment& GetSpeedSegmentAtBeat( float fBeat ) { return GetSpeedSegmentAtRow( BeatToNoteRow(fBeat) ); } + SpeedSegment* GetSpeedSegmentAtBeat( float fBeat ) { return GetSpeedSegmentAtRow( BeatToNoteRow(fBeat) ); } float GetDisplayedSpeedPercent( float fBeat, float fMusicSeconds ) const; @@ -914,13 +914,13 @@ public: * @param iNoteRow the row that has a ScrollSegment. * @return the ScrollSegment in question. */ - ScrollSegment& GetScrollSegmentAtRow( int iNoteRow ); + ScrollSegment* GetScrollSegmentAtRow( int iNoteRow ); /** * @brief Retrieve the ScrollSegment at the specified beat. * @param fBeat the beat that has a ScrollSegment. * @return the ScrollSegment in question. */ - ScrollSegment& GetScrollSegmentAtBeat( float fBeat ) { return GetScrollSegmentAtRow( BeatToNoteRow(fBeat) ); } + ScrollSegment* GetScrollSegmentAtBeat( float fBeat ) { return GetScrollSegmentAtRow( BeatToNoteRow(fBeat) ); } /** * @brief Retrieve the next beat that contains a ScrollSegment. @@ -983,13 +983,13 @@ public: * @param iRow the row to focus on. * @return the FakeSegment in question. */ - FakeSegment& GetFakeSegmentAtRow( int iRow ); + FakeSegment* GetFakeSegmentAtRow( int iRow ); /** * @brief Retrieve the FakeSegment at the specified beat. * @param fBeat the beat to focus on. * @return the FakeSegment in question. */ - FakeSegment& GetFakeSegmentAtBeat( float fBeat ) { return GetFakeSegmentAtRow( BeatToNoteRow( fBeat ) ); } + FakeSegment* GetFakeSegmentAtBeat( float fBeat ) { return GetFakeSegmentAtRow( BeatToNoteRow( fBeat ) ); } /** * @brief Checks if the row is inside a fake. * @param iRow the row to focus on.