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

Method syncSector

source/game/StarWorldStorage.cpp:809–844  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

807}
808
809void WorldStorage::syncSector(Sector const& sector) {
810 if (!m_tileArray->sectorValid(sector))
811 return;
812
813 auto entityFactory = Root::singleton().entityFactory();
814 auto& metadata = m_sectorMetadata[sector];
815
816 // Only sync the levels that we know are loaded. It is possible that this
817 // sector is at load level < Entities but has zombie entities in it, but
818 // storing those without unloading them will lead to duplication. Zombie
819 // entities will be unloaded in update eventually anyway.
820
821 if (metadata.loadLevel >= SectorLoadLevel::Entities) {
822 EntitySectorStore sectorStore;
823 UniqueIndexStore storedUniques;
824 for (auto const& entity : m_entityMap->entityQuery(RectF(m_tileArray->sectorRegion(sector)))) {
825 if (!belongsInSector(sector, entity->position()))
826 continue;
827
828 if (m_generatorFacade->entityPersistent(this, entity)) {
829 if (auto uniqueId = entity->uniqueId())
830 storedUniques.add(*uniqueId, {sector, entity->position()});
831 sectorStore.append(entityFactory->storeVersionedEntity(entity));
832 }
833 }
834 m_db.insert(entitySectorKey(sector), writeEntitySector(sectorStore));
835 updateSectorUniques(sector, storedUniques);
836 }
837
838 if (metadata.loadLevel >= SectorLoadLevel::Tiles) {
839 TileSectorStore sectorStore;
840 sectorStore.tiles = m_tileArray->copySector(sector);
841 sectorStore.generationLevel = metadata.generationLevel;
842 m_db.insert(tileSectorKey(sector), writeTileSector(sectorStore));
843 }
844}
845
846List<WorldStorage::Sector> WorldStorage::adjacentSectors(Sector const& sector) const {
847 auto tiles = m_tileArray->sectorRegion(sector);

Callers

nothing calls this directly

Calls 13

singletonClass · 0.85
entityFactoryMethod · 0.80
sectorRegionMethod · 0.80
entityPersistentMethod · 0.80
uniqueIdMethod · 0.80
storeVersionedEntityMethod · 0.80
sectorValidMethod · 0.45
entityQueryMethod · 0.45
positionMethod · 0.45
addMethod · 0.45
appendMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected