mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-03-05 17:44:52 +01:00
NBT: unify API of different array types
This commit is contained in:
parent
c313db2994
commit
466f393d26
4 changed files with 17 additions and 9 deletions
|
@ -37,7 +37,7 @@ namespace NBT {
|
|||
class ByteArrayTag : public Tag {
|
||||
private:
|
||||
uint32_t len;
|
||||
const uint8_t *value;
|
||||
const uint8_t *ptr;
|
||||
|
||||
public:
|
||||
static const MakeType<ByteArrayTag> Type;
|
||||
|
@ -45,7 +45,7 @@ public:
|
|||
|
||||
ByteArrayTag(Buffer *buffer) {
|
||||
len = buffer->get32();
|
||||
value = buffer->get(len);
|
||||
ptr = buffer->get(len);
|
||||
}
|
||||
|
||||
virtual const TagType & getType() const {
|
||||
|
@ -58,7 +58,7 @@ public:
|
|||
std::string inner = indent + " ";
|
||||
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
uint8_t v = value[i];
|
||||
uint8_t v = ptr[i];
|
||||
|
||||
os << inner
|
||||
<< (unsigned)v << " / "
|
||||
|
@ -74,8 +74,12 @@ public:
|
|||
return len;
|
||||
}
|
||||
|
||||
const uint8_t * getValue() const {
|
||||
return value;
|
||||
const uint8_t * getPointer() const {
|
||||
return ptr;
|
||||
}
|
||||
|
||||
uint8_t getValue(size_t i) const {
|
||||
return ptr[i];
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -77,6 +77,10 @@ public:
|
|||
const uint8_t * getPointer() const {
|
||||
return ptr;
|
||||
}
|
||||
|
||||
uint64_t getValue(size_t i) const {
|
||||
return Buffer::parse64(&ptr[8*i]);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ private:
|
|||
|
||||
uint8_t getBiomeAt(size_t x, size_t z) const {
|
||||
if (biomeBytes)
|
||||
return biomeBytes->getValue()[z*SIZE + x];
|
||||
return biomeBytes->getValue(z*SIZE + x);
|
||||
else
|
||||
return biomeInts->getValue(z*SIZE + x);
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ public:
|
|||
if (!blockLight)
|
||||
return 0;
|
||||
|
||||
return getHalf(blockLight->getValue(), x, y, z);
|
||||
return getHalf(blockLight->getPointer(), x, y, z);
|
||||
}
|
||||
|
||||
static std::unique_ptr<Section> makeSection(const std::shared_ptr<const NBT::CompoundTag> §ion, uint32_t dataVersion);
|
||||
|
@ -91,11 +91,11 @@ private:
|
|||
|
||||
|
||||
uint8_t getBlockAt(size_t x, size_t y, size_t z) const {
|
||||
return blocks->getValue()[getIndex(x, y, z)];
|
||||
return blocks->getValue(getIndex(x, y, z));
|
||||
}
|
||||
|
||||
uint8_t getDataAt(size_t x, size_t y, size_t z) const {
|
||||
return getHalf(data->getValue(), x, y, z);
|
||||
return getHalf(data->getPointer(), x, y, z);
|
||||
}
|
||||
|
||||
public:
|
||||
|
|
Loading…
Add table
Reference in a new issue