From 9cb41af5f4b1e349874f8e2d64b9ba79eed99845 Mon Sep 17 00:00:00 2001 From: Jason Felds Date: Mon, 9 May 2011 21:11:33 -0400 Subject: [PATCH] [splittiming] All but ScreenEdit. (67) --- src/Attack.cpp | 12 +++++++----- src/AutoKeysounds.cpp | 2 +- src/Foreground.cpp | 6 +++--- src/GameSoundManager.cpp | 4 ++-- src/LyricDisplay.cpp | 2 +- src/NoteDataUtil.cpp | 4 ++-- src/Player.cpp | 4 ++-- src/ScreenGameplay.cpp | 6 +++--- src/ScreenHowToPlay.cpp | 2 +- src/ScreenSyncOverlay.cpp | 4 ++-- src/Song.cpp | 8 +++++--- 11 files changed, 29 insertions(+), 25 deletions(-) diff --git a/src/Attack.cpp b/src/Attack.cpp index a896944158..1a67cc3181 100644 --- a/src/Attack.cpp +++ b/src/Attack.cpp @@ -11,9 +11,10 @@ void Attack::GetAttackBeats( const Song *pSong, float &fStartBeat, float &fEndBe { ASSERT( pSong ); ASSERT_M( fStartSecond >= 0, ssprintf("StartSecond: %f",fStartSecond) ); - - fStartBeat = pSong->GetBeatFromElapsedTime( fStartSecond ); - fEndBeat = pSong->GetBeatFromElapsedTime( fStartSecond+fSecsRemaining ); + + const TimingData &timing = pSong->m_SongTiming; + fStartBeat = timing.GetBeatFromElapsedTime( fStartSecond ); + fEndBeat = timing.GetBeatFromElapsedTime( fStartSecond+fSecsRemaining ); } /* Get the range for an attack that's being applied in realtime, eg. during battle @@ -34,9 +35,10 @@ void Attack::GetRealtimeAttackBeats( const Song *pSong, const PlayerState* pPlay fStartBeat = min( GAMESTATE->m_fSongBeat+8, pPlayerState->m_fLastDrawnBeat ); fStartBeat = truncf(fStartBeat)+1; - const float lStartSecond = pSong->GetElapsedTimeFromBeat( fStartBeat ); + const TimingData &timing = pSong->m_SongTiming; + const float lStartSecond = timing.GetElapsedTimeFromBeat( fStartBeat ); const float fEndSecond = lStartSecond + fSecsRemaining; - fEndBeat = pSong->GetBeatFromElapsedTime( fEndSecond ); + fEndBeat = timing.GetBeatFromElapsedTime( fEndSecond ); fEndBeat = truncf(fEndBeat)+1; // loading the course should have caught this. diff --git a/src/AutoKeysounds.cpp b/src/AutoKeysounds.cpp index 5aac67976b..aba066200d 100644 --- a/src/AutoKeysounds.cpp +++ b/src/AutoKeysounds.cpp @@ -99,7 +99,7 @@ void AutoKeysounds::LoadAutoplaySoundsInto( RageSoundReader_Chain *pChain ) if( tn[pn].iKeysoundIndex >= 0 ) { RString sKeysoundFilePath = sSongDir + pSong->m_vsKeysoundFile[tn[pn].iKeysoundIndex]; - float fSeconds = pSong->m_Timing.GetElapsedTimeFromBeatNoOffset( NoteRowToBeat(iRow) ) + SOUNDMAN->GetPlayLatency(); + float fSeconds = pSong->m_SongTiming.GetElapsedTimeFromBeatNoOffset( NoteRowToBeat(iRow) ) + SOUNDMAN->GetPlayLatency(); float fPan = 0; if( !bSoundIsGlobal ) diff --git a/src/Foreground.cpp b/src/Foreground.cpp index 708fbcb608..54ba873d7e 100644 --- a/src/Foreground.cpp +++ b/src/Foreground.cpp @@ -41,9 +41,9 @@ void Foreground::LoadFromSong( const Song *pSong ) bga.m_fStartBeat = change.m_fStartBeat; bga.m_bFinished = false; - const float fStartSecond = pSong->m_Timing.GetElapsedTimeFromBeat( bga.m_fStartBeat ); + const float fStartSecond = pSong->m_SongTiming.GetElapsedTimeFromBeat( bga.m_fStartBeat ); const float fStopSecond = fStartSecond + bga.m_bga->GetTweenTimeLeft(); - bga.m_fStopBeat = pSong->m_Timing.GetBeatFromElapsedTime( fStopSecond ); + bga.m_fStopBeat = pSong->m_SongTiming.GetBeatFromElapsedTime( fStopSecond ); bga.m_bga->SetVisible( false ); @@ -82,7 +82,7 @@ void Foreground::Update( float fDeltaTime ) bga.m_bga->SetVisible( true ); bga.m_bga->PlayCommand( "On" ); - const float fStartSecond = m_pSong->m_Timing.GetElapsedTimeFromBeat( bga.m_fStartBeat ); + const float fStartSecond = m_pSong->m_SongTiming.GetElapsedTimeFromBeat( bga.m_fStartBeat ); lDeltaTime = GAMESTATE->m_fMusicSeconds - fStartSecond; } else diff --git a/src/GameSoundManager.cpp b/src/GameSoundManager.cpp index 5b3ba858de..6e517249fb 100644 --- a/src/GameSoundManager.cpp +++ b/src/GameSoundManager.cpp @@ -146,7 +146,7 @@ static void StartMusic( MusicToPlay &ToPlay ) SSCLoader::LoadFromSSCFile(ToPlay.m_sTimingFile, song) ) { ToPlay.HasTiming = true; - ToPlay.m_TimingData = song.m_Timing; + ToPlay.m_TimingData = song.m_SongTiming; // get cabinet lights if any Steps *pStepsCabinetLights = SongUtil::GetOneSteps( &song, StepsType_lights_cabinet ); if( pStepsCabinetLights ) @@ -156,7 +156,7 @@ static void StartMusic( MusicToPlay &ToPlay ) SMLoader::LoadFromSMFile(ToPlay.m_sTimingFile, song) ) { ToPlay.HasTiming = true; - ToPlay.m_TimingData = song.m_Timing; + ToPlay.m_TimingData = song.m_SongTiming; // get cabinet lights if any Steps *pStepsCabinetLights = SongUtil::GetOneSteps( &song, StepsType_lights_cabinet ); if( pStepsCabinetLights ) diff --git a/src/LyricDisplay.cpp b/src/LyricDisplay.cpp index 27263d068c..fec9827e34 100644 --- a/src/LyricDisplay.cpp +++ b/src/LyricDisplay.cpp @@ -59,7 +59,7 @@ void LyricDisplay::Update( float fDeltaTime ) if( m_iCurLyricNumber+1 < GAMESTATE->m_pCurSong->m_LyricSegments.size() ) fEndTime = pSong->m_LyricSegments[m_iCurLyricNumber+1].m_fStartTime; else - fEndTime = pSong->GetElapsedTimeFromBeat( pSong->m_fLastBeat ); + fEndTime = pSong->m_SongTiming.GetElapsedTimeFromBeat( pSong->m_fLastBeat ); const float fDistance = fEndTime - pSong->m_LyricSegments[m_iCurLyricNumber].m_fStartTime; const float fTweenBufferTime = IN_LENGTH.GetValue() + OUT_LENGTH.GetValue(); diff --git a/src/NoteDataUtil.cpp b/src/NoteDataUtil.cpp index 6b7f47cba1..413fd3a425 100644 --- a/src/NoteDataUtil.cpp +++ b/src/NoteDataUtil.cpp @@ -2215,7 +2215,7 @@ void NoteDataUtil::AddTapAttacks( NoteData &nd, Song* pSong ) for( float sec=15; secm_fMusicLengthSeconds; sec+=30 ) { - float fBeat = pSong->GetBeatFromElapsedTime( sec ); + float fBeat = pSong->m_SongTiming.GetBeatFromElapsedTime( sec ); int iBeat = (int)fBeat; int iTrack = iBeat % nd.GetNumTracks(); // deterministically calculates track TapNote tn( @@ -2448,7 +2448,7 @@ void NoteDataUtil::SetHopoPossibleFlags( const Song *pSong, NoteData& ndInOut ) FOREACH_NONEMPTY_ROW_ALL_TRACKS( ndInOut, r ) { float fBeat = NoteRowToBeat( r ); - float fSeconds = pSong->GetElapsedTimeFromBeat( fBeat ); + float fSeconds = pSong->m_SongTiming.GetElapsedTimeFromBeat( fBeat ); int iLastTapTrack = ndInOut.GetLastTrackWithTapOrHoldHead( r ); if( iLastTapTrack != -1 && fSeconds <= fLastRowMusicSeconds + g_fTimingWindowHopo ) diff --git a/src/Player.cpp b/src/Player.cpp index caa30e5c92..2c793bb4c1 100644 --- a/src/Player.cpp +++ b/src/Player.cpp @@ -1873,7 +1873,7 @@ void Player::StepStrumHopo( int col, int row, const RageTimer &tm, bool bHeld, b break; } - const float fSongBeat = GAMESTATE->m_pCurSong ? GAMESTATE->m_pCurSong->GetBeatFromElapsedTime( fPositionSeconds ) : GAMESTATE->m_fSongBeat; + const float fSongBeat = GAMESTATE->m_pCurSong ? GAMESTATE->m_pCurSong->m_SongTiming.GetBeatFromElapsedTime( fPositionSeconds ) : GAMESTATE->m_fSongBeat; const int iSongRow = row == -1 ? BeatToNoteRow( fSongBeat ) : row; if( col != -1 && !bRelease ) @@ -2039,7 +2039,7 @@ void Player::StepStrumHopo( int col, int row, const RageTimer &tm, bool bHeld, b float fNoteOffset = 0.0f; // we need this later if we are autosyncing const float fStepBeat = NoteRowToBeat( iRowOfOverlappingNoteOrRow ); - const float fStepSeconds = GAMESTATE->m_pCurSong->GetElapsedTimeFromBeat(fStepBeat); + const float fStepSeconds = GAMESTATE->m_pCurSong->m_SongTiming.GetElapsedTimeFromBeat(fStepBeat); if( row == -1 ) { diff --git a/src/ScreenGameplay.cpp b/src/ScreenGameplay.cpp index 1a603c7046..f2cba6c337 100644 --- a/src/ScreenGameplay.cpp +++ b/src/ScreenGameplay.cpp @@ -1480,7 +1480,7 @@ bool ScreenGameplay::AllAreFailing() void ScreenGameplay::GetMusicEndTiming( float &fSecondsToStartFadingOutMusic, float &fSecondsToStartTransitioningOut ) { - float fLastStepSeconds = GAMESTATE->m_pCurSong->GetElapsedTimeFromBeat( GAMESTATE->m_pCurSong->m_fLastBeat ); + float fLastStepSeconds = GAMESTATE->m_pCurSong->m_SongTiming.GetElapsedTimeFromBeat( GAMESTATE->m_pCurSong->m_fLastBeat ); fLastStepSeconds += Player::GetMaxStepDistanceSeconds(); float fTransitionLength; @@ -1995,7 +1995,7 @@ void ScreenGameplay::SendCrossedMessages() static int iRowLastCrossed = 0; float fPositionSeconds = GAMESTATE->m_fMusicSeconds; - float fSongBeat = GAMESTATE->m_pCurSong->GetBeatFromElapsedTime( fPositionSeconds ); + float fSongBeat = GAMESTATE->m_pCurSong->m_SongTiming.GetBeatFromElapsedTime( fPositionSeconds ); int iRowNow = BeatToNoteRowNotRounded( fSongBeat ); iRowNow = max( 0, iRowNow ); @@ -2033,7 +2033,7 @@ void ScreenGameplay::SendCrossedMessages() float fNoteWillCrossInSeconds = MESSAGE_SPACING_SECONDS * i; float fPositionSeconds = GAMESTATE->m_fMusicSeconds + fNoteWillCrossInSeconds; - float fSongBeat = GAMESTATE->m_pCurSong->GetBeatFromElapsedTime( fPositionSeconds ); + float fSongBeat = GAMESTATE->m_pCurSong->m_SongTiming.GetBeatFromElapsedTime( fPositionSeconds ); int iRowNow = BeatToNoteRowNotRounded( fSongBeat ); iRowNow = max( 0, iRowNow ); diff --git a/src/ScreenHowToPlay.cpp b/src/ScreenHowToPlay.cpp index 7deca6dd40..877fb693c4 100644 --- a/src/ScreenHowToPlay.cpp +++ b/src/ScreenHowToPlay.cpp @@ -244,7 +244,7 @@ void ScreenHowToPlay::Update( float fDelta ) { if( GAMESTATE->m_pCurSong != NULL ) { - GAMESTATE->UpdateSongPosition( m_fFakeSecondsIntoSong, GAMESTATE->m_pCurSong->m_Timing ); + GAMESTATE->UpdateSongPosition( m_fFakeSecondsIntoSong, GAMESTATE->m_pCurSong->m_SongTiming ); m_fFakeSecondsIntoSong += fDelta; static int iLastNoteRowCounted = 0; diff --git a/src/ScreenSyncOverlay.cpp b/src/ScreenSyncOverlay.cpp index a0038b083f..baf240d54d 100644 --- a/src/ScreenSyncOverlay.cpp +++ b/src/ScreenSyncOverlay.cpp @@ -221,7 +221,7 @@ bool ScreenSyncOverlay::OverlayInput( const InputEventPlus &input ) } if( GAMESTATE->m_pCurSong != NULL ) { - BPMSegment& seg = GAMESTATE->m_pCurSong->GetBPMSegmentAtBeat( GAMESTATE->m_fSongBeat ); + BPMSegment& seg = GAMESTATE->m_pCurSong->m_SongTiming.GetBPMSegmentAtBeat( GAMESTATE->m_fSongBeat ); seg.m_fBPS += fDelta; } } @@ -253,7 +253,7 @@ bool ScreenSyncOverlay::OverlayInput( const InputEventPlus &input ) case ChangeSongOffset: if( GAMESTATE->m_pCurSong != NULL ) - GAMESTATE->m_pCurSong->m_Timing.m_fBeat0OffsetInSeconds += fDelta; + GAMESTATE->m_pCurSong->m_SongTiming.m_fBeat0OffsetInSeconds += fDelta; break; } } diff --git a/src/Song.cpp b/src/Song.cpp index b8882a5ef2..a2c5184425 100644 --- a/src/Song.cpp +++ b/src/Song.cpp @@ -504,13 +504,14 @@ void Song::TidyUpData() m_fMusicSampleStartSeconds == 0 || m_fMusicSampleStartSeconds+m_fMusicSampleLengthSeconds > this->m_fMusicLengthSeconds ) { - m_fMusicSampleStartSeconds = this->GetElapsedTimeFromBeat( 100 ); + const TimingData &timing = this->m_SongTiming; + m_fMusicSampleStartSeconds = timing.GetElapsedTimeFromBeat( 100 ); if( m_fMusicSampleStartSeconds+m_fMusicSampleLengthSeconds > this->m_fMusicLengthSeconds ) { int iBeat = lrintf( m_fLastBeat/2 ); iBeat -= iBeat%4; - m_fMusicSampleStartSeconds = this->GetElapsedTimeFromBeat( (float)iBeat ); + m_fMusicSampleStartSeconds = timing.GetElapsedTimeFromBeat( (float)iBeat ); } } @@ -1485,7 +1486,8 @@ bool Song::HasSignificantBpmChangesOrStops() const float Song::GetStepsSeconds() const { - return GetElapsedTimeFromBeat( m_fLastBeat ) - GetElapsedTimeFromBeat( m_fFirstBeat ); + const TimingData &timing = this->m_SongTiming; + return timing.GetElapsedTimeFromBeat( m_fLastBeat ) - timing.GetElapsedTimeFromBeat( m_fFirstBeat ); } bool Song::IsLong() const