mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 02:51:49 +00:00
Merge branch 'voxel-upd' into vixel-upd-2
This commit is contained in:
commit
d9e1d353d5
36 changed files with 498 additions and 286 deletions
|
|
@ -4,7 +4,7 @@
|
|||
#include <limits>
|
||||
#include <stdexcept>
|
||||
|
||||
void BinaryWriter::put(ubyte b) {
|
||||
void BinaryWriter::put(u_char8 b) {
|
||||
buffer.push_back(b);
|
||||
}
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ void BinaryWriter::put(const std::string& s) {
|
|||
throw std::domain_error("length > INT16_MAX");
|
||||
}
|
||||
putInt16(len);
|
||||
put((const ubyte*)s.data(), len);
|
||||
put((const u_char8*)s.data(), len);
|
||||
}
|
||||
|
||||
void BinaryWriter::putShortStr(const std::string& s) {
|
||||
|
|
@ -31,10 +31,10 @@ void BinaryWriter::putShortStr(const std::string& s) {
|
|||
throw std::domain_error("length > 255");
|
||||
}
|
||||
put(len);
|
||||
put((const ubyte*)s.data(), len);
|
||||
put((const u_char8*)s.data(), len);
|
||||
}
|
||||
|
||||
void BinaryWriter::put(const ubyte* arr, size_t size) {
|
||||
void BinaryWriter::put(const u_char8* arr, size_t size) {
|
||||
buffer.reserve(buffer.size() + size);
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
buffer.push_back(arr[i]);
|
||||
|
|
@ -75,7 +75,7 @@ void BinaryWriter::putFloat32(float val) {
|
|||
putInt32(value.vali32);
|
||||
}
|
||||
|
||||
BinaryReader::BinaryReader(const ubyte* data, size_t size)
|
||||
BinaryReader::BinaryReader(const u_char8* data, size_t size)
|
||||
: data(data), size(size), pos(0) {
|
||||
}
|
||||
|
||||
|
|
@ -84,14 +84,14 @@ void BinaryReader::checkMagic(const char* data, size_t size) {
|
|||
throw std::runtime_error("invalid magic number");
|
||||
}
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
if (this->data[pos + i] != (ubyte)data[i]){
|
||||
if (this->data[pos + i] != (u_char8)data[i]){
|
||||
throw std::runtime_error("invalid magic number");
|
||||
}
|
||||
}
|
||||
pos += size;
|
||||
}
|
||||
|
||||
ubyte BinaryReader::get() {
|
||||
u_char8 BinaryReader::get() {
|
||||
if (pos == size) {
|
||||
throw std::underflow_error("buffer underflow");
|
||||
}
|
||||
|
|
@ -152,7 +152,7 @@ std::string BinaryReader::getString() {
|
|||
}
|
||||
|
||||
std::string BinaryReader::getShortString() {
|
||||
ubyte length = get();
|
||||
u_char8 length = get();
|
||||
if (pos+length > size) {
|
||||
throw std::underflow_error("unexpected end");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue