From e691b97d31c3ee65944eef827fae453743ae8d4c Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Thu, 9 Mar 2006 06:39:24 +0000 Subject: [PATCH] reset autosync between each loop in SGSyncMachine --- stepmania/src/AdjustSync.h | 2 +- stepmania/src/MeterDisplay.cpp | 15 +++++++++------ stepmania/src/ScreenGameplaySyncMachine.cpp | 3 +++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/stepmania/src/AdjustSync.h b/stepmania/src/AdjustSync.h index 2a7078fef5..d9d21e38d4 100644 --- a/stepmania/src/AdjustSync.h +++ b/stepmania/src/AdjustSync.h @@ -3,7 +3,7 @@ class TimingData; -const int SAMPLE_COUNT = 32; +const int SAMPLE_COUNT = 30; class AdjustSync { diff --git a/stepmania/src/MeterDisplay.cpp b/stepmania/src/MeterDisplay.cpp index 747f8115c0..dae41f66c2 100644 --- a/stepmania/src/MeterDisplay.cpp +++ b/stepmania/src/MeterDisplay.cpp @@ -74,12 +74,15 @@ void MeterDisplay::SetPercent( float fPercent ) void SongMeterDisplay::Update( float fDeltaTime ) { - float fSongStartSeconds = GAMESTATE->m_pCurSong->m_Timing.GetElapsedTimeFromBeat( GAMESTATE->m_pCurSong->m_fFirstBeat ); - float fSongEndSeconds = GAMESTATE->m_pCurSong->m_Timing.GetElapsedTimeFromBeat( GAMESTATE->m_pCurSong->m_fLastBeat ); - float fPercentPositionSong = SCALE( GAMESTATE->m_fMusicSeconds, fSongStartSeconds, fSongEndSeconds, 0.0f, 1.0f ); - CLAMP( fPercentPositionSong, 0, 1 ); - - SetPercent( fPercentPositionSong ); + if( GAMESTATE->m_pCurSong ) + { + float fSongStartSeconds = GAMESTATE->m_pCurSong->m_Timing.GetElapsedTimeFromBeat( GAMESTATE->m_pCurSong->m_fFirstBeat ); + float fSongEndSeconds = GAMESTATE->m_pCurSong->m_Timing.GetElapsedTimeFromBeat( GAMESTATE->m_pCurSong->m_fLastBeat ); + float fPercentPositionSong = SCALE( GAMESTATE->m_fMusicSeconds, fSongStartSeconds, fSongEndSeconds, 0.0f, 1.0f ); + CLAMP( fPercentPositionSong, 0, 1 ); + + SetPercent( fPercentPositionSong ); + } MeterDisplay::Update( fDeltaTime ); } diff --git a/stepmania/src/ScreenGameplaySyncMachine.cpp b/stepmania/src/ScreenGameplaySyncMachine.cpp index 02b625490a..3dd1c4feb4 100644 --- a/stepmania/src/ScreenGameplaySyncMachine.cpp +++ b/stepmania/src/ScreenGameplaySyncMachine.cpp @@ -79,6 +79,9 @@ void ScreenGameplaySyncMachine::ResetAndRestartCurrentSong() m_pSoundMusic->Stop(); ReloadCurrentSong(); StartPlayingSong( 4, 0 ); + + // reset autosync + AdjustSync::s_iAutosyncOffsetSample = 0; } void ScreenGameplaySyncMachine::RefreshText()