mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-03-05 01:24:53 +01:00
World: ChunkData: make getRoot() return shared pointer reference
This commit is contained in:
parent
16a1258f08
commit
21966252ea
3 changed files with 5 additions and 5 deletions
|
@ -19,7 +19,7 @@ namespace World {
|
||||||
|
|
||||||
Chunk::Chunk(const ChunkData *data) {
|
Chunk::Chunk(const ChunkData *data) {
|
||||||
std::shared_ptr<const NBT::CompoundTag> level =
|
std::shared_ptr<const NBT::CompoundTag> level =
|
||||||
assertValue(data->getRoot().get<NBT::CompoundTag>("Level"));
|
assertValue(data->getRoot()->get<NBT::CompoundTag>("Level"));
|
||||||
|
|
||||||
std::shared_ptr<const NBT::ListTag> sectionsTag = level->get<NBT::ListTag>("Sections");
|
std::shared_ptr<const NBT::ListTag> sectionsTag = level->get<NBT::ListTag>("Sections");
|
||||||
if (!sectionsTag || sectionsTag->empty())
|
if (!sectionsTag || sectionsTag->empty())
|
||||||
|
@ -37,7 +37,7 @@ Chunk::Chunk(const ChunkData *data) {
|
||||||
else
|
else
|
||||||
throw std::invalid_argument("corrupt biome data");
|
throw std::invalid_argument("corrupt biome data");
|
||||||
|
|
||||||
auto dataVersionTag = data->getRoot().get<NBT::IntTag>("DataVersion");
|
auto dataVersionTag = data->getRoot()->get<NBT::IntTag>("DataVersion");
|
||||||
uint32_t dataVersion = dataVersionTag ? dataVersionTag->getValue() : 0;
|
uint32_t dataVersion = dataVersionTag ? dataVersionTag->getValue() : 0;
|
||||||
|
|
||||||
for (auto &sTag : *sectionsTag) {
|
for (auto &sTag : *sectionsTag) {
|
||||||
|
|
|
@ -32,8 +32,8 @@ private:
|
||||||
public:
|
public:
|
||||||
ChunkData(Buffer buffer);
|
ChunkData(Buffer buffer);
|
||||||
|
|
||||||
const NBT::CompoundTag & getRoot() const {
|
const std::shared_ptr<const NBT::CompoundTag> & getRoot() const {
|
||||||
return *root;
|
return root;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
World::Region::visitChunks(argv[1], [&] (chunk_idx_t X, chunk_idx_t Z, const World::ChunkData *chunk) {
|
World::Region::visitChunks(argv[1], [&] (chunk_idx_t X, chunk_idx_t Z, const World::ChunkData *chunk) {
|
||||||
std::cout << "Chunk(" << X << ", " << Z << "): "
|
std::cout << "Chunk(" << X << ", " << Z << "): "
|
||||||
<< chunk->getRoot() << std::endl;
|
<< *chunk->getRoot() << std::endl;
|
||||||
});
|
});
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue