diff --git a/stepmania/src/Player.cpp b/stepmania/src/Player.cpp index 32fa741632..c243a9a091 100644 --- a/stepmania/src/Player.cpp +++ b/stepmania/src/Player.cpp @@ -339,27 +339,18 @@ void Player::DrawPrimitives() 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 - return; // do nothing - - //LOG->Trace( "Player::HandlePlayerStep()" ); - - ASSERT( col >= 0 && col <= GetNumTracks() ); - - const float fSongBeat = GAMESTATE->m_fSongBeat; + fMaxSecondsBehind; /* not yet implemented */ + IgnoreScored; /* not yet implemented */ // 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 - // 3dfsux: I expanded this window so that beat correction will look - 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 iNumElementsToExamine = BeatToNoteRow( fMaxSecondsAhead ); + int iIndexOverlappingNote = -1; // Start at iIndexStartLookingAt and search outward. The first one note // overlaps the player's hit (this is the closest match). 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; if( iIndexOverlappingNote != -1 ) diff --git a/stepmania/src/Player.h b/stepmania/src/Player.h index f523fdf009..ed72a1810f 100644 --- a/stepmania/src/Player.h +++ b/stepmania/src/Player.h @@ -58,6 +58,8 @@ protected: void HandleNoteScore( TapNoteScore score, int iNumTapsInRow ); void HandleHoldNoteScore( HoldNoteScore score, TapNoteScore TapNoteScore ); + int GetClosestBeat( int col, float fSeconds, float fMaxSecondsAhead, float fMaxSecondsBehind, bool IgnoreScored ); + static float GetMaxBeatDifference(); PlayerNumber m_PlayerNumber;