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

Method run

source/game/StarSystemWorldServerThread.cpp:53–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51}
52
53void SystemWorldServerThread::run() {
54 TickRateApproacher tickApproacher(1.0 / SystemWorldTimestep, 0.5);
55
56 while (!m_stop) {
57 LogMap::set(strf("system_{}_update_rate", m_systemLocation), strf("{:4.2f}Hz", tickApproacher.rate()));
58
59 update();
60
61 m_periodicStorage -= 1.0 / tickApproacher.rate();
62 if (m_triggerStorage || m_periodicStorage <= 0.0) {
63 m_triggerStorage = false;
64 m_periodicStorage = 300.0; // store every 5 minutes
65 store();
66 }
67
68 tickApproacher.tick();
69
70 double spareTime = tickApproacher.spareTime();
71 uint64_t millis = floor(spareTime * 1000);
72 if (spareTime > 0)
73 sleepPrecise(millis);
74 }
75
76 store();
77}
78
79void SystemWorldServerThread::stop() {
80 m_stop = true;

Callers

nothing calls this directly

Calls 5

strfFunction · 0.85
rateMethod · 0.80
spareTimeMethod · 0.80
setFunction · 0.50
tickMethod · 0.45

Tested by

no test coverage detected