From 4facdd0a065498b0191854b49bb99e1b950c3ab4 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Thu, 18 Dec 2003 02:34:59 +0000 Subject: [PATCH] fix hold note glitches --- stepmania/src/NoteData.cpp | 14 ++++++++++++++ stepmania/src/NoteData.h | 5 +++-- stepmania/src/NoteDataWithScoring.cpp | 8 ++++---- stepmania/src/NoteDataWithScoring.h | 7 ++++++- stepmania/src/NoteField.cpp | 6 ++---- stepmania/src/NoteField.h | 2 +- stepmania/src/Player.cpp | 7 ++++--- 7 files changed, 34 insertions(+), 15 deletions(-) diff --git a/stepmania/src/NoteData.cpp b/stepmania/src/NoteData.cpp index 21057b958c..eb67f69119 100644 --- a/stepmania/src/NoteData.cpp +++ b/stepmania/src/NoteData.cpp @@ -274,6 +274,20 @@ void NoteData::RemoveHoldNote( int iHoldIndex ) m_HoldNotes.erase(m_HoldNotes.begin()+iHoldIndex, m_HoldNotes.begin()+iHoldIndex+1); } +/* Get a hold note with the same track and end row as hn. */ +int NoteData::GetMatchingHoldNote( const HoldNote &hn ) const +{ + for( int i=0; i::const_iterator it = m_HoldNoteScores.find( RowTrack(hn.iEndRow, hn.iTrack) ); + map::const_iterator it = m_HoldNoteScores.find( RowTrack(hn) ); if( it == m_HoldNoteScores.end() ) return HNS_NONE; return it->second; @@ -369,17 +369,17 @@ HoldNoteScore NoteDataWithScoring::GetHoldNoteScore( const HoldNote &hn ) const void NoteDataWithScoring::SetHoldNoteScore( const HoldNote &hn, HoldNoteScore hns ) { - m_HoldNoteScores[RowTrack(hn.iEndRow, hn.iTrack)] = hns; + m_HoldNoteScores[RowTrack(hn)] = hns; } void NoteDataWithScoring::SetHoldNoteLife( const HoldNote &hn, float f ) { - m_fHoldNoteLife[RowTrack(hn.iEndRow, hn.iTrack)] = f; + m_fHoldNoteLife[RowTrack(hn)] = f; } float NoteDataWithScoring::GetHoldNoteLife( const HoldNote &hn ) const { - map::const_iterator it = m_fHoldNoteLife.find( RowTrack(hn.iEndRow, hn.iTrack) ); + map::const_iterator it = m_fHoldNoteLife.find( RowTrack(hn) ); if( it == m_fHoldNoteLife.end() ) return 1.0f; return it->second; diff --git a/stepmania/src/NoteDataWithScoring.h b/stepmania/src/NoteDataWithScoring.h index 7f9ef29665..4506cd92ee 100644 --- a/stepmania/src/NoteDataWithScoring.h +++ b/stepmania/src/NoteDataWithScoring.h @@ -16,11 +16,16 @@ #include "PlayerNumber.h" #include +class RowTrack: public pair +{ +public: + RowTrack( const HoldNote &hn ): pair( hn.iEndRow, hn.iTrack ) { } +}; + class NoteDataWithScoring : public NoteData { // maintain this extra data in addition to the NoteData vector m_TapNoteScores[MAX_NOTE_TRACKS]; - typedef pair RowTrack; map m_HoldNoteScores; /* Offset, in seconds, for each tap grade. Negative numbers mean the note diff --git a/stepmania/src/NoteField.cpp b/stepmania/src/NoteField.cpp index d673a5882a..cedb70f047 100644 --- a/stepmania/src/NoteField.cpp +++ b/stepmania/src/NoteField.cpp @@ -96,8 +96,7 @@ void NoteField::Load( const NoteData* pNoteData, PlayerNumber pn, int iFirstPixe NoteDataWithScoring::Init(); - m_bIsHoldingHoldNote.clear(); - m_bIsHoldingHoldNote.insert(m_bIsHoldingHoldNote.end(), pNoteData->GetNumTapNotes(), false); + m_HeldHoldNotes.clear(); this->CopyAll( pNoteData ); ASSERT( GetNumTracks() == GAMESTATE->GetCurrentStyleDef()->m_iColsPerPlayer ); @@ -519,8 +518,7 @@ void NoteField::DrawPrimitives() const HoldNote &hn = GetHoldNote(i); const HoldNoteScore hns = GetHoldNoteScore( hn ); const float fLife = GetHoldNoteLife( hn ); - const bool bIsHoldingNote = (i < int(m_bIsHoldingHoldNote.size()))? - m_bIsHoldingHoldNote[i]: false; + const bool bIsHoldingNote = m_HeldHoldNotes[hn]; if( hns == HNS_OK ) // if this HoldNote was completed continue; // don't draw anything diff --git a/stepmania/src/NoteField.h b/stepmania/src/NoteField.h index 951cc1cd9b..9f4f03e480 100644 --- a/stepmania/src/NoteField.h +++ b/stepmania/src/NoteField.h @@ -39,7 +39,7 @@ public: virtual void Unload(); void RemoveTapNoteRow( int iIndex ); - vector m_bIsHoldingHoldNote; // hack: Need this to know when to "light up" the center of hold notes + map m_HeldHoldNotes; // hack: Need this to know when to "light up" the center of hold notes float m_fBeginMarker, m_fEndMarker; // only used with MODE_EDIT diff --git a/stepmania/src/Player.cpp b/stepmania/src/Player.cpp index dec95c6d0f..8d928358bd 100644 --- a/stepmania/src/Player.cpp +++ b/stepmania/src/Player.cpp @@ -283,7 +283,7 @@ void PlayerMinus::Update( float fDeltaTime ) const HoldNote &hn = GetHoldNote(i); HoldNoteScore hns = GetHoldNoteScore(hn); - m_pNoteField->m_bIsHoldingHoldNote[i] = false; // set host flag so NoteField can do intelligent drawing + m_pNoteField->m_HeldHoldNotes[hn] = false; // set hold flag so NoteField can do intelligent drawing if( hns != HNS_NONE ) // if this HoldNote already has a result @@ -310,12 +310,13 @@ void PlayerMinus::Update( float fDeltaTime ) bIsHoldingButton = true; // set hold flag so NoteField can do intelligent drawing - m_pNoteField->m_bIsHoldingHoldNote[i] = bIsHoldingButton && bSteppedOnTapNote; + m_pNoteField->m_HeldHoldNotes[hn] = bIsHoldingButton && bSteppedOnTapNote; if( bSteppedOnTapNote ) // this note is not judged and we stepped on its head { // Move the start of this Hold - HoldNote &fhn = m_pNoteField->GetHoldNote(i); + const int n = m_pNoteField->GetMatchingHoldNote( hn ); + HoldNote &fhn = m_pNoteField->GetHoldNote( n ); fhn.iStartRow = min( iSongRow, fhn.iEndRow ); }