diff --git a/src/NoteField.cpp b/src/NoteField.cpp index 2e05aac08b..0385dee466 100644 --- a/src/NoteField.cpp +++ b/src/NoteField.cpp @@ -960,11 +960,11 @@ void NoteField::DrawPrimitives() // Combo text FOREACH_CONST( ComboSegment, timing.m_ComboSegments, seg ) { - if( seg->m_iStartRow >= iFirstRowToDraw && seg->m_iStartRow <= iLastRowToDraw ) + if( seg->GetRow() >= iFirstRowToDraw && seg->GetRow() <= iLastRowToDraw ) { - float fBeat = NoteRowToBeat(seg->m_iStartRow); + float fBeat = seg->GetBeat(); if( IS_ON_SCREEN(fBeat) ) - DrawComboText( fBeat, seg->m_iCombo ); + DrawComboText( fBeat, seg->GetCombo() ); } } } diff --git a/src/NotesWriterSSC.cpp b/src/NotesWriterSSC.cpp index 8f8e32d86c..8ab6b71d52 100644 --- a/src/NotesWriterSSC.cpp +++ b/src/NotesWriterSSC.cpp @@ -128,7 +128,7 @@ static void GetTimingTags( vector &lines, TimingData timing, bool bIsSo ASSERT( !timing.m_ComboSegments.empty() ); w.Init( "COMBOS" ); FOREACH_CONST( ComboSegment, timing.m_ComboSegments, cs ) - w.Write( cs->m_iStartRow, cs->m_iCombo ); + w.Write( cs->GetRow(), cs->GetCombo() ); w.Finish(); // Song Timing should only have the initial value. diff --git a/src/ScoreKeeperNormal.cpp b/src/ScoreKeeperNormal.cpp index 8106effb3a..ce3874aa5a 100644 --- a/src/ScoreKeeperNormal.cpp +++ b/src/ScoreKeeperNormal.cpp @@ -445,7 +445,7 @@ void ScoreKeeperNormal::HandleComboInternal( int iNumHitContinueCombo, int iNumH if( iNumBreakCombo == 0 ) { TimingData td = GAMESTATE->m_pCurSteps[m_pPlayerState->m_PlayerNumber]->m_Timing; - int multiplier = ( iRow == -1 ? 1 : td.GetComboSegmentAtRow( iRow ).m_iCombo ); + int multiplier = ( iRow == -1 ? 1 : td.GetComboSegmentAtRow( iRow ).GetCombo() ); m_pPlayerStageStats->m_iCurCombo += iNumHitContinueCombo * multiplier; } else @@ -465,7 +465,7 @@ void ScoreKeeperNormal::HandleRowComboInternal( TapNoteScore tns, int iNumTapsIn { m_pPlayerStageStats->m_iCurMissCombo = 0; TimingData td = GAMESTATE->m_pCurSteps[m_pPlayerState->m_PlayerNumber]->m_Timing; - int multiplier = ( iRow == -1 ? 1 : td.GetComboSegmentAtRow( iRow ).m_iCombo ); + int multiplier = ( iRow == -1 ? 1 : td.GetComboSegmentAtRow( iRow ).GetCombo() ); m_pPlayerStageStats->m_iCurCombo += iNumTapsInRow * multiplier; } else if ( tns < m_MinScoreToMaintainCombo ) diff --git a/src/TimingData.cpp b/src/TimingData.cpp index 3e267852cc..a7ae78db9b 100644 --- a/src/TimingData.cpp +++ b/src/TimingData.cpp @@ -227,20 +227,20 @@ void TimingData::SetComboAtRow( int iRow, int iCombo ) { unsigned i; for( i=0; i= iRow ) + if( m_ComboSegments[i].GetRow() >= iRow ) break; - if( i == m_ComboSegments.size() || m_ComboSegments[i].m_iStartRow != iRow ) + if( i == m_ComboSegments.size() || m_ComboSegments[i].GetRow() != iRow ) { - if( i == 0 || m_ComboSegments[i-1].m_iCombo != iCombo ) + if( i == 0 || m_ComboSegments[i-1].GetCombo() != iCombo ) AddComboSegment( ComboSegment(iRow, iCombo ) ); } else { - if( i > 0 && m_ComboSegments[i-1].m_iCombo == iCombo ) + if( i > 0 && m_ComboSegments[i-1].GetCombo() == iCombo ) m_ComboSegments.erase( m_ComboSegments.begin()+i, m_ComboSegments.begin()+i+1 ); else - m_ComboSegments[i].m_iCombo = iCombo; + m_ComboSegments[i].SetCombo(iCombo); } } @@ -398,7 +398,7 @@ float TimingData::GetDelayAtRow( int iRow ) const int TimingData::GetComboAtRow( int iNoteRow ) const { - return m_ComboSegments[GetComboSegmentIndexAtRow( iNoteRow )].m_iCombo; + return m_ComboSegments[GetComboSegmentIndexAtRow( iNoteRow )].GetCombo(); } RString TimingData::GetLabelAtRow( int iRow ) const @@ -598,7 +598,7 @@ int TimingData::GetComboSegmentIndexAtRow( int iRow ) const for( i=0; i iRow ) + if( s.GetRow() > iRow ) break; } return static_cast(i); @@ -685,7 +685,7 @@ ComboSegment& TimingData::GetComboSegmentAtRow( int iRow ) { unsigned i; for( i=0; i iRow ) + if( m_ComboSegments[i+1].GetRow() > iRow ) break; return m_ComboSegments[i]; } @@ -1086,13 +1086,14 @@ void TimingData::ScaleRegion( float fScale, int iStartIndex, int iEndIndex, bool for ( unsigned i = 0; i < m_ComboSegments.size(); i++ ) { - const int iSegStart = m_ComboSegments[i].m_iStartRow; + ComboSegment &c = m_ComboSegments[i]; + const int iSegStart = c.GetRow(); if( iSegStart < iStartIndex ) continue; else if( iSegStart > iEndIndex ) - m_ComboSegments[i].m_iStartRow += lrintf( (iEndIndex - iStartIndex) * (fScale - 1) ); + c.SetRow(c.GetRow() + lrintf( (iEndIndex - iStartIndex) * (fScale - 1) )); else - m_ComboSegments[i].m_iStartRow = lrintf( (iSegStart - iStartIndex) * fScale ) + iStartIndex; + c.SetRow(lrintf( (iSegStart - iStartIndex) * fScale ) + iStartIndex); } for ( unsigned i = 0; i < m_LabelSegments.size(); i++ ) @@ -1222,9 +1223,9 @@ void TimingData::InsertRows( int iStartRow, int iRowsToAdd ) for( unsigned i = 0; i < m_ComboSegments.size(); i++ ) { ComboSegment &comb = m_ComboSegments[i]; - if( comb.m_iStartRow < iStartRow ) + if( comb.GetRow() < iStartRow ) continue; - comb.m_iStartRow += iRowsToAdd; + comb.SetRow(comb.GetRow() + iRowsToAdd); } for( unsigned i = 0; i < m_LabelSegments.size(); i++ ) { @@ -1379,13 +1380,13 @@ void TimingData::DeleteRows( int iStartRow, int iRowsToDelete ) for( unsigned i = 0; i < m_ComboSegments.size(); i++ ) { ComboSegment &comb = m_ComboSegments[i]; - + int keyRow = comb.GetRow(); // Before deleted region: - if( comb.m_iStartRow < iStartRow ) + if( keyRow < iStartRow ) continue; // Inside deleted region: - if( comb.m_iStartRow < iStartRow+iRowsToDelete ) + if( keyRow < iStartRow+iRowsToDelete ) { m_ComboSegments.erase( m_ComboSegments.begin()+i, m_ComboSegments.begin()+i+1 ); --i; @@ -1393,7 +1394,7 @@ void TimingData::DeleteRows( int iStartRow, int iRowsToDelete ) } // After deleted region: - comb.m_iStartRow -= iRowsToDelete; + comb.SetRow(keyRow - iRowsToDelete); } for( unsigned i = 0; i < m_LabelSegments.size(); i++ ) diff --git a/src/TimingData.h b/src/TimingData.h index f39ce7a139..2fab07ecca 100644 --- a/src/TimingData.h +++ b/src/TimingData.h @@ -309,82 +309,6 @@ struct TimeSignatureSegment bool operator>= (const TimeSignatureSegment &other ) const { return !operator<(other); } }; -/** - * @brief Identifies when a chart is to have a different combo multiplier value. - * - * Admitedly, this would primarily be used for mission mode style charts. However, - * it can have its place during normal gameplay. - */ -struct ComboSegment -{ - /** - * @brief Creates a simple Combo Segment with default values. - * - * It is best to override the values as soon as possible. - */ - ComboSegment() : m_iStartRow(-1), m_iCombo(1) { } - /** - * @brief Creates a Combo Segment with the specified starting row and combo factor. - * @param s the starting row of this segment. - * @param t the amount the combo increases on a succesful hit. - */ - ComboSegment( int s, int t ): m_iStartRow(max(0, s)), - m_iCombo(max(0,t)) {} - /** - * @brief The row in which the ComboSegment activates. - */ - int m_iStartRow; - /** - * @brief The amount the combo increases at this point. - */ - int m_iCombo; - - /** - * @brief Compares two ComboSegments to see if they are equal to each other. - * @param other the other ComboSegment to compare to. - * @return the equality of the two segments. - */ - bool operator==( const ComboSegment &other ) const - { - COMPARE( m_iStartRow ); - COMPARE( m_iCombo ); - return true; - } - /** - * @brief Compares two ComboSegments to see if they are not equal to each other. - * @param other the other ComboSegment to compare to. - * @return the inequality of the two segments. - */ - bool operator!=( const ComboSegment &other ) const { return !operator==(other); } - /** - * @brief Compares two ComboSegments to see if one is less than the other. - * @param other the other ComboSegment to compare to. - * @return the truth/falsehood of if the first is less than the second. - */ - bool operator<( const ComboSegment &other ) const { return m_iStartRow < other.m_iStartRow; } - /** - * @brief Compares two ComboSegments to see if one is less than or equal to the other. - * @param other the other ComboSegment to compare to. - * @return the truth/falsehood of if the first is less or equal to than the second. - */ - bool operator<=( const ComboSegment &other ) const - { - return ( operator<(other) || operator==(other) ); - } - /** - * @brief Compares two ComboSegments to see if one is greater than the other. - * @param other the other ComboSegment to compare to. - * @return the truth/falsehood of if the first is greater than the second. - */ - bool operator>( const ComboSegment &other ) const { return !operator<=(other); } - /** - * @brief Compares two ComboSegments to see if one is greater than or equal to the other. - * @param other the other ComboSegment to compare to. - * @return the truth/falsehood of if the first is greater than or equal to the second. - */ - bool operator>=( const ComboSegment &other ) const { return !operator<(other); } -}; - /** * @brief Identifies when the arrow scroll changes. * diff --git a/src/TimingSegments.cpp b/src/TimingSegments.cpp index ed7b96637e..73d5c1919d 100644 --- a/src/TimingSegments.cpp +++ b/src/TimingSegments.cpp @@ -89,6 +89,23 @@ bool TickcountSegment::operator<( const TickcountSegment &other ) const return false; } +int ComboSegment::GetCombo() const +{ + return this->combo; +} + +void ComboSegment::SetCombo(const int i) +{ + this->combo = i; +} + +bool ComboSegment::operator<( const ComboSegment &other ) const +{ + LTCOMPARE(GetRow()); + LTCOMPARE(GetCombo()); + return false; +} + RString LabelSegment::GetLabel() const { return this->label; diff --git a/src/TimingSegments.h b/src/TimingSegments.h index 7beed060fe..f9f2b37add 100644 --- a/src/TimingSegments.h +++ b/src/TimingSegments.h @@ -283,6 +283,55 @@ private: int ticks; }; +/** + * @brief Identifies when a chart is to have a different combo multiplier value. + * + * Admitedly, this would primarily be used for mission mode style charts. However, + * it can have its place during normal gameplay. + */ +struct ComboSegment : public TimingSegment +{ + /** + * @brief Creates a simple Combo Segment with default values. + * + * It is best to override the values as soon as possible. + */ + ComboSegment() : + TimingSegment(), combo(1) { } + /** + * @brief Creates a Combo Segment with the specified values. + * @param s the starting row / beat of this segment. + * @param t the amount the combo increases on a succesful hit. + */ + template + ComboSegment( StartType s, int t ): + TimingSegment(max((StartType)0, s)), + combo(max(0,t)) {} + + /** + * @brief Get the combo in this ComboSegment. + * @return the combo. */ + int GetCombo() const; + + /** + * @brief Set the combo in this ComboSegment. + * @param i the combo. */ + void SetCombo(const int i); + + /** + * @brief Compares two ComboSegments to see if one is less than the other. + * @param other the other ComboSegment to compare to. + * @return the truth/falsehood of if the first is less than the second. + */ + bool operator<( const ComboSegment &other ) const; +private: + /** + * @brief The amount the combo increases at this point. + */ + int combo; +}; + + /** * @brief Identifies when a chart is entering a different section. *