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.

This commit is contained in:
Steve Checkoway
2006-06-26 09:33:11 +00:00
parent ec9d50c332
commit 8129d943ba
5 changed files with 15 additions and 11 deletions
+10 -1
View File
@@ -21,7 +21,6 @@ NoteData::NoteData()
void NoteData::Init() void NoteData::Init()
{ {
m_bComposite = false;
ClearAll(); ClearAll();
m_TapNotes = vector<TrackMap>(); // ensure that the memory is freed m_TapNotes = vector<TrackMap>(); // ensure that the memory is freed
} }
@@ -37,6 +36,16 @@ void NoteData::SetNumTracks( int iNewNumTracks )
m_TapNotes.resize( 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). */ /* Clear [rowBegin,rowEnd). */
void NoteData::ClearRangeForTrack( int rowBegin, int rowEnd, int iTrack ) void NoteData::ClearRangeForTrack( int rowBegin, int rowEnd, int iTrack )
+1 -4
View File
@@ -30,8 +30,6 @@ private:
// There's no point in inserting empty notes into the map. // There's no point in inserting empty notes into the map.
// Any blank space in the map is defined to be empty. // Any blank space in the map is defined to be empty.
vector<TrackMap> m_TapNotes; vector<TrackMap> m_TapNotes;
// This NoteData comprises multiple NoteDatas.
bool m_bComposite;
public: public:
NoteData(); NoteData();
@@ -40,8 +38,7 @@ public:
int GetNumTracks() const { return m_TapNotes.size(); } int GetNumTracks() const { return m_TapNotes.size(); }
void SetNumTracks( int iNewNumTracks ); void SetNumTracks( int iNewNumTracks );
bool IsComposite() const { return m_bComposite; } bool IsComposite() const;
void SetComposite( bool b ) { m_bComposite = b; }
/* Return the note at the given track and row. Row may be out of /* Return the note at the given track and row. Row may be out of
* range; pretend the song goes on with TAP_EMPTYs indefinitely. */ * range; pretend the song goes on with TAP_EMPTYs indefinitely. */
+1 -3
View File
@@ -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 // Load note data
@@ -263,10 +263,8 @@ void NoteDataUtil::LoadFromSMNoteDataString( NoteData &out, const RString &sSMNo
/* Clear notes, but keep the same number of tracks. */ /* Clear notes, but keep the same number of tracks. */
int iNumTracks = out.GetNumTracks(); int iNumTracks = out.GetNumTracks();
bool bComposite = out.IsComposite();
out.Init(); out.Init();
out.SetNumTracks( iNumTracks ); out.SetNumTracks( iNumTracks );
out.SetComposite( bComposite );
if( !bComposite ) if( !bComposite )
{ {
+1 -1
View File
@@ -17,7 +17,7 @@ struct RadarValues;
namespace NoteDataUtil namespace NoteDataUtil
{ {
NoteType GetSmallestNoteTypeForMeasure( const NoteData &n, int iMeasureIndex ); 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 &notes_out ); void GetSMNoteDataString( const NoteData &in, RString &notes_out );
void SplitCompositeNoteData( const NoteData &in, vector<NoteData> &out ); void SplitCompositeNoteData( const NoteData &in, vector<NoteData> &out );
void LoadTransformedSlidingWindow( const NoteData &in, NoteData &out, int iNewNumTracks ); void LoadTransformedSlidingWindow( const NoteData &in, NoteData &out, int iNewNumTracks );
+2 -2
View File
@@ -225,11 +225,11 @@ void Steps::Decompress() const
else else
{ {
// load from compressed // load from compressed
bool bComposite = m_StepsType == STEPS_TYPE_DANCE_ROUTINE;
m_bNoteDataIsFilled = true; m_bNoteDataIsFilled = true;
m_pNoteData->SetNumTracks( GameManager::StepsTypeToNumTracks(m_StepsType) ); 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 );
} }
} }