diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-06-21 15:25:10 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-06-21 15:25:10 +1000 |
commit | d6fdd960768cbb94a67a1d3cdd34c606807ac180 (patch) | |
tree | b824f0091745d9bea6e02c78b0f7ef4d05e7d5d5 /source/game/StarSongbook.cpp | |
parent | 0ec3000536fae16ede8aa85ad22aba4d9781cc9e (diff) |
Fixes and stuff
Using proper SDL Audio APIs now
Fixed borderless
Create game window before asset load
Bump up root loading worker thread count to 8
Fix not hearing other player songs on load-in
Fix issues with shipworlds missing ship.level property
Fix rare thread race with received chat packets on the server-side
Diffstat (limited to 'source/game/StarSongbook.cpp')
-rw-r--r-- | source/game/StarSongbook.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/source/game/StarSongbook.cpp b/source/game/StarSongbook.cpp index 482fcd3..b420802 100644 --- a/source/game/StarSongbook.cpp +++ b/source/game/StarSongbook.cpp @@ -18,6 +18,7 @@ Songbook::Songbook(String const& species) { m_dataUpdated = false; m_dataChanged = false; m_timeSourceEpoch = 0; + m_epochUpdated = false; m_globalNowDelta = 0; m_species = species; m_stopped = true; @@ -72,6 +73,10 @@ void Songbook::update(EntityMode mode, World* world) { return; m_globalNowDelta = world->epochTime() * 1000 - Time::millisecondsSinceEpoch(); + if (m_epochUpdated) { + m_epochUpdated = false; + m_timeSourceEpoch -= m_globalNowDelta; + } if (m_dataUpdated) { m_dataUpdated = false; if (!m_song.isNull()) { @@ -652,6 +657,7 @@ void Songbook::play(Json const& song, String const& timeSource) { m_timeSource = toString(Random::randu64()); { + m_epochUpdated = false; m_timeSourceEpoch = Time::millisecondsSinceEpoch(); MutexLocker lock(s_timeSourcesMutex); if (!s_timeSources.contains(m_timeSource)) { @@ -702,7 +708,8 @@ double Songbook::fundamentalPitch(double f) { void Songbook::netElementsNeedLoad(bool) { if (m_songNetState.pullUpdated()) { m_song = m_songNetState.get(); - m_timeSourceEpoch = m_timeSourceEpochNetState.get() - m_globalNowDelta; + m_timeSourceEpoch = m_timeSourceEpochNetState.get(); + m_epochUpdated = true; m_dataUpdated = true; } m_timeSource = m_timeSourceNetState.get(); |