autosync is back - Tom Jackson appears in a puff of logic
This commit is contained in:
@@ -84,6 +84,8 @@ PlayerMinus::PlayerMinus()
|
||||
m_pSecondaryScoreKeeper = NULL;
|
||||
m_pInventory = NULL;
|
||||
|
||||
m_iOffsetSample = 0;
|
||||
|
||||
this->AddChild( &m_ArrowBackdrop );
|
||||
this->AddChild( &m_Judgment );
|
||||
this->AddChild( &m_ProTimingDisplay );
|
||||
@@ -901,6 +903,10 @@ void PlayerMinus::Step( int col, RageTimer tm )
|
||||
if( score != TNS_NONE )
|
||||
SetTapNoteOffset(col, iIndexOverlappingNote, -fNoteOffset);
|
||||
|
||||
if( GAMESTATE->m_PlayerController[m_PlayerNumber] == PC_HUMAN &&
|
||||
score >= TNS_GREAT )
|
||||
HandleAutosync(fNoteOffset);
|
||||
|
||||
if( m_pPrimaryScoreKeeper )
|
||||
m_pPrimaryScoreKeeper->HandleTapScore( score );
|
||||
if( m_pSecondaryScoreKeeper )
|
||||
@@ -939,6 +945,27 @@ void PlayerMinus::Step( int col, RageTimer tm )
|
||||
m_pNoteField->Step( col );
|
||||
}
|
||||
|
||||
void PlayerMinus::HandleAutosync(float fNoteOffset)
|
||||
{
|
||||
if( !GAMESTATE->m_SongOptions.m_bAutoSync )
|
||||
return;
|
||||
|
||||
m_fOffset[m_iOffsetSample++] = fNoteOffset;
|
||||
if (m_iOffsetSample < SAMPLE_COUNT)
|
||||
return; /* need more */
|
||||
|
||||
const float mean = calc_mean(m_fOffset, m_fOffset+SAMPLE_COUNT);
|
||||
const float stddev = calc_stddev(m_fOffset, m_fOffset+SAMPLE_COUNT);
|
||||
|
||||
if (stddev < .03 && stddev < fabsf(mean)) { //If they stepped with less than .03 error
|
||||
GAMESTATE->m_pCurSong->m_Timing.m_fBeat0OffsetInSeconds += mean;
|
||||
LOG->Trace("Offset corrected by %f. Error in steps: %f seconds.", mean, stddev);
|
||||
} else
|
||||
LOG->Trace("Offset NOT corrected. Average offset: %f seconds. Error: %f seconds.", mean, stddev);
|
||||
|
||||
m_iOffsetSample = 0;
|
||||
}
|
||||
|
||||
|
||||
void PlayerMinus::OnRowCompletelyJudged( int iIndexThatWasSteppedOn )
|
||||
{
|
||||
|
||||
@@ -36,6 +36,8 @@ class CombinedLifeMeter;
|
||||
class ScoreKeeper;
|
||||
class Inventory;
|
||||
|
||||
#define SAMPLE_COUNT 16
|
||||
|
||||
|
||||
class PlayerMinus : public NoteDataWithScoring, public ActorFrame
|
||||
{
|
||||
@@ -63,6 +65,7 @@ protected:
|
||||
void OnRowCompletelyJudged( int iStepIndex );
|
||||
void HandleTapRowScore( unsigned row );
|
||||
void HandleHoldScore( HoldNoteScore holdScore, TapNoteScore tapScore );
|
||||
void HandleAutosync(float fNoteOffset);
|
||||
void DrawTapJudgments();
|
||||
void DrawHoldJudgments();
|
||||
|
||||
@@ -72,6 +75,9 @@ protected:
|
||||
PlayerNumber m_PlayerNumber;
|
||||
float m_fNoteFieldHeight;
|
||||
|
||||
float m_fOffset[SAMPLE_COUNT]; // for AutoSync
|
||||
int m_iOffsetSample;
|
||||
|
||||
ArrowBackdrop m_ArrowBackdrop;
|
||||
NoteField* m_pNoteField;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user