From f752e1c3b0ad93f3187fb2f5cb53789c96653ff5 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Mon, 7 Feb 2005 22:03:32 +0000 Subject: [PATCH] hide NoteData::InsertHoldTails away in NoteDataUtils --- stepmania/src/NoteData.cpp | 25 ------------------------- stepmania/src/NoteData.h | 3 --- stepmania/src/NoteDataUtil.cpp | 30 +++++++++++++++++++++++++++++- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/stepmania/src/NoteData.cpp b/stepmania/src/NoteData.cpp index 690fd2bc1a..cce9fd655c 100644 --- a/stepmania/src/NoteData.cpp +++ b/stepmania/src/NoteData.cpp @@ -812,31 +812,6 @@ bool NoteData::GetNextTapNoteRowForAllTracks( int &rowInOut ) const } } -void NoteData::InsertHoldTails() -{ - for( int t=0; tbegin(t), end = this->end(t); - - for( ; begin != end; ++begin ) - { - int iRow = begin->first; - const TapNote &tn = begin->second; - if( tn.type != TapNote::hold_head ) - continue; - - TapNote tail = tn; - tail.type = TapNote::hold_tail; - - /* If iDuration is 0, we'd end up overwriting the head with the tail - * (and invalidating our iterator). Empty hold notes aren't valid. */ - ASSERT( tn.iDuration != 0 ); - - SetTapNote( t, iRow + tn.iDuration, tail ); - } - } -} - /* * (c) 2001-2004 Chris Danford, Glenn Maynard * All rights reserved. diff --git a/stepmania/src/NoteData.h b/stepmania/src/NoteData.h index 97e5362a32..b8305ed65e 100644 --- a/stepmania/src/NoteData.h +++ b/stepmania/src/NoteData.h @@ -141,9 +141,6 @@ public: // Transformations void LoadTransformed( const NoteData& original, int iNewNumTracks, const int iOriginalTrackToTakeFrom[] ); // -1 for iOriginalTracksToTakeFrom means no track - - /* hold_tail is only used to make SM parsing easier. */ - void InsertHoldTails(); }; diff --git a/stepmania/src/NoteDataUtil.cpp b/stepmania/src/NoteDataUtil.cpp index 840ec16184..c1baa1b183 100644 --- a/stepmania/src/NoteDataUtil.cpp +++ b/stepmania/src/NoteDataUtil.cpp @@ -227,13 +227,41 @@ void NoteDataUtil::LoadFromSMNoteDataString( NoteData &out, CString sSMNoteData } } +namespace +{ + void InsertHoldTails( NoteData &inout ) + { + for( int t=0; t < inout.GetNumTracks(); t++ ) + { + NoteData::iterator begin = inout.begin(t), end = inout.end(t); + + for( ; begin != end; ++begin ) + { + int iRow = begin->first; + const TapNote &tn = begin->second; + if( tn.type != TapNote::hold_head ) + continue; + + TapNote tail = tn; + tail.type = TapNote::hold_tail; + + /* If iDuration is 0, we'd end up overwriting the head with the tail + * (and invalidating our iterator). Empty hold notes aren't valid. */ + ASSERT( tn.iDuration != 0 ); + + inout.SetTapNote( t, iRow + tn.iDuration, tail ); + } + } + } +}; + void NoteDataUtil::GetSMNoteDataString( const NoteData &in_, CString ¬es_out ) { // // Get note data // NoteData in( in_ ); - in.InsertHoldTails(); + InsertHoldTails( in ); float fLastBeat = in.GetLastBeat(); int iLastMeasure = int( fLastBeat/BEATS_PER_MEASURE );