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

Method doTriggeredStorage

source/game/StarUniverseServer.cpp:1245–1272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1243}
1244
1245void UniverseServer::doTriggeredStorage() {
1246 RecursiveMutexLocker locker(m_mainLock);
1247 ReadLocker clientsLocker(m_clientsLock);
1248
1249 if (Time::monotonicMilliseconds() >= m_storageTriggerDeadline) {
1250 Logger::debug("UniverseServer: periodic sync to disk");
1251 saveSettings();
1252 saveTempWorldIndex();
1253
1254 clientsLocker.unlock();
1255 locker.unlock();
1256 for (auto const& p : m_clients) {
1257 if (auto shipWorld = getWorld(ClientShipWorldId(p.second->playerUuid())))
1258 p.second->updateShipChunks(shipWorld->readChunks());
1259
1260 auto versioningDatabase = Root::singleton().versioningDatabase();
1261 String clientContextFile = File::relativeTo(m_storageDirectory, strf("{}.clientcontext", p.second->playerUuid().hex()));
1262 VersionedJson::writeFile(versioningDatabase->makeCurrentVersionedJson("ClientContext", p.second->storeServerData()), clientContextFile);
1263 }
1264
1265 locker.lock();
1266 clientsLocker.lock();
1267 int storageTriggerInterval = Root::singleton().assets()->json("/universe_server.config:universeStorageInterval").toInt();
1268 m_storageTriggerDeadline = Time::monotonicMilliseconds() + storageTriggerInterval;
1269
1270 m_celestialDatabase->cleanupAndCommit();
1271 }
1272}
1273
1274void UniverseServer::saveSettings() {
1275 RecursiveMutexLocker locker(m_mainLock);

Callers

nothing calls this directly

Calls 15

singletonClass · 0.85
strfFunction · 0.85
playerUuidMethod · 0.80
updateShipChunksMethod · 0.80
versioningDatabaseMethod · 0.80
hexMethod · 0.80
storeServerDataMethod · 0.80
toIntMethod · 0.80
jsonMethod · 0.80
assetsMethod · 0.80
cleanupAndCommitMethod · 0.80
unlockMethod · 0.45

Tested by

no test coverage detected