From f1f783877f0f8338a225244faff4e40efe10a4ce Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 21 Jul 2018 18:07:45 +0200 Subject: NBT: rework type system --- src/World/Chunk.cpp | 8 +++++--- src/World/Chunk.hpp | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'src/World') diff --git a/src/World/Chunk.cpp b/src/World/Chunk.cpp index 07e38a4..38ca496 100644 --- a/src/World/Chunk.cpp +++ b/src/World/Chunk.cpp @@ -44,8 +44,9 @@ Chunk::Chunk(const ChunkData *data) { std::shared_ptr lightPopulatedTag = level->get("LightPopulated"); bool lightPopulated = lightPopulatedTag && lightPopulatedTag->getValue(); - sections = assertValue(level->get>("Sections")); - maxY = (assertValue(sections->back()->get("Y"))->getValue() + 1) * SIZE; + sections = assertValue(level->get("Sections")); + const NBT::CompoundTag *lastSection = assertValue(dynamic_cast(sections->back().get())); + maxY = (assertValue(lastSection->get("Y"))->getValue() + 1) * SIZE; std::shared_ptr biomeTag = assertValue(level->get("Biomes")); @@ -65,7 +66,8 @@ Chunk::Chunk(const ChunkData *data) { std::memset(blockBlockLight.get(), 0, maxY * SIZE * SIZE / 2); - for (auto §ion : *sections) { + for (auto §ionTag : *sections) { + const NBT::CompoundTag *section = assertValue(dynamic_cast(sectionTag.get())); std::shared_ptr blocks = assertValue(section->get("Blocks")); std::shared_ptr data = assertValue(section->get("Data")); size_t Y = assertValue(section->get("Y"))->getValue(); diff --git a/src/World/Chunk.hpp b/src/World/Chunk.hpp index d4213b3..4bd301d 100644 --- a/src/World/Chunk.hpp +++ b/src/World/Chunk.hpp @@ -52,7 +52,7 @@ public: private: std::shared_ptr level; - std::shared_ptr> sections; + std::shared_ptr sections; unsigned maxY; @@ -107,7 +107,7 @@ public: return *level; } - const NBT::ListTag & getSections() const { + const NBT::ListTag & getSections() const { return *sections; } -- cgit v1.2.3