move note matching into a separate function
This commit is contained in:
+29
-16
@@ -339,27 +339,18 @@ void Player::DrawPrimitives()
|
|||||||
m_HoldJudgement[c].Draw();
|
m_HoldJudgement[c].Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::Step( int col )
|
int Player::GetClosestBeat( int col, float fSeconds, float fMaxSecondsAhead, float fMaxSecondsBehind, bool IgnoreScored )
|
||||||
{
|
{
|
||||||
if( GAMESTATE->m_SongOptions.m_LifeType == SongOptions::LIFE_BATTERY && GAMESTATE->m_CurStageStats.bFailed[m_PlayerNumber] ) // Oni dead
|
fMaxSecondsBehind; /* not yet implemented */
|
||||||
return; // do nothing
|
IgnoreScored; /* not yet implemented */
|
||||||
|
|
||||||
//LOG->Trace( "Player::HandlePlayerStep()" );
|
|
||||||
|
|
||||||
ASSERT( col >= 0 && col <= GetNumTracks() );
|
|
||||||
|
|
||||||
const float fSongBeat = GAMESTATE->m_fSongBeat;
|
|
||||||
|
|
||||||
// look for the closest matching step
|
// look for the closest matching step
|
||||||
int iIndexStartLookingAt = BeatToNoteRow( GAMESTATE->m_fSongBeat );
|
int iIndexStartLookingAt = BeatToNoteRow( fSeconds );
|
||||||
|
|
||||||
// number of elements to examine on either end of iIndexStartLookingAt
|
// number of elements to examine on either end of iIndexStartLookingAt
|
||||||
// 3dfsux: I expanded this window so that beat correction will look
|
int iNumElementsToExamine = BeatToNoteRow( fMaxSecondsAhead );
|
||||||
int iNumElementsToExamine = BeatToNoteRow( GAMESTATE->m_fCurBPS * GAMESTATE->m_SongOptions.m_fMusicRate );
|
|
||||||
|
|
||||||
//LOG->Trace( "iIndexStartLookingAt = %d, iNumElementsToExamine = %d", iIndexStartLookingAt, iNumElementsToExamine );
|
|
||||||
|
|
||||||
int iIndexOverlappingNote = -1; // leave as -1 if we don't find any
|
|
||||||
|
|
||||||
|
int iIndexOverlappingNote = -1;
|
||||||
// Start at iIndexStartLookingAt and search outward. The first one note
|
// Start at iIndexStartLookingAt and search outward. The first one note
|
||||||
// overlaps the player's hit (this is the closest match).
|
// overlaps the player's hit (this is the closest match).
|
||||||
for( int delta=0; delta <= iNumElementsToExamine; delta++ )
|
for( int delta=0; delta <= iNumElementsToExamine; delta++ )
|
||||||
@@ -393,6 +384,28 @@ void Player::Step( int col )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return iIndexOverlappingNote;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::Step( int col )
|
||||||
|
{
|
||||||
|
if( GAMESTATE->m_SongOptions.m_LifeType == SongOptions::LIFE_BATTERY && GAMESTATE->m_CurStageStats.bFailed[m_PlayerNumber] ) // Oni dead
|
||||||
|
return; // do nothing
|
||||||
|
|
||||||
|
//LOG->Trace( "Player::HandlePlayerStep()" );
|
||||||
|
|
||||||
|
ASSERT( col >= 0 && col <= GetNumTracks() );
|
||||||
|
|
||||||
|
const float fSongBeat = GAMESTATE->m_fSongBeat;
|
||||||
|
|
||||||
|
int iIndexOverlappingNote;
|
||||||
|
iIndexOverlappingNote = GetClosestBeat( col, GAMESTATE->m_fSongBeat,
|
||||||
|
GAMESTATE->m_fCurBPS * GAMESTATE->m_SongOptions.m_fMusicRate,
|
||||||
|
GAMESTATE->m_fCurBPS * GAMESTATE->m_SongOptions.m_fMusicRate,
|
||||||
|
true );
|
||||||
|
|
||||||
|
//LOG->Trace( "iIndexStartLookingAt = %d, iNumElementsToExamine = %d", iIndexStartLookingAt, iNumElementsToExamine );
|
||||||
|
|
||||||
bool bDestroyedNote = false;
|
bool bDestroyedNote = false;
|
||||||
|
|
||||||
if( iIndexOverlappingNote != -1 )
|
if( iIndexOverlappingNote != -1 )
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ protected:
|
|||||||
void HandleNoteScore( TapNoteScore score, int iNumTapsInRow );
|
void HandleNoteScore( TapNoteScore score, int iNumTapsInRow );
|
||||||
void HandleHoldNoteScore( HoldNoteScore score, TapNoteScore TapNoteScore );
|
void HandleHoldNoteScore( HoldNoteScore score, TapNoteScore TapNoteScore );
|
||||||
|
|
||||||
|
int GetClosestBeat( int col, float fSeconds, float fMaxSecondsAhead, float fMaxSecondsBehind, bool IgnoreScored );
|
||||||
|
|
||||||
static float GetMaxBeatDifference();
|
static float GetMaxBeatDifference();
|
||||||
|
|
||||||
PlayerNumber m_PlayerNumber;
|
PlayerNumber m_PlayerNumber;
|
||||||
|
|||||||
Reference in New Issue
Block a user