diff --git a/stepmania/src/RageDisplay.cpp b/stepmania/src/RageDisplay.cpp index f18139c334..0335c44beb 100644 --- a/stepmania/src/RageDisplay.cpp +++ b/stepmania/src/RageDisplay.cpp @@ -421,6 +421,13 @@ void RageDisplay::Flip() } } +float RageDisplay::PredictedSecondsUntilNextFlip() const +{ + float fps = max( 30.f, GetFPS() ); + return 1.f/fps; +} + + void RageDisplay::ResetStats() { g_iFPS = g_iVPF = 0; diff --git a/stepmania/src/RageDisplay.h b/stepmania/src/RageDisplay.h index ccad602638..df3dd0e088 100644 --- a/stepmania/src/RageDisplay.h +++ b/stepmania/src/RageDisplay.h @@ -38,6 +38,7 @@ public: void Clear(); void Flip(); + float PredictedSecondsUntilNextFlip() const; bool IsWindowed() const; int GetWidth() const; int GetHeight() const; diff --git a/stepmania/src/ScreenEdit.cpp b/stepmania/src/ScreenEdit.cpp index e168677695..60efe2163d 100644 --- a/stepmania/src/ScreenEdit.cpp +++ b/stepmania/src/ScreenEdit.cpp @@ -372,7 +372,6 @@ void ScreenEdit::Update( float fDeltaTime ) // update the global music statistics for other classes to access GAMESTATE->m_fMusicSeconds = fPositionSeconds; -// GAMESTATE->m_fSongBeat = fSongBeat; GAMESTATE->m_fCurBPS = fBPS; GAMESTATE->m_bFreeze = bFreeze; diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index 2733858be3..f38e224ed6 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -722,10 +722,10 @@ bool ScreenGameplay::IsTimeToPlayTicks() const void ScreenGameplay::Update( float fDeltaTime ) { - Screen::Update( fDeltaTime ); - - if( GAMESTATE->m_pCurSong == NULL ) - return; + /* Very important: Update GAMESTATE's song beat information + * -before- calling update on all the classes that depend on it. + * If you don't do this first, the classes are all acting on old + * information and will lag. -Chris */ // update the global music statistics for other classes to access /* If ScreenJukebox is changing screens, it'll stop m_soundMusic to tell @@ -735,9 +735,20 @@ void ScreenGameplay::Update( float fDeltaTime ) if(m_soundMusic.IsPlaying()) GAMESTATE->UpdateSongPosition(m_soundMusic.GetPositionSeconds()); + + Screen::Update( fDeltaTime ); + + m_MaxCombo.SetText( ssprintf("%d", m_Player[GAMESTATE->m_MasterPlayerNumber].GetPlayersMaxCombo()) ); /* MAKE THIS WORK FOR BOTH PLAYERS! */ + + //LOG->Trace( "m_fOffsetInBeats = %f, m_fBeatsPerSecond = %f, m_Music.GetPositionSeconds = %f", m_fOffsetInBeats, m_fBeatsPerSecond, m_Music.GetPositionSeconds() ); + + if( GAMESTATE->m_pCurSong == NULL ) + return; + + int pn; switch( m_DancingState ) { @@ -847,7 +858,9 @@ void ScreenGameplay::Update( float fDeltaTime ) // // Send crossed row messages to Player // - int iRowNow = BeatToNoteRowNotRounded( GAMESTATE->m_fSongBeat ); + + // Why was this originally "BeatToNoteRowNotRounded"? It should be rounded. -Chris + int iRowNow = BeatToNoteRow( GAMESTATE->m_fSongBeat ); if( iRowNow >= 0 && iRowNow < MAX_TAP_NOTE_ROWS ) { for( int r=m_iRowLastCrossed+1; r<=iRowNow; r++ ) // for each index we crossed since the last update diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index c0f10250ce..02954c3a5a 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -526,9 +526,11 @@ static void GameLoop() TEXTUREMAN->Update( fDeltaTime ); + /* Important: Process input before updaing game logic, or else game logic will lag for one frame */ + HandleInputEvents( fDeltaTime ); + SCREENMAN->Update( fDeltaTime ); SOUNDMAN->Update( fDeltaTime ); - HandleInputEvents( fDeltaTime ); /* * Render