Implement GlobalOffsetSeconds in GameState::UpdateSongPosition,
not TimingData. TimingData is a simple data structure, and shouldn't be affected by hardware tweaks. This is also easier to bypass in cases we don't want GlobalOffsetSeconds. Don't adjust assist tick by GlobalOffsetSeconds.
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user