From 372540e3a482c4fe1cfa91ec8ed1b62beea1ed77 Mon Sep 17 00:00:00 2001 From: Thai Pangsakulyanont Date: Thu, 26 May 2011 01:12:41 +0700 Subject: [PATCH] Bringing Thai's fix in for Warps and Delays. --- src/Player.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Player.cpp b/src/Player.cpp index 34d446e620..6a9def4af2 100644 --- a/src/Player.cpp +++ b/src/Player.cpp @@ -1563,8 +1563,13 @@ int Player::GetClosestNote( int col, int iNoteRow, int iMaxRowsAhead, int iMaxRo if( iPrevIndex == -1 ) return iNextIndex; + // Get the current time, previous time, and next time. + float fNoteTime = m_pPlayerState->m_Position.m_fMusicSeconds ; + float fNextTime = m_Timing->GetElapsedTimeFromBeat(NoteRowToBeat(iNextIndex)); + float fPrevTime = m_Timing->GetElapsedTimeFromBeat(NoteRowToBeat(iPrevIndex)); + /* Figure out which row is closer. */ - if( abs(iNoteRow-iNextIndex) > abs(iNoteRow-iPrevIndex) ) + if( fabsf(fNoteTime-fNextTime) > fabsf(fNoteTime-fPrevTime) ) return iPrevIndex; else return iNextIndex; @@ -1623,8 +1628,13 @@ int Player::GetClosestNonEmptyRow( int iNoteRow, int iMaxRowsAhead, int iMaxRows if( iPrevRow == -1 ) return iNextRow; + // Get the current time, previous time, and next time. + float fNoteTime = m_pPlayerState->m_Position.m_fMusicSeconds; + float fNextTime = m_Timing->GetElapsedTimeFromBeat(NoteRowToBeat(iNextRow)); + float fPrevTime = m_Timing->GetElapsedTimeFromBeat(NoteRowToBeat(iPrevRow)); + /* Figure out which row is closer. */ - if( abs(iNoteRow-iNextRow) > abs(iNoteRow-iPrevRow) ) + if( fabsf(fNoteTime-fNextTime) > fabsf(fNoteTime-fPrevTime) ) return iPrevRow; else return iNextRow;