MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / update

Method update

source/game/StarSongbook.cpp:69–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67}
68
69void Songbook::update(EntityMode mode, World* world) {
70 m_serverMode = world->isServer();
71
72 if (m_serverMode)
73 return;
74
75 m_globalNowDelta = world->epochTime() * 1000 - Time::millisecondsSinceEpoch();
76 if (m_epochUpdated) {
77 m_epochUpdated = false;
78 m_timeSourceEpoch -= m_globalNowDelta;
79 }
80 if (m_dataUpdated) {
81 m_dataUpdated = false;
82 if (!m_song.isNull()) {
83 try {
84 {
85 MutexLocker lock(s_timeSourcesMutex);
86 if (!s_timeSources.contains(m_timeSource)) {
87 m_timeSourceInstance = make_shared<TimeSource>();
88 s_timeSources[m_timeSource] = m_timeSourceInstance;
89 m_timeSourceInstance->epoch = m_timeSourceEpoch;
90 m_timeSourceInstance->keepalive = m_timeSourceEpoch;
91 } else
92 m_timeSourceInstance = s_timeSources[m_timeSource];
93 }
94 m_track.clear();
95 m_stopped = false;
96 m_track.appendAll(parseABC(m_song.getString("abc")));
97 } catch (StarException const& e) {
98 Logger::error("Failed to handle abc: {}", outputException(e, true));
99 m_stopped = true;
100 }
101 }
102 }
103 if (mode == EntityMode::Master) {
104 if (active())
105 m_activeCooldown--;
106 }
107 playback();
108}
109
110void Songbook::playback() {
111 if (!active() || (m_track.empty() && m_heldNotes.empty())) {

Callers

nothing calls this directly

Calls 9

errorFunction · 0.85
isServerMethod · 0.80
appendAllMethod · 0.80
getStringMethod · 0.80
outputExceptionFunction · 0.50
epochTimeMethod · 0.45
isNullMethod · 0.45
containsMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected