diff --git a/stepmania/src/NoteDataWithScoring.cpp b/stepmania/src/NoteDataWithScoring.cpp index efc7be7927..a0ddd507ab 100644 --- a/stepmania/src/NoteDataWithScoring.cpp +++ b/stepmania/src/NoteDataWithScoring.cpp @@ -19,22 +19,15 @@ NoteDataWithScoring::NoteDataWithScoring() Init(); } -void NoteDataWithScoring::Init(int taps, int holds) +void NoteDataWithScoring::Init() { NoteData::Init(); for( int t=0; t +void extend(vector &v, T val, unsigned pos) +{ + int needed = pos - v.size() + 1; + if(needed > 0) + { + needed += 100; /* optimization: give it a little more than it needs */ + v.insert(v.end(), needed, val); + } +} + +TapNoteScore NoteDataWithScoring::GetTapNoteScore(unsigned track, unsigned row) const +{ + if(row >= m_TapNoteScores[track].size()) + return TNS_NONE; + return m_TapNoteScores[track][row]; +} + +void NoteDataWithScoring::SetTapNoteScore(unsigned track, unsigned row, TapNoteScore tns) +{ + extend(m_TapNoteScores[track], TNS_NONE, row); + m_TapNoteScores[track][row] = tns; +} + +HoldNoteScore NoteDataWithScoring::GetHoldNoteScore(unsigned h) const +{ + if(h >= m_HoldNoteScores.size()) + return HNS_NONE; + return m_HoldNoteScores[h]; +} + +void NoteDataWithScoring::SetHoldNoteScore(unsigned h, HoldNoteScore hns) +{ + extend(m_HoldNoteScores, HNS_NONE, h); + m_HoldNoteScores[h] = hns; +} + +void NoteDataWithScoring::SetHoldNoteLife(unsigned h, float f) +{ + extend(m_fHoldNoteLife, 1.0f, h); + m_fHoldNoteLife[h] = f; +} + +float NoteDataWithScoring::GetHoldNoteLife(unsigned h) const +{ + // start with full life + if(h >= m_fHoldNoteLife.size()) + return 1.0f; + return m_fHoldNoteLife[h]; +} diff --git a/stepmania/src/NoteDataWithScoring.h b/stepmania/src/NoteDataWithScoring.h index 877290ac00..81b7863ff6 100644 --- a/stepmania/src/NoteDataWithScoring.h +++ b/stepmania/src/NoteDataWithScoring.h @@ -18,7 +18,6 @@ class NoteDataWithScoring : public NoteData { // maintain this extra data in addition to the NoteData vector m_TapNoteScores[MAX_NOTE_TRACKS]; - vector m_HoldNoteScores; /* 1.0 means this HoldNote has full life. @@ -28,43 +27,20 @@ class NoteDataWithScoring : public NoteData vector m_fHoldNoteLife; public: - NoteDataWithScoring(); - void Init(int taps=0, int holds=0); + void Init(); // statistics int GetNumTapNotesWithScore( TapNoteScore tns, const float fStartBeat = 0, const float fEndBeat = MAX_BEATS ); int GetNumDoublesWithScore( TapNoteScore tns, const float fStartBeat = 0, const float fEndBeat = MAX_BEATS ); int GetNumHoldNotesWithScore( HoldNoteScore hns, const float fStartBeat = 0, const float fEndBeat = MAX_BEATS ); - const TapNoteScore &GetTapNoteScore(int track, int row) const - { - ASSERT(row < int(m_TapNoteScores[track].size())); - return m_TapNoteScores[track][row]; - } - TapNoteScore &GetTapNoteScore(int track, int row) - { - ASSERT(row < int(m_TapNoteScores[track].size())); - return m_TapNoteScores[track][row]; - } - const HoldNoteScore &GetHoldNoteScore(int h) const - { - ASSERT(h < int(m_HoldNoteScores.size())); - return m_HoldNoteScores[h]; - } - HoldNoteScore &GetHoldNoteScore(int h) - { - ASSERT(h < int(m_HoldNoteScores.size())); - return m_HoldNoteScores[h]; - } - float &GetHoldNoteLife(int h) - { - return m_fHoldNoteLife[h]; - } - const float &GetHoldNoteLife(int h) const - { - return m_fHoldNoteLife[h]; - } + TapNoteScore GetTapNoteScore(unsigned track, unsigned row) const; + void SetTapNoteScore(unsigned track, unsigned row, TapNoteScore tns); + HoldNoteScore GetHoldNoteScore(unsigned h) const; + void SetHoldNoteScore(unsigned h, HoldNoteScore hns); + float GetHoldNoteLife(unsigned h) const; + void SetHoldNoteLife(unsigned h, float f); bool IsRowComplete( int index );