diff --git a/stepmania/src/GameSoundManager.cpp b/stepmania/src/GameSoundManager.cpp index 017ddb58d0..066b245430 100644 --- a/stepmania/src/GameSoundManager.cpp +++ b/stepmania/src/GameSoundManager.cpp @@ -491,7 +491,7 @@ void GameSoundManager::Update( float fDeltaTime ) { /* There's no song playing. Fake it. */ CHECKPOINT_M( ssprintf("%f, delta %f", GAMESTATE->m_fMusicSeconds, fDeltaTime) ); - GAMESTATE->UpdateSongPosition( GAMESTATE->m_fMusicSeconds + fDeltaTime, g_Playing->m_Timing ); + GAMESTATE->UpdateSongPosition( GAMESTATE->m_fMusicSecondsNoOffset + fDeltaTime, g_Playing->m_Timing ); return; } @@ -537,7 +537,7 @@ void GameSoundManager::Update( float fDeltaTime ) { /* We're still waiting for the new sound to start playing, so keep using the * old timing data and fake the time. */ - GAMESTATE->UpdateSongPosition( GAMESTATE->m_fMusicSeconds + fDeltaTime, g_Playing->m_Timing ); + GAMESTATE->UpdateSongPosition( GAMESTATE->m_fMusicSecondsNoOffset + fDeltaTime, g_Playing->m_Timing ); } else { diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index 8035825bf6..f2f0394e78 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -582,6 +582,7 @@ const float GameState::MUSIC_SECONDS_INVALID = -5000.0f; void GameState::ResetMusicStatistics() { m_fMusicSeconds = 0; // MUSIC_SECONDS_INVALID; + m_fMusicSecondsNoOffset = 0; m_fSongBeat = 0; m_fCurBPS = 10; m_bFreeze = false; @@ -643,6 +644,10 @@ void GameState::ResetStageStatistics() void GameState::UpdateSongPosition( float fPositionSeconds, const TimingData &timing, const RageTimer ×tamp ) { + m_fMusicSecondsNoOffset = fPositionSeconds; + + fPositionSeconds += PREFSMAN->m_fGlobalOffsetSeconds; + if( !timestamp.IsZero() ) m_LastBeatUpdate = timestamp; else diff --git a/stepmania/src/GameState.h b/stepmania/src/GameState.h index 61f01a4a4d..2b66990d95 100644 --- a/stepmania/src/GameState.h +++ b/stepmania/src/GameState.h @@ -156,6 +156,7 @@ public: // Let a lot of classes access this info here so the don't have to keep their own copies. // float m_fMusicSeconds; // time into the current song + float m_fMusicSecondsNoOffset; // time into the current song, ignoring m_fGlobalOffsetSeconds float m_fSongBeat; float m_fCurBPS; float m_fLightSongBeat; // g_fLightsFalloffSeconds ahead diff --git a/stepmania/src/ScreenEdit.cpp b/stepmania/src/ScreenEdit.cpp index 2d1ebb85ea..a64fe12a62 100644 --- a/stepmania/src/ScreenEdit.cpp +++ b/stepmania/src/ScreenEdit.cpp @@ -782,7 +782,7 @@ void ScreenEdit::PlayTicks() * will start coming out the speaker. Compensate for this by boosting fPositionSeconds * ahead. This is just to make sure that we request the sound early enough for it to * come out on time; the actual precise timing is handled by SetStartTime. */ - float fPositionSeconds = GAMESTATE->m_fMusicSeconds; + float fPositionSeconds = GAMESTATE->m_fMusicSecondsNoOffset; fPositionSeconds += SOUND->GetPlayLatency() + (float)CommonMetrics::TICK_EARLY_SECONDS + 0.250f; const float fSongBeat = GAMESTATE->m_pCurSong->GetBeatFromElapsedTime( fPositionSeconds ); @@ -803,11 +803,11 @@ void ScreenEdit::PlayTicks() { const float fTickBeat = NoteRowToBeat( iTickRow ); const float fTickSecond = GAMESTATE->m_pCurSong->m_Timing.GetElapsedTimeFromBeat( fTickBeat ); - float fSecondsUntil = fTickSecond - GAMESTATE->m_fMusicSeconds; + float fSecondsUntil = fTickSecond - GAMESTATE->m_fMusicSecondsNoOffset; fSecondsUntil /= m_soundMusic.GetPlaybackRate(); /* 2x music rate means the time until the tick is halved */ RageSoundParams p; - p.m_StartTime = GAMESTATE->m_LastBeatUpdate + (fSecondsUntil - (float)CommonMetrics::TICK_EARLY_SECONDS); + p.m_StartTime = GAMESTATE->m_LastBeatUpdate + (fSecondsUntil - (float)CommonMetrics::TICK_EARLY_SECONDS); m_soundAssistTick.Play( &p ); } } diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index 4522a14ae9..f83aa3ee30 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -1433,7 +1433,7 @@ void ScreenGameplay::PlayTicks() * will start coming out the speaker. Compensate for this by boosting fPositionSeconds * ahead. This is just to make sure that we request the sound early enough for it to * come out on time; the actual precise timing is handled by SetStartTime. */ - float fPositionSeconds = GAMESTATE->m_fMusicSeconds; + float fPositionSeconds = GAMESTATE->m_fMusicSecondsNoOffset; fPositionSeconds += SOUND->GetPlayLatency() + (float)CommonMetrics::TICK_EARLY_SECONDS + 0.250f; const float fSongBeat = GAMESTATE->m_pCurSong->GetBeatFromElapsedTime( fPositionSeconds ); @@ -1455,7 +1455,7 @@ void ScreenGameplay::PlayTicks() { const float fTickBeat = NoteRowToBeat( iTickRow ); const float fTickSecond = GAMESTATE->m_pCurSong->m_Timing.GetElapsedTimeFromBeat( fTickBeat ); - float fSecondsUntil = fTickSecond - GAMESTATE->m_fMusicSeconds; + float fSecondsUntil = fTickSecond - GAMESTATE->m_fMusicSecondsNoOffset; fSecondsUntil /= GAMESTATE->m_SongOptions.m_fMusicRate; /* 2x music rate means the time until the tick is halved */ RageSoundParams p; diff --git a/stepmania/src/TimingData.cpp b/stepmania/src/TimingData.cpp index d787ec5bce..f1b6b2709e 100644 --- a/stepmania/src/TimingData.cpp +++ b/stepmania/src/TimingData.cpp @@ -201,8 +201,6 @@ void TimingData::GetBeatAndBPSFromElapsedTime( float fElapsedTime, float &fBeatO { // LOG->Trace( "GetBeatAndBPSFromElapsedTime( fElapsedTime = %f )", fElapsedTime ); - fElapsedTime += PREFSMAN->m_fGlobalOffsetSeconds; - fElapsedTime += m_fBeat0OffsetInSeconds; @@ -264,7 +262,6 @@ void TimingData::GetBeatAndBPSFromElapsedTime( float fElapsedTime, float &fBeatO float TimingData::GetElapsedTimeFromBeat( float fBeat ) const { float fElapsedTime = 0; - fElapsedTime -= PREFSMAN->m_fGlobalOffsetSeconds; fElapsedTime -= m_fBeat0OffsetInSeconds; int iRow = BeatToNoteRow(fBeat);