fix hold note glitches

This commit is contained in:
Glenn Maynard
2003-12-18 02:34:59 +00:00
parent a9b8be3c07
commit 4facdd0a06
7 changed files with 34 additions and 15 deletions
+14
View File
@@ -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<GetNumHoldNotes(); i++ ) // for each HoldNote
{
const HoldNote &ret = GetHoldNote(i);
if( ret.iTrack == hn.iTrack && ret.iEndRow == hn.iEndRow )
return i;
}
ASSERT(0);
return -1;
}
void NoteData::SetTapAttackNote( int track, int row, Attack attack )
{
PruneUnusedAttacksFromMap();
+3 -2
View File
@@ -98,8 +98,9 @@ public:
//
void AddHoldNote( HoldNote newNote ); // add note hold note merging overlapping HoldNotes and destroying TapNotes underneath
void RemoveHoldNote( int index );
HoldNote &GetHoldNote( int index ) { return m_HoldNotes[index]; }
const HoldNote &GetHoldNote( int index ) const { return m_HoldNotes[index]; }
HoldNote &GetHoldNote( int index ) { ASSERT( index < (int) m_HoldNotes.size() ); return m_HoldNotes[index]; }
const HoldNote &GetHoldNote( int index ) const { ASSERT( index < (int) m_HoldNotes.size() ); return m_HoldNotes[index]; }
int GetMatchingHoldNote( const HoldNote &hn ) const;
void SetTapAttackNote( int track, int row, Attack attack );
void PruneUnusedAttacksFromMap(); // slow
+4 -4
View File
@@ -361,7 +361,7 @@ void NoteDataWithScoring::SetTapNoteOffset(unsigned track, unsigned row, float o
* changes when hold notes are being stepped on, but end rows never change. */
HoldNoteScore NoteDataWithScoring::GetHoldNoteScore( const HoldNote &hn ) const
{
map<RowTrack, HoldNoteScore>::const_iterator it = m_HoldNoteScores.find( RowTrack(hn.iEndRow, hn.iTrack) );
map<RowTrack, HoldNoteScore>::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<RowTrack, float>::const_iterator it = m_fHoldNoteLife.find( RowTrack(hn.iEndRow, hn.iTrack) );
map<RowTrack, float>::const_iterator it = m_fHoldNoteLife.find( RowTrack(hn) );
if( it == m_fHoldNoteLife.end() )
return 1.0f;
return it->second;
+6 -1
View File
@@ -16,11 +16,16 @@
#include "PlayerNumber.h"
#include <map>
class RowTrack: public pair<int,int>
{
public:
RowTrack( const HoldNote &hn ): pair<int,int>( hn.iEndRow, hn.iTrack ) { }
};
class NoteDataWithScoring : public NoteData
{
// maintain this extra data in addition to the NoteData
vector<TapNoteScore> m_TapNoteScores[MAX_NOTE_TRACKS];
typedef pair<int,int> RowTrack;
map<RowTrack, HoldNoteScore> m_HoldNoteScores;
/* Offset, in seconds, for each tap grade. Negative numbers mean the note
+2 -4
View File
@@ -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
+1 -1
View File
@@ -39,7 +39,7 @@ public:
virtual void Unload();
void RemoveTapNoteRow( int iIndex );
vector<bool> m_bIsHoldingHoldNote; // hack: Need this to know when to "light up" the center of hold notes
map<RowTrack,bool> 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
+4 -3
View File
@@ -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 );
}