summaryrefslogtreecommitdiffstats
path: root/src/World
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2015-02-01 03:21:57 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2015-02-01 03:21:57 +0100
commitfc1fc8fbbc9dd9534f40de348210ea66b6defe42 (patch)
tree3cfa5fae12050f49df5cc6bc0482d4e5a45711d1 /src/World
parenta6a2a6281218688de7a74a9cd2a426aad3fe2da2 (diff)
downloadMinedMap-fc1fc8fbbc9dd9534f40de348210ea66b6defe42.tar
MinedMap-fc1fc8fbbc9dd9534f40de348210ea66b6defe42.zip
Use template argument for list subtype, extract further information from chunks
Diffstat (limited to 'src/World')
-rw-r--r--src/World/Chunk.cpp4
-rw-r--r--src/World/Chunk.hpp7
2 files changed, 11 insertions, 0 deletions
diff --git a/src/World/Chunk.cpp b/src/World/Chunk.cpp
index f3a140d..fb46466 100644
--- a/src/World/Chunk.cpp
+++ b/src/World/Chunk.cpp
@@ -95,6 +95,10 @@ Chunk::Chunk(uint8_t *buffer, size_t buflen) {
if (!(*this) || tag.first != "")
throw std::invalid_argument("invalid root tag");
+
+ sections = (*this)->get<const NBT::ListTag<NBT::CompoundTag>>("Level", "Sections");
+ if (!sections)
+ throw std::invalid_argument("no sections found");
}
}
diff --git a/src/World/Chunk.hpp b/src/World/Chunk.hpp
index 7c485eb..3ed6cf4 100644
--- a/src/World/Chunk.hpp
+++ b/src/World/Chunk.hpp
@@ -29,6 +29,7 @@
#include "../UniqueCPtr.hpp"
#include "../NBT/CompoundTag.hpp"
+#include "../NBT/ListTag.hpp"
#include <cstdint>
#include <tuple>
@@ -44,8 +45,14 @@ public:
private:
static std::pair<UniqueCPtr<uint8_t[]>, size_t> inflateChunk(uint8_t *data, size_t len);
+ std::shared_ptr<const NBT::ListTag<NBT::CompoundTag>> sections;
+
public:
Chunk(uint8_t *buffer, size_t buflen);
+
+ const NBT::ListTag<NBT::CompoundTag> & getSections() const {
+ return *sections;
+ }
};
}