diff --git a/src/Background.cpp b/src/Background.cpp index b86a86027e..d5b14b308b 100644 --- a/src/Background.cpp +++ b/src/Background.cpp @@ -577,9 +577,8 @@ void BackgroundImpl::LoadFromSong( const Song* pSong ) else // pSong doesn't have an animation plan { Layer &layer = m_Layer[0]; - const TimingData &t = pSong->m_SongTiming; - float firstBeat = t.GetBeatFromElapsedTime(pSong->firstSecond); - float lastBeat = t.GetBeatFromElapsedTime(pSong->lastSecond); + float firstBeat = pSong->GetFirstBeat(); + float lastBeat = pSong->GetLastBeat(); LoadFromRandom( firstBeat, lastBeat, BackgroundChange() ); @@ -645,7 +644,7 @@ void BackgroundImpl::LoadFromSong( const Song* pSong ) continue; float fStartBeat = change.m_fStartBeat; - float fEndBeat = pSong->m_SongTiming.GetBeatFromElapsedTime(pSong->lastSecond); + float fEndBeat = pSong->GetLastBeat(); if( i+1 < mainlayer.m_aBGChanges.size() ) fEndBeat = mainlayer.m_aBGChanges[i+1].m_fStartBeat; diff --git a/src/DancingCharacters.cpp b/src/DancingCharacters.cpp index d9382c42d1..403277580c 100644 --- a/src/DancingCharacters.cpp +++ b/src/DancingCharacters.cpp @@ -166,8 +166,7 @@ void DancingCharacters::LoadNextSong() m_fThisCameraEndBeat = 0; ASSERT( GAMESTATE->m_pCurSong ); - Song &s = *GAMESTATE->m_pCurSong; - m_fThisCameraEndBeat = s.m_SongTiming.GetBeatFromElapsedTime(s.firstSecond); + m_fThisCameraEndBeat = GAMESTATE->m_pCurSong->GetFirstBeat(); FOREACH_PlayerNumber( p ) if( GAMESTATE->IsPlayerEnabled(p) ) @@ -213,8 +212,7 @@ void DancingCharacters::Update( float fDelta ) bWasGameplayStarting = bGameplayStarting; static float fLastBeat = GAMESTATE->m_Position.m_fSongBeat; - Song &s = *GAMESTATE->m_pCurSong; - float firstBeat = s.m_SongTiming.GetBeatFromElapsedTime(s.firstSecond); + float firstBeat = GAMESTATE->m_pCurSong->GetFirstBeat(); float fThisBeat = GAMESTATE->m_Position.m_fSongBeat; if( fLastBeat < firstBeat && fThisBeat >= firstBeat ) { diff --git a/src/GameState.cpp b/src/GameState.cpp index 1ba34d53f9..bf9a841bd8 100644 --- a/src/GameState.cpp +++ b/src/GameState.cpp @@ -992,7 +992,7 @@ float GameState::GetSongPercent( float beat ) const { // 0 = first step; 1 = last step float curTime = this->m_pCurSong->m_SongTiming.GetElapsedTimeFromBeat(beat); - return (curTime - m_pCurSong->firstSecond) / m_pCurSong->lastSecond; + return (curTime - m_pCurSong->GetFirstSecond()) / m_pCurSong->GetLastSecond(); } int GameState::GetNumStagesLeft( PlayerNumber pn ) const diff --git a/src/Inventory.cpp b/src/Inventory.cpp index 71a30a9ba9..b45b779449 100644 --- a/src/Inventory.cpp +++ b/src/Inventory.cpp @@ -122,7 +122,7 @@ void Inventory::Update( float fDelta ) Song &song = *GAMESTATE->m_pCurSong; // use items if this player is CPU-controlled if( m_pPlayerState->m_PlayerController != PC_HUMAN && - GAMESTATE->m_Position.m_fSongBeat < song.m_SongTiming.GetBeatFromElapsedTime(song.lastSecond) ) + GAMESTATE->m_Position.m_fSongBeat < song.GetLastBeat() ) { // every 1 seconds, try to use an item int iLastSecond = (int)(RageTimer::GetTimeSinceStartFast() - fDelta); diff --git a/src/LyricDisplay.cpp b/src/LyricDisplay.cpp index a6bdfea918..b896814e1d 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->lastSecond; + fEndTime = pSong->GetLastSecond(); const float fDistance = fEndTime - pSong->m_LyricSegments[m_iCurLyricNumber].m_fStartTime; const float fTweenBufferTime = IN_LENGTH.GetValue() + OUT_LENGTH.GetValue(); diff --git a/src/MeterDisplay.cpp b/src/MeterDisplay.cpp index 5bc9da2e6a..cd8c2faebb 100644 --- a/src/MeterDisplay.cpp +++ b/src/MeterDisplay.cpp @@ -73,8 +73,8 @@ void SongMeterDisplay::Update( float fDeltaTime ) { if( GAMESTATE->m_pCurSong ) { - float fSongStartSeconds = GAMESTATE->m_pCurSong->firstSecond; - float fSongEndSeconds = GAMESTATE->m_pCurSong->lastSecond; + float fSongStartSeconds = GAMESTATE->m_pCurSong->GetFirstSecond(); + float fSongEndSeconds = GAMESTATE->m_pCurSong->GetLastSecond(); float fPercentPositionSong = SCALE( GAMESTATE->m_Position.m_fMusicSeconds, fSongStartSeconds, fSongEndSeconds, 0.0f, 1.0f ); CLAMP( fPercentPositionSong, 0, 1 ); diff --git a/src/NotesLoaderSM.cpp b/src/NotesLoaderSM.cpp index 82da1ffbbc..ffe564269c 100644 --- a/src/NotesLoaderSM.cpp +++ b/src/NotesLoaderSM.cpp @@ -1090,7 +1090,7 @@ void SMLoader::TidyUpData( Song &song, bool bFromCache ) if( bFromCache ) break; - float lastBeat = song.m_SongTiming.GetBeatFromElapsedTime(song.lastSecond); + float lastBeat = song.GetLastBeat(); /* If BGChanges already exist after the last beat, don't add the * background in the middle. */ if( !bg.empty() && bg.back().m_fStartBeat-0.0001f >= lastBeat ) diff --git a/src/NotesLoaderSSC.cpp b/src/NotesLoaderSSC.cpp index d2d92daf51..1f4314a31a 100644 --- a/src/NotesLoaderSSC.cpp +++ b/src/NotesLoaderSSC.cpp @@ -410,7 +410,7 @@ bool SSCLoader::LoadFromSimfile( const RString &sPath, Song &out, bool bFromCach out.firstSecond = StringToFloat( sParams[1] ); } - else if( sValueName=="LASTBEAT" ) + else if( sValueName=="LASTSECOND" ) { if( bFromCache ) out.lastSecond = StringToFloat( sParams[1] ); diff --git a/src/NotesWriterJson.cpp b/src/NotesWriterJson.cpp index f0df061323..8320c3d4b9 100644 --- a/src/NotesWriterJson.cpp +++ b/src/NotesWriterJson.cpp @@ -147,8 +147,8 @@ bool NotesWriterJson::WriteSong( const RString &sFile, const Song &out, bool bWr else root["Selectable"] = "YES"; - root["FirstBeat"] = out.m_SongTiming.GetBeatFromElapsedTime(out.firstSecond); - root["LastBeat"] = out.m_SongTiming.GetBeatFromElapsedTime(out.lastSecond); + root["FirstBeat"] = out.GetFirstBeat(); + root["LastBeat"] = out.GetLastBeat(); root["SongFileName"] = out.m_sSongFileName; root["HasMusic"] = out.m_bHasMusic; root["HasBanner"] = out.m_bHasBanner; diff --git a/src/NotesWriterSSC.cpp b/src/NotesWriterSSC.cpp index 261cf73c05..364361dd74 100644 --- a/src/NotesWriterSSC.cpp +++ b/src/NotesWriterSSC.cpp @@ -368,8 +368,8 @@ bool NotesWriterSSC::Write( RString sPath, const Song &out, const vector if( bSavingCache ) { f.PutLine( ssprintf( "// cache tags:" ) ); - f.PutLine( ssprintf( "#FIRSTSECOND:%.6f;", out.firstSecond ) ); - f.PutLine( ssprintf( "#LASTSECOND:%.6f;", out.lastSecond ) ); + f.PutLine( ssprintf( "#FIRSTSECOND:%.6f;", out.GetFirstSecond() ) ); + f.PutLine( ssprintf( "#LASTSECOND:%.6f;", out.GetLastSecond() ) ); f.PutLine( ssprintf( "#SONGFILENAME:%s;", out.m_sSongFileName.c_str() ) ); f.PutLine( ssprintf( "#HASMUSIC:%i;", out.m_bHasMusic ) ); f.PutLine( ssprintf( "#HASBANNER:%i;", out.m_bHasBanner ) ); diff --git a/src/ScreenEdit.cpp b/src/ScreenEdit.cpp index 4de9d3ede2..1ac2c39f78 100644 --- a/src/ScreenEdit.cpp +++ b/src/ScreenEdit.cpp @@ -4713,12 +4713,12 @@ float ScreenEdit::GetMaximumBeatForNewNote() const case EditMode_Home: { Song &s = *GAMESTATE->m_pCurSong; - TimingData &timing = s.m_SongTiming; - float fEndBeat = timing.GetBeatFromElapsedTime(s.lastSecond); + float fEndBeat = s.GetLastBeat(); /* Round up to the next measure end. Some songs end on weird beats * mid-measure, and it's odd to have movement capped to these weird * beats. */ + TimingData &timing = s.m_SongTiming; float playerBeat = GetAppropriatePosition().m_fSongBeat; int beatsPerMeasure = timing.GetTimeSignatureSegmentAtBeat( playerBeat ).GetNum(); fEndBeat += beatsPerMeasure; diff --git a/src/ScreenGameplay.cpp b/src/ScreenGameplay.cpp index 5379530502..7cb93d1113 100644 --- a/src/ScreenGameplay.cpp +++ b/src/ScreenGameplay.cpp @@ -1329,7 +1329,7 @@ void ScreenGameplay::StartPlayingSong( float fMinTimeToNotes, float fMinTimeToMu p.StopMode = RageSoundParams::M_CONTINUE; { - const float fFirstSecond = GAMESTATE->m_pCurSong->firstSecond; + const float fFirstSecond = GAMESTATE->m_pCurSong->GetFirstSecond(); float fStartDelay = fMinTimeToNotes - fFirstSecond; fStartDelay = max( fStartDelay, fMinTimeToMusic ); p.m_StartSecond = -fStartDelay; @@ -1412,8 +1412,7 @@ void ScreenGameplay::PlayAnnouncer( RString type, float fSeconds ) if( m_DancingState != STATE_DANCING ) return; if(GAMESTATE->m_pCurSong == NULL || // this will be true on ScreenDemonstration sometimes - GAMESTATE->m_Position.m_fSongBeat < - GAMESTATE->m_pCurSong->m_SongTiming.GetBeatFromElapsedTime(GAMESTATE->m_pCurSong->firstSecond) ) + GAMESTATE->m_Position.m_fSongBeat < GAMESTATE->m_pCurSong->GetFirstBeat()) return; if( m_fTimeSinceLastDancingComment < fSeconds ) @@ -1488,7 +1487,7 @@ bool ScreenGameplay::AllAreFailing() void ScreenGameplay::GetMusicEndTiming( float &fSecondsToStartFadingOutMusic, float &fSecondsToStartTransitioningOut ) { - float fLastStepSeconds = GAMESTATE->m_pCurSong->lastSecond; + float fLastStepSeconds = GAMESTATE->m_pCurSong->GetLastSecond(); fLastStepSeconds += Player::GetMaxStepDistanceSeconds(); float fTransitionLength; @@ -1698,10 +1697,8 @@ void ScreenGameplay::Update( float fDeltaTime ) STATSMAN->m_CurStageStats.m_fGameplaySeconds += fUnscaledDeltaTime; float curBeat = GAMESTATE->m_Position.m_fSongBeat; Song &s = *GAMESTATE->m_pCurSong; - TimingData &timing = s.m_SongTiming; - - if( curBeat >= timing.GetBeatFromElapsedTime(s.firstSecond) && curBeat < timing.GetBeatFromElapsedTime(s.lastSecond) ) + if( curBeat >= s.GetFirstBeat() && curBeat < s.GetLastBeat() ) { STATSMAN->m_CurStageStats.m_fStepsSeconds += fUnscaledDeltaTime; @@ -1983,7 +1980,7 @@ void ScreenGameplay::UpdateLights() // Before the first beat of the song, all cabinet lights solid on (except for menu buttons). Song &s = *GAMESTATE->m_pCurSong; - bool bOverrideCabinetBlink = (GAMESTATE->m_Position.m_fSongBeat < s.m_SongTiming.GetBeatFromElapsedTime(s.firstSecond)); + bool bOverrideCabinetBlink = (GAMESTATE->m_Position.m_fSongBeat < s.GetFirstBeat()); FOREACH_CabinetLight( cl ) bBlinkCabinetLight[cl] |= bOverrideCabinetBlink; diff --git a/src/Song.cpp b/src/Song.cpp index 992410adbe..fefc77f0fa 100644 --- a/src/Song.cpp +++ b/src/Song.cpp @@ -529,7 +529,7 @@ void Song::TidyUpData( bool bFromCache ) if( m_fMusicSampleStartSeconds+m_fMusicSampleLengthSeconds > this->m_fMusicLengthSeconds ) { // Attempt to get a reasonable default. - int iBeat = lrintf(this->m_SongTiming.GetBeatFromElapsedTime(this->lastSecond)/2); + int iBeat = lrintf(this->m_SongTiming.GetBeatFromElapsedTime(this->GetLastSecond())/2); iBeat -= iBeat%4; m_fMusicSampleStartSeconds = timing.GetElapsedTimeFromBeat( (float)iBeat ); } @@ -818,7 +818,7 @@ void Song::TranslateTitles() void Song::ReCalculateRadarValuesAndLastBeat( bool bFromCache ) { - if( bFromCache && this->firstSecond >= 0 && this->lastSecond > 0 ) + if( bFromCache && this->GetFirstSecond() >= 0 && this->GetLastSecond() > 0 ) { // this is loaded from cache, then we just have to calculate the radar values. for( unsigned i=0; ilastSecond - this->firstSecond; + return this->GetLastSecond() - this->GetFirstSecond(); } bool Song::IsLong() const