From 8129d943bafa770c9d8ab7a5543fbd96118069be Mon Sep 17 00:00:00 2001 From: Steve Checkoway Date: Mon, 26 Jun 2006 09:33:11 +0000 Subject: [PATCH] It's hard to maintain this information when using begin() and end() so rather than wrapping the iterators, just check each time IsComposite() is called since it doesn't happen _that_ often. Just don't call IsComposite() often. --- stepmania/src/NoteData.cpp | 11 ++++++++++- stepmania/src/NoteData.h | 5 +---- stepmania/src/NoteDataUtil.cpp | 4 +--- stepmania/src/NoteDataUtil.h | 2 +- stepmania/src/Steps.cpp | 4 ++-- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/stepmania/src/NoteData.cpp b/stepmania/src/NoteData.cpp index b51037e852..5488696305 100644 --- a/stepmania/src/NoteData.cpp +++ b/stepmania/src/NoteData.cpp @@ -21,7 +21,6 @@ NoteData::NoteData() void NoteData::Init() { - m_bComposite = false; ClearAll(); m_TapNotes = vector(); // ensure that the memory is freed } @@ -37,6 +36,16 @@ void NoteData::SetNumTracks( int iNewNumTracks ) m_TapNotes.resize( iNewNumTracks ); } +bool NoteData::IsComposite() const +{ + for( int track = 0; track < GetNumTracks(); ++track ) + { + FOREACHM_CONST( int, TapNote, m_TapNotes[track], tn ) + if( tn->second.pn != PLAYER_INVALID ) + return true; + } + return false; +} /* Clear [rowBegin,rowEnd). */ void NoteData::ClearRangeForTrack( int rowBegin, int rowEnd, int iTrack ) diff --git a/stepmania/src/NoteData.h b/stepmania/src/NoteData.h index be025dc97d..88f7432ec0 100644 --- a/stepmania/src/NoteData.h +++ b/stepmania/src/NoteData.h @@ -30,8 +30,6 @@ private: // There's no point in inserting empty notes into the map. // Any blank space in the map is defined to be empty. vector m_TapNotes; - // This NoteData comprises multiple NoteDatas. - bool m_bComposite; public: NoteData(); @@ -40,8 +38,7 @@ public: int GetNumTracks() const { return m_TapNotes.size(); } void SetNumTracks( int iNewNumTracks ); - bool IsComposite() const { return m_bComposite; } - void SetComposite( bool b ) { m_bComposite = b; } + bool IsComposite() const; /* Return the note at the given track and row. Row may be out of * range; pretend the song goes on with TAP_EMPTYs indefinitely. */ diff --git a/stepmania/src/NoteDataUtil.cpp b/stepmania/src/NoteDataUtil.cpp index 8c0708e4f9..604a8deeea 100644 --- a/stepmania/src/NoteDataUtil.cpp +++ b/stepmania/src/NoteDataUtil.cpp @@ -239,7 +239,7 @@ static void LoadFromSMNoteDataStringWithPlayer( NoteData& out, const RString &sS } -void NoteDataUtil::LoadFromSMNoteDataString( NoteData &out, const RString &sSMNoteData_ ) +void NoteDataUtil::LoadFromSMNoteDataString( NoteData &out, const RString &sSMNoteData_, bool bComposite ) { // // Load note data @@ -263,10 +263,8 @@ void NoteDataUtil::LoadFromSMNoteDataString( NoteData &out, const RString &sSMNo /* Clear notes, but keep the same number of tracks. */ int iNumTracks = out.GetNumTracks(); - bool bComposite = out.IsComposite(); out.Init(); out.SetNumTracks( iNumTracks ); - out.SetComposite( bComposite ); if( !bComposite ) { diff --git a/stepmania/src/NoteDataUtil.h b/stepmania/src/NoteDataUtil.h index 1e43bba7fe..48c134d7b4 100644 --- a/stepmania/src/NoteDataUtil.h +++ b/stepmania/src/NoteDataUtil.h @@ -17,7 +17,7 @@ struct RadarValues; namespace NoteDataUtil { NoteType GetSmallestNoteTypeForMeasure( const NoteData &n, int iMeasureIndex ); - void LoadFromSMNoteDataString( NoteData &out, const RString &sSMNoteData ); + void LoadFromSMNoteDataString( NoteData &out, const RString &sSMNoteData, bool bComposite ); void GetSMNoteDataString( const NoteData &in, RString ¬es_out ); void SplitCompositeNoteData( const NoteData &in, vector &out ); void LoadTransformedSlidingWindow( const NoteData &in, NoteData &out, int iNewNumTracks ); diff --git a/stepmania/src/Steps.cpp b/stepmania/src/Steps.cpp index fe978beed2..97f7932eb6 100644 --- a/stepmania/src/Steps.cpp +++ b/stepmania/src/Steps.cpp @@ -225,11 +225,11 @@ void Steps::Decompress() const else { // load from compressed + bool bComposite = m_StepsType == STEPS_TYPE_DANCE_ROUTINE; m_bNoteDataIsFilled = true; m_pNoteData->SetNumTracks( GameManager::StepsTypeToNumTracks(m_StepsType) ); - m_pNoteData->SetComposite( m_StepsType == STEPS_TYPE_DANCE_ROUTINE ); - NoteDataUtil::LoadFromSMNoteDataString( *m_pNoteData, m_sNoteDataCompressed ); + NoteDataUtil::LoadFromSMNoteDataString( *m_pNoteData, m_sNoteDataCompressed, bComposite ); } }