mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 02:51:49 +00:00
World structure update + new blocks
This commit is contained in:
parent
cc556bc19b
commit
275e4af9fd
9 changed files with 70 additions and 4 deletions
|
|
@ -27,6 +27,15 @@ void BinaryWriter::put(const string& s) {
|
|||
put((const ubyte*)s.data(), len);
|
||||
}
|
||||
|
||||
void BinaryWriter::putShortStr(const string& s) {
|
||||
size_t len = s.length();
|
||||
if (len > 255) {
|
||||
throw std::domain_error("length > 255");
|
||||
}
|
||||
put(len);
|
||||
put((const ubyte*)s.data(), len);
|
||||
}
|
||||
|
||||
void BinaryWriter::put(const ubyte* arr, size_t size) {
|
||||
buffer.reserve(buffer.size() + size);
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
|
|
@ -144,6 +153,15 @@ string BinaryReader::getString() {
|
|||
return string((const char*)(data+pos-length), length);
|
||||
}
|
||||
|
||||
string BinaryReader::getShortString() {
|
||||
ubyte length = get();
|
||||
if (pos+length > size) {
|
||||
throw std::underflow_error("unexpected end");
|
||||
}
|
||||
pos += length;
|
||||
return string((const char*)(data+pos-length), length);
|
||||
}
|
||||
|
||||
bool BinaryReader::hasNext() const {
|
||||
return pos < size;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue