From e6348ac5a203970c914ab80e94ca1166cf66475d Mon Sep 17 00:00:00 2001 From: Roman Shishkin Date: Thu, 16 May 2019 20:16:27 +0300 Subject: [PATCH] Ignore chunks without sections --- src/World/Chunk.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/World/Chunk.cpp b/src/World/Chunk.cpp index 7af7923..f94c763 100644 --- a/src/World/Chunk.cpp +++ b/src/World/Chunk.cpp @@ -43,15 +43,6 @@ Chunk::Chunk(const ChunkData *data) { if (!sectionsTag) return; - biomeBytes = level->get("Biomes"); - biomeInts = level->get("Biomes"); - assertValue(biomeBytes || biomeInts); - - if (biomeBytes && biomeBytes->getLength() != SIZE*SIZE) - throw std::invalid_argument("corrupt biome data"); - else if (biomeInts && biomeInts->getLength() != SIZE*SIZE) - throw std::invalid_argument("corrupt biome data"); - for (auto &sTag : *sectionsTag) { auto s = std::dynamic_pointer_cast(sTag); std::unique_ptr
section = Section::makeSection(s); @@ -61,6 +52,17 @@ Chunk::Chunk(const ChunkData *data) { sections.push_back(std::move(section)); } } + + if (!sections.empty()) { + biomeBytes = level->get("Biomes"); + biomeInts = level->get("Biomes"); + assertValue(biomeBytes || biomeInts); + + if (biomeBytes && biomeBytes->getLength() != SIZE*SIZE) + throw std::invalid_argument("corrupt biome data"); + else if (biomeInts && biomeInts->getLength() != SIZE*SIZE) + throw std::invalid_argument("corrupt biome data"); + } } bool Chunk::getBlock(Block *block, const Section *section, size_t x, size_t y, size_t z, uint8_t prev_light) const {