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

Method readTileSector

source/game/StarWorldStorage.cpp:488–526  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

486}
487
488WorldStorage::TileSectorStore WorldStorage::readTileSector(ByteArray const& data) {
489 auto& root = Root::singleton();
490 auto matDatabase = root.materialDatabase();
491 auto liqDatabase = root.liquidsDatabase();
492 auto storageConfig = root.assets()->json("/worldstorage.config");
493
494 DataStreamBuffer ds(uncompressData(data));
495 TileSectorStore store;
496 ds.vuread(store.generationLevel);
497 ds.vuread(store.tileSerializationVersion);
498
499 store.tiles.reset(new TileArray());
500 for (size_t y = 0; y < WorldSectorSize; ++y) {
501 for (size_t x = 0; x < WorldSectorSize; ++x) {
502 ServerTile tile;
503 tile.read(ds, store.tileSerializationVersion);
504
505 if (!matDatabase->isValidMaterialId(tile.foreground))
506 tile.foreground = storageConfig.getUInt("replacementMaterialId");
507 if (!matDatabase->isValidMaterialId(tile.background))
508 tile.background = storageConfig.getUInt("replacementMaterialId");
509 if (!matDatabase->isValidModId(tile.foregroundMod))
510 tile.foregroundMod = storageConfig.getUInt("replacementModId");
511 if (!matDatabase->isValidModId(tile.backgroundMod))
512 tile.backgroundMod = storageConfig.getUInt("replacementModId");
513 if (!liqDatabase->isValidLiquidId(tile.liquid.liquid)) {
514 LiquidId replacementLiquid = storageConfig.getUInt("replacementLiquidId");
515 if (replacementLiquid == EmptyLiquidId)
516 tile.liquid = LiquidStore();
517 else
518 tile.liquid.liquid = replacementLiquid;
519 }
520
521 (*store.tiles)(x, y) = tile;
522 }
523 }
524
525 return store;
526}
527
528ByteArray WorldStorage::writeTileSector(TileSectorStore const& store) {
529 DataStreamBuffer ds;

Callers

nothing calls this directly

Calls 14

singletonClass · 0.85
uncompressDataFunction · 0.85
LiquidStoreClass · 0.85
materialDatabaseMethod · 0.80
liquidsDatabaseMethod · 0.80
jsonMethod · 0.80
assetsMethod · 0.80
vureadMethod · 0.80
isValidMaterialIdMethod · 0.80
getUIntMethod · 0.80
isValidModIdMethod · 0.80
isValidLiquidIdMethod · 0.80

Tested by

no test coverage detected