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

Method createSystemWorld

source/game/StarUniverseServer.cpp:2321–2355  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2319}
2320
2321SystemWorldServerThreadPtr UniverseServer::createSystemWorld(Vec3I const& location) {
2322 if (!m_systemWorlds.contains(location)) {
2323 SystemWorldServerPtr systemWorld;
2324
2325 String storageFile = File::relativeTo(m_storageDirectory, strf("{}_{}_{}.system", location[0], location[1], location[2]));
2326 bool loadedFromStorage = false;
2327 if (File::isFile(storageFile)) {
2328 Logger::info("UniverseServer: Loading system world {} from disk storage", location);
2329 try {
2330 auto versioningDatabase = Root::singleton().versioningDatabase();
2331 VersionedJson versionedStore = VersionedJson::readFile(storageFile);
2332 Json store = versioningDatabase->loadVersionedJson(versionedStore, "System");
2333
2334 systemWorld = make_shared<SystemWorldServer>(store, m_universeClock, m_celestialDatabase);
2335 loadedFromStorage = true;
2336 } catch (std::exception const& e) {
2337 Logger::error("UniverseServer: Failed to load system {} from disk storage, re-creating. Cause: {}", location, outputException(e, false));
2338 File::rename(storageFile, strf("{}.{}.fail", storageFile, Time::millisecondsSinceEpoch()));
2339 loadedFromStorage = false;
2340 }
2341 }
2342
2343 if (!loadedFromStorage) {
2344 Logger::info("UniverseServer: Creating new system world at location {}", location);
2345 systemWorld = make_shared<SystemWorldServer>(location, m_universeClock, m_celestialDatabase);
2346 }
2347
2348 auto systemThread = make_shared<SystemWorldServerThread>(location, systemWorld, storageFile);
2349 systemThread->setUpdateAction(bind(&UniverseServer::systemWorldUpdated, this, _1));
2350 systemThread->start();
2351 m_systemWorlds.set(location, systemThread);
2352 }
2353
2354 return m_systemWorlds.get(location);
2355}
2356
2357bool UniverseServer::instanceWorldStoredOrActive(InstanceWorldId const& worldId) const {
2358 String storageFile = File::relativeTo(m_storageDirectory, strf("unique-{}.world", worldId.instance));

Callers

nothing calls this directly

Calls 11

strfFunction · 0.85
singletonClass · 0.85
errorFunction · 0.85
versioningDatabaseMethod · 0.80
outputExceptionFunction · 0.50
containsMethod · 0.45
loadVersionedJsonMethod · 0.45
setUpdateActionMethod · 0.45
startMethod · 0.45
setMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected