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

Method loadSettings

source/game/StarUniverseServer.cpp:1282–1308  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1280}
1281
1282void UniverseServer::loadSettings() {
1283 RecursiveMutexLocker locker(m_mainLock);
1284
1285 auto loadDefaultSettings = [this]() {
1286 m_universeClock = make_shared<Clock>();
1287 m_universeSettings = make_shared<UniverseSettings>();
1288 };
1289
1290 auto versioningDatabase = Root::singleton().versioningDatabase();
1291 auto storageFile = File::relativeTo(m_storageDirectory, "universe.dat");
1292 if (File::isFile(storageFile)) {
1293 try {
1294 auto settings = versioningDatabase->loadVersionedJson(VersionedJson::readFile(storageFile), "UniverseSettings");
1295 m_universeSettings = make_shared<UniverseSettings>(settings);
1296 m_universeClock = make_shared<Clock>();
1297 m_universeClock->setTime(settings.getDouble("time"));
1298 } catch (std::exception const& e) {
1299 Logger::error("UniverseServer: Could not load universe settings file, loading defaults {}", outputException(e, false));
1300 File::rename(storageFile, strf("{}.{}.fail", storageFile, Time::millisecondsSinceEpoch()));
1301 loadDefaultSettings();
1302 }
1303 } else {
1304 loadDefaultSettings();
1305 }
1306
1307 m_universeClock->start();
1308}
1309
1310Maybe<CelestialCoordinate> UniverseServer::nextStarterWorld() {
1311 RecursiveMutexLocker locker(m_mainLock);

Callers

nothing calls this directly

Calls 9

singletonClass · 0.85
errorFunction · 0.85
strfFunction · 0.85
versioningDatabaseMethod · 0.80
getDoubleMethod · 0.80
outputExceptionFunction · 0.50
loadVersionedJsonMethod · 0.45
setTimeMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected