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

Method unloadAll

source/game/StarWorldStorage.cpp:364–392  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

362}
363
364void WorldStorage::unloadAll(bool force) {
365 try {
366 auto storageConfig = Root::singleton().assets()->json("/worldstorage.config");
367 auto sectors = m_sectorMetadata.keys();
368
369 // Entities can do some strange things during unload, such as repeatedly
370 // creating new entities during uninit, or setting their bounding box null
371 // or being entirely outside of the world geometry. This limits the number
372 // of tries to completely uninit and store all entities before giving up
373 // and just letting some entities not be stored.
374 if (m_entityMap) {
375 unsigned forceUnloadTries = storageConfig.getUInt("forceUnloadTries");
376 for (unsigned i = 0; i < forceUnloadTries; ++i) {
377 for (auto& sector : sectors)
378 unloadSectorToLevel(sector, SectorLoadLevel::Tiles, force);
379
380 if (!force || m_entityMap->size() == 0)
381 break;
382 }
383 }
384 for (auto& sector : sectors)
385 unloadSectorToLevel(sector, SectorLoadLevel::None, force);
386
387 } catch (std::exception const& e) {
388 m_db.rollback();
389 m_db.close();
390 throw WorldStorageException("WorldStorage exception during unload", e);
391 }
392}
393
394void WorldStorage::sync() {
395 try {

Callers 2

~WorldServerMethod · 0.80
initMethod · 0.80

Calls 8

singletonClass · 0.85
jsonMethod · 0.80
assetsMethod · 0.80
getUIntMethod · 0.80
rollbackMethod · 0.80
keysMethod · 0.45
sizeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected