mirror of
https://github.com/quizhizhe/LiteLoaderBDS-1.16.40.git
synced 2025-06-05 03:43:40 +00:00
46 lines
1.3 KiB
C++
46 lines
1.3 KiB
C++
#include <MC/ReadOnlyBinaryStream.hpp>
|
|
#include <MC/CompoundTag.hpp>
|
|
#include <MC/NbtIo.hpp>
|
|
|
|
std::string const& ReadOnlyBinaryStream::getData() const {
|
|
return *pBuf;
|
|
}
|
|
|
|
size_t ReadOnlyBinaryStream::getLength() const {
|
|
return pBuf->size();
|
|
}
|
|
|
|
size_t ReadOnlyBinaryStream::getReadPointer() const {
|
|
return readPointer;
|
|
}
|
|
|
|
size_t ReadOnlyBinaryStream::getUnreadLength() const {
|
|
return getLength() - getReadPointer();
|
|
}
|
|
|
|
void ReadOnlyBinaryStream::setReadPointer(std::size_t size) {
|
|
auto len = getLength();
|
|
if (size <= len)
|
|
readPointer = size;
|
|
else
|
|
readPointer = len;
|
|
}
|
|
|
|
struct IDataInput{
|
|
void* pVT;
|
|
ReadOnlyBinaryStream* pReadOnlyBinaryStream;
|
|
};
|
|
|
|
std::unique_ptr<class CompoundTag> ReadOnlyBinaryStream::getCompoundTag() {
|
|
// auto tag = CompoundTag::create();
|
|
// class CompoundTag& (*rv)(class CompoundTag&, class ReadOnlyBinaryStream&);
|
|
// *((void**)&rv) = dlsym("?read@?$serialize@VCompoundTag@@@@SA?AVCompoundTag@@AEAVReadOnlyBinaryStream@@@Z");
|
|
// (*rv)(*tag, *this);
|
|
IDataInput pVTVarIntDataInput;
|
|
pVTVarIntDataInput.pVT = dlsym("??_7VarIntDataInput@@6B@");
|
|
pVTVarIntDataInput.pReadOnlyBinaryStream = this;
|
|
return std::move(NbtIo::read(pVTVarIntDataInput));
|
|
|
|
}
|
|
|
|
// static_assert(offsetof(ReadOnlyBinaryStream, pBuf) == 56);
|