mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-05-30 10:26:09 +00:00
format everything
This commit is contained in:
@@ -8,32 +8,32 @@ class Biome;
|
||||
|
||||
class Arrays {
|
||||
public:
|
||||
static void fill(std::vector<double>& arr, unsigned int from, unsigned int to,
|
||||
double value) {
|
||||
static void fill(std::vector<double>& arr, unsigned int from,
|
||||
unsigned int to, double value) {
|
||||
assert(from >= 0);
|
||||
assert(from <= to);
|
||||
assert(to <= arr.size());
|
||||
std::fill(arr.data() + from, arr.data() + to, value);
|
||||
}
|
||||
|
||||
static void fill(std::vector<float>& arr, unsigned int from, unsigned int to,
|
||||
float value) {
|
||||
static void fill(std::vector<float>& arr, unsigned int from,
|
||||
unsigned int to, float value) {
|
||||
assert(from >= 0);
|
||||
assert(from <= to);
|
||||
assert(to <= arr.size());
|
||||
std::fill(arr.data() + from, arr.data() + to, value);
|
||||
}
|
||||
|
||||
static void fill(std::vector<Biome*>& arr, unsigned int from, unsigned int to,
|
||||
Biome* value) {
|
||||
static void fill(std::vector<Biome*>& arr, unsigned int from,
|
||||
unsigned int to, Biome* value) {
|
||||
assert(from >= 0);
|
||||
assert(from <= to);
|
||||
assert(to <= arr.size());
|
||||
std::fill(arr.data() + from, arr.data() + to, value);
|
||||
}
|
||||
|
||||
static void fill(std::vector<uint8_t>& arr, unsigned int from, unsigned int to,
|
||||
uint8_t value) {
|
||||
static void fill(std::vector<uint8_t>& arr, unsigned int from,
|
||||
unsigned int to, uint8_t value) {
|
||||
assert(from >= 0);
|
||||
assert(from <= to);
|
||||
assert(to <= arr.size());
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "Buffer.h"
|
||||
#include "console_helpers/Definitions.h" // 4jcraft TODO
|
||||
#include "console_helpers/Definitions.h" // 4jcraft TODO
|
||||
|
||||
class IntBuffer;
|
||||
class FloatBuffer;
|
||||
|
||||
@@ -12,8 +12,8 @@ private:
|
||||
OutputStream* stream;
|
||||
|
||||
protected:
|
||||
std::vector<uint8_t> buf; // The internal buffer where data is stored.
|
||||
unsigned int count; // The number of valid bytes in the buffer.
|
||||
std::vector<uint8_t> buf; // The internal buffer where data is stored.
|
||||
unsigned int count; // The number of valid bytes in the buffer.
|
||||
|
||||
public:
|
||||
BufferedOutputStream(OutputStream* out, int size);
|
||||
@@ -21,7 +21,8 @@ public:
|
||||
|
||||
virtual void flush();
|
||||
virtual void close();
|
||||
virtual void write(const std::vector<uint8_t>& b, unsigned int offset, unsigned int length);
|
||||
virtual void write(const std::vector<uint8_t>& b, unsigned int offset,
|
||||
unsigned int length);
|
||||
virtual void write(const std::vector<uint8_t>& b);
|
||||
virtual void write(unsigned int b);
|
||||
};
|
||||
@@ -8,8 +8,8 @@
|
||||
|
||||
class ByteArrayInputStream : public InputStream {
|
||||
protected:
|
||||
std::vector<uint8_t> buf; // An array of bytes that was provided by the creator of the
|
||||
// stream.
|
||||
std::vector<uint8_t> buf; // An array of bytes that was provided by the
|
||||
// creator of the stream.
|
||||
unsigned int count; // The index one greater than the last valid character
|
||||
// in the input stream buffer.
|
||||
unsigned int mark; // The currently marked position in the stream.
|
||||
@@ -23,7 +23,8 @@ public:
|
||||
virtual ~ByteArrayInputStream();
|
||||
virtual int read();
|
||||
virtual int read(std::vector<uint8_t>& b);
|
||||
virtual int read(std::vector<uint8_t>& b, unsigned int offset, unsigned int length);
|
||||
virtual int read(std::vector<uint8_t>& b, unsigned int offset,
|
||||
unsigned int length);
|
||||
virtual void close();
|
||||
virtual int64_t skip(int64_t n);
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
#include <cstdint>
|
||||
|
||||
class ByteArrayOutputStream : public OutputStream {
|
||||
// Note - when actually implementing, std::vector<uint8_t> will need to grow as data is
|
||||
// written
|
||||
// Note - when actually implementing, std::vector<uint8_t> will need to grow
|
||||
// as data is written
|
||||
public:
|
||||
std::vector<uint8_t> buf; // The buffer where data is stored.
|
||||
|
||||
@@ -22,7 +22,8 @@ public:
|
||||
virtual void flush() {}
|
||||
virtual void write(unsigned int b);
|
||||
virtual void write(const std::vector<uint8_t>& b);
|
||||
virtual void write(const std::vector<uint8_t>& b, unsigned int offset, unsigned int length);
|
||||
virtual void write(const std::vector<uint8_t>& b, unsigned int offset,
|
||||
unsigned int length);
|
||||
virtual void close();
|
||||
virtual std::vector<uint8_t> toByteArray();
|
||||
|
||||
|
||||
@@ -8,7 +8,8 @@ class DataInput {
|
||||
public:
|
||||
virtual int read() = 0;
|
||||
virtual int read(std::vector<uint8_t>& b) = 0;
|
||||
virtual int read(std::vector<uint8_t>& b, unsigned int offset, unsigned int length) = 0;
|
||||
virtual int read(std::vector<uint8_t>& b, unsigned int offset,
|
||||
unsigned int length) = 0;
|
||||
virtual bool readBoolean() = 0;
|
||||
virtual uint8_t readByte() = 0;
|
||||
virtual unsigned char readUnsignedByte() = 0;
|
||||
|
||||
@@ -16,7 +16,8 @@ public:
|
||||
DataInputStream(InputStream* in);
|
||||
virtual int read();
|
||||
virtual int read(std::vector<uint8_t>& b);
|
||||
virtual int read(std::vector<uint8_t>& b, unsigned int offset, unsigned int length);
|
||||
virtual int read(std::vector<uint8_t>& b, unsigned int offset,
|
||||
unsigned int length);
|
||||
virtual void close();
|
||||
virtual bool readBoolean();
|
||||
virtual uint8_t readByte();
|
||||
|
||||
@@ -23,7 +23,8 @@ public:
|
||||
|
||||
virtual void write(unsigned int b);
|
||||
virtual void write(const std::vector<uint8_t>& b);
|
||||
virtual void write(const std::vector<uint8_t>& b, unsigned int offset, unsigned int length);
|
||||
virtual void write(const std::vector<uint8_t>& b, unsigned int offset,
|
||||
unsigned int length);
|
||||
virtual void close();
|
||||
virtual void writeByte(uint8_t a);
|
||||
virtual void writeDouble(double a);
|
||||
|
||||
@@ -14,7 +14,8 @@ public:
|
||||
virtual ~FileInputStream();
|
||||
virtual int read();
|
||||
virtual int read(std::vector<uint8_t>& b);
|
||||
virtual int read(std::vector<uint8_t>& b, unsigned int offset, unsigned int length);
|
||||
virtual int read(std::vector<uint8_t>& b, unsigned int offset,
|
||||
unsigned int length);
|
||||
virtual void close();
|
||||
virtual int64_t skip(int64_t n);
|
||||
|
||||
|
||||
@@ -13,7 +13,8 @@ public:
|
||||
virtual ~FileOutputStream();
|
||||
virtual void write(unsigned int b);
|
||||
virtual void write(const std::vector<uint8_t>& b);
|
||||
virtual void write(const std::vector<uint8_t>& b, unsigned int offset, unsigned int length);
|
||||
virtual void write(const std::vector<uint8_t>& b, unsigned int offset,
|
||||
unsigned int length);
|
||||
virtual void close();
|
||||
virtual void flush();
|
||||
|
||||
|
||||
@@ -14,7 +14,8 @@ public:
|
||||
GZIPInputStream(InputStream* out) : stream(out) {};
|
||||
virtual int read() { return stream->read(); };
|
||||
virtual int read(std::vector<uint8_t>& b) { return stream->read(b); };
|
||||
virtual int read(std::vector<uint8_t>& b, unsigned int offset, unsigned int length) {
|
||||
virtual int read(std::vector<uint8_t>& b, unsigned int offset,
|
||||
unsigned int length) {
|
||||
return stream->read(b, offset, length);
|
||||
};
|
||||
virtual void close() { return stream->close(); };
|
||||
|
||||
@@ -12,7 +12,8 @@ public:
|
||||
GZIPOutputStream(OutputStream* out) : stream(out) {};
|
||||
virtual void write(unsigned int b) { stream->write(b); };
|
||||
virtual void write(const std::vector<uint8_t>& b) { stream->write(b); };
|
||||
virtual void write(const std::vector<uint8_t>& b, unsigned int offset, unsigned int length) {
|
||||
virtual void write(const std::vector<uint8_t>& b, unsigned int offset,
|
||||
unsigned int length) {
|
||||
stream->write(b, offset, length);
|
||||
};
|
||||
virtual void close() { stream->close(); };
|
||||
|
||||
@@ -12,7 +12,8 @@ public:
|
||||
|
||||
virtual int read() = 0;
|
||||
virtual int read(std::vector<uint8_t>& b) = 0;
|
||||
virtual int read(std::vector<uint8_t>& b, unsigned int offset, unsigned int length) = 0;
|
||||
virtual int read(std::vector<uint8_t>& b, unsigned int offset,
|
||||
unsigned int length) = 0;
|
||||
virtual void close() = 0;
|
||||
virtual int64_t skip(int64_t n) = 0;
|
||||
|
||||
|
||||
@@ -10,15 +10,15 @@ class Biome;
|
||||
class Node;
|
||||
|
||||
// 4J Jev, just thought it would be easier this way.
|
||||
#define ArrayCopyFunctionDeclaration(x) \
|
||||
static void arraycopy(const std::vector<x>& src, unsigned int srcPos, \
|
||||
std::vector<x>* dst, unsigned int dstPos, \
|
||||
#define ArrayCopyFunctionDeclaration(x) \
|
||||
static void arraycopy(const std::vector<x>& src, unsigned int srcPos, \
|
||||
std::vector<x>* dst, unsigned int dstPos, \
|
||||
unsigned int length);
|
||||
#define ArrayCopyFunctionDefinition(x) \
|
||||
void System::arraycopy(const std::vector<x>& src, unsigned int srcPos, \
|
||||
std::vector<x>* dst, unsigned int dstPos, \
|
||||
unsigned int length) { \
|
||||
arraycopy<x>(src, srcPos, dst, dstPos, length); \
|
||||
#define ArrayCopyFunctionDefinition(x) \
|
||||
void System::arraycopy(const std::vector<x>& src, unsigned int srcPos, \
|
||||
std::vector<x>* dst, unsigned int dstPos, \
|
||||
unsigned int length) { \
|
||||
arraycopy<x>(src, srcPos, dst, dstPos, length); \
|
||||
}
|
||||
|
||||
class System {
|
||||
|
||||
@@ -393,7 +393,9 @@ ByteBuffer* ByteBuffer::put(std::vector<uint8_t>& inputArray) {
|
||||
return this;
|
||||
}
|
||||
|
||||
std::vector<uint8_t> ByteBuffer::array() { return std::vector<uint8_t>(buffer, buffer + m_capacity); }
|
||||
std::vector<uint8_t> ByteBuffer::array() {
|
||||
return std::vector<uint8_t>(buffer, buffer + m_capacity);
|
||||
}
|
||||
|
||||
// Creates a view of this byte buffer as an int buffer.
|
||||
// The content of the new buffer will start at this buffer's current position.
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
#include "java/FileFilter.h"
|
||||
#include "java/File.h"
|
||||
#include "console_helpers/PathHelper.h" // 4jcraft TODO
|
||||
#include "console_helpers/StringHelpers.h" // 4jcraft TODO
|
||||
#include "console_helpers/PathHelper.h" // 4jcraft TODO
|
||||
#include "console_helpers/StringHelpers.h" // 4jcraft TODO
|
||||
|
||||
const wchar_t File::pathSeparator = L'/';
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@ BufferedOutputStream::~BufferedOutputStream() {
|
||||
void BufferedOutputStream::flush() {
|
||||
if (stream == nullptr) {
|
||||
fprintf(stderr,
|
||||
"BufferedOutputStream::flush() called but underlying stream is "
|
||||
"nullptr\n");
|
||||
"BufferedOutputStream::flush() called but underlying stream is "
|
||||
"nullptr\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -43,8 +43,8 @@ void BufferedOutputStream::close() {
|
||||
flush();
|
||||
if (stream == nullptr) {
|
||||
fprintf(stderr,
|
||||
"BufferedOutputStream::close() called but underlying stream is "
|
||||
"nullptr\n");
|
||||
"BufferedOutputStream::close() called but underlying stream is "
|
||||
"nullptr\n");
|
||||
return;
|
||||
}
|
||||
stream->close();
|
||||
@@ -64,8 +64,8 @@ void BufferedOutputStream::close() {
|
||||
// b - the data.
|
||||
// off - the start offset in the data.
|
||||
// len - the number of bytes to write.
|
||||
void BufferedOutputStream::write(const std::vector<uint8_t>& b, unsigned int offset,
|
||||
unsigned int length) {
|
||||
void BufferedOutputStream::write(const std::vector<uint8_t>& b,
|
||||
unsigned int offset, unsigned int length) {
|
||||
// Over the length of what we can store in our buffer - just flush the
|
||||
// buffer and output directly
|
||||
if (length >= buf.size()) {
|
||||
@@ -84,7 +84,9 @@ void BufferedOutputStream::write(const std::vector<uint8_t>& b, unsigned int off
|
||||
//
|
||||
// Note that this method does not call the one-argument write method of its
|
||||
// underlying stream with the single argument b.
|
||||
void BufferedOutputStream::write(const std::vector<uint8_t>& b) { write(b, 0, b.size()); }
|
||||
void BufferedOutputStream::write(const std::vector<uint8_t>& b) {
|
||||
write(b, 0, b.size());
|
||||
}
|
||||
|
||||
// Writes the specified byte to this buffered output stream.
|
||||
// Overrides:
|
||||
|
||||
@@ -12,9 +12,12 @@
|
||||
|
||||
#include "java/InputOutputStream/ByteArrayInputStream.h"
|
||||
|
||||
ByteArrayInputStream::ByteArrayInputStream(std::vector<uint8_t>& buf, unsigned int offset,
|
||||
ByteArrayInputStream::ByteArrayInputStream(std::vector<uint8_t>& buf,
|
||||
unsigned int offset,
|
||||
unsigned int length)
|
||||
: pos(offset), count(std::min(offset + length, (unsigned int)buf.size())), mark(offset) {
|
||||
: pos(offset),
|
||||
count(std::min(offset + length, (unsigned int)buf.size())),
|
||||
mark(offset) {
|
||||
this->buf = buf;
|
||||
}
|
||||
|
||||
@@ -59,7 +62,9 @@ int ByteArrayInputStream::read() {
|
||||
// Returns:
|
||||
// the total number of bytes read into the buffer, or -1 is there is no more
|
||||
// data because the end of the stream has been reached.
|
||||
int ByteArrayInputStream::read(std::vector<uint8_t>& b) { return read(b, 0, b.size()); }
|
||||
int ByteArrayInputStream::read(std::vector<uint8_t>& b) {
|
||||
return read(b, 0, b.size());
|
||||
}
|
||||
|
||||
// Reads up to len bytes of data into an array of bytes from this input stream.
|
||||
// If pos equals count, then -1 is returned to indicate end of file. Otherwise,
|
||||
@@ -110,5 +115,4 @@ int64_t ByteArrayInputStream::skip(int64_t n) {
|
||||
return k;
|
||||
}
|
||||
|
||||
ByteArrayInputStream::~ByteArrayInputStream() {
|
||||
}
|
||||
ByteArrayInputStream::~ByteArrayInputStream() {}
|
||||
|
||||
@@ -18,8 +18,7 @@ ByteArrayOutputStream::ByteArrayOutputStream(unsigned int size) {
|
||||
buf = std::vector<uint8_t>(size);
|
||||
}
|
||||
|
||||
ByteArrayOutputStream::~ByteArrayOutputStream() {
|
||||
}
|
||||
ByteArrayOutputStream::~ByteArrayOutputStream() {}
|
||||
|
||||
// Writes the specified byte to this byte array output stream.
|
||||
// Parameters:
|
||||
@@ -35,18 +34,21 @@ void ByteArrayOutputStream::write(unsigned int b) {
|
||||
// Writes b.size() bytes from the specified byte array to this output stream.
|
||||
// The general contract for write(b) is that it should have exactly the same
|
||||
// effect as the call write(b, 0, b.size()).
|
||||
void ByteArrayOutputStream::write(const std::vector<uint8_t>& b) { write(b, 0, b.size()); }
|
||||
void ByteArrayOutputStream::write(const std::vector<uint8_t>& b) {
|
||||
write(b, 0, b.size());
|
||||
}
|
||||
|
||||
// Writes len bytes from the specified byte array starting at offset off to this
|
||||
// byte array output stream. Parameters: b - the data. off - the start offset in
|
||||
// the data. len - the number of bytes to write.
|
||||
void ByteArrayOutputStream::write(const std::vector<uint8_t>& b, unsigned int offset,
|
||||
unsigned int length) {
|
||||
void ByteArrayOutputStream::write(const std::vector<uint8_t>& b,
|
||||
unsigned int offset, unsigned int length) {
|
||||
assert(b.size() >= offset + length);
|
||||
|
||||
// If we will fill the buffer we need to make it bigger
|
||||
if (count + length >= buf.size())
|
||||
buf.resize(std::max(count + length + 1, (unsigned int)(buf.size() * 2)));
|
||||
buf.resize(
|
||||
std::max(count + length + 1, (unsigned int)(buf.size() * 2)));
|
||||
|
||||
std::memcpy(&buf[count], &b[offset], length);
|
||||
// std::copy( b->data+offset, b->data+offset+length, buf->data + count ); //
|
||||
|
||||
@@ -21,8 +21,8 @@ DataInputStream::DataInputStream(InputStream* in) : stream(in) {}
|
||||
int DataInputStream::read() {
|
||||
if (stream == nullptr) {
|
||||
fprintf(stderr,
|
||||
"DataInputStream::read() called but underlying stream is "
|
||||
"nullptr\n");
|
||||
"DataInputStream::read() called but underlying stream is "
|
||||
"nullptr\n");
|
||||
return -1;
|
||||
}
|
||||
return stream->read();
|
||||
@@ -56,8 +56,9 @@ int DataInputStream::read() {
|
||||
int DataInputStream::read(std::vector<uint8_t>& b) {
|
||||
if (stream == nullptr) {
|
||||
fprintf(stderr,
|
||||
"DataInputStream::read(std::vector<uint8_t>) called but underlying stream is "
|
||||
"nullptr\n");
|
||||
"DataInputStream::read(std::vector<uint8_t>) called but "
|
||||
"underlying stream is "
|
||||
"nullptr\n");
|
||||
return -1;
|
||||
}
|
||||
return read(b, 0, b.size());
|
||||
@@ -96,8 +97,9 @@ int DataInputStream::read(std::vector<uint8_t>& b, unsigned int offset,
|
||||
unsigned int length) {
|
||||
if (stream == nullptr) {
|
||||
fprintf(stderr,
|
||||
"DataInputStream::read(std::vector<uint8_t>,offset,length) called but "
|
||||
"underlying stream is nullptr\n");
|
||||
"DataInputStream::read(std::vector<uint8_t>,offset,length) "
|
||||
"called but "
|
||||
"underlying stream is nullptr\n");
|
||||
return -1;
|
||||
}
|
||||
return stream->read(b, offset, length);
|
||||
@@ -108,8 +110,8 @@ int DataInputStream::read(std::vector<uint8_t>& b, unsigned int offset,
|
||||
void DataInputStream::close() {
|
||||
if (stream == nullptr) {
|
||||
fprintf(stderr,
|
||||
"DataInputStream::close() called but underlying stream is "
|
||||
"nullptr\n");
|
||||
"DataInputStream::close() called but underlying stream is "
|
||||
"nullptr\n");
|
||||
return;
|
||||
}
|
||||
stream->close();
|
||||
@@ -121,8 +123,8 @@ void DataInputStream::close() {
|
||||
bool DataInputStream::readBoolean() {
|
||||
if (stream == nullptr) {
|
||||
fprintf(stderr,
|
||||
"DataInputStream::readBoolean() but underlying stream is "
|
||||
"nullptr\n");
|
||||
"DataInputStream::readBoolean() but underlying stream is "
|
||||
"nullptr\n");
|
||||
return false;
|
||||
}
|
||||
return stream->read() != 0;
|
||||
@@ -134,7 +136,8 @@ bool DataInputStream::readBoolean() {
|
||||
// the 8-bit value read.
|
||||
uint8_t DataInputStream::readByte() {
|
||||
if (stream == nullptr) {
|
||||
fprintf(stderr,
|
||||
fprintf(
|
||||
stderr,
|
||||
"DataInputStream::readByte() but underlying stream is nullptr\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -144,8 +147,8 @@ uint8_t DataInputStream::readByte() {
|
||||
unsigned char DataInputStream::readUnsignedByte() {
|
||||
if (stream == nullptr) {
|
||||
fprintf(stderr,
|
||||
"DataInputStream::readUnsignedByte() but underlying stream is "
|
||||
"nullptr\n");
|
||||
"DataInputStream::readUnsignedByte() but underlying stream is "
|
||||
"nullptr\n");
|
||||
return 0;
|
||||
}
|
||||
return (unsigned char)stream->read();
|
||||
@@ -159,7 +162,8 @@ unsigned char DataInputStream::readUnsignedByte() {
|
||||
// interface DataOutput. Returns: the char value read.
|
||||
wchar_t DataInputStream::readChar() {
|
||||
if (stream == nullptr) {
|
||||
fprintf(stderr,
|
||||
fprintf(
|
||||
stderr,
|
||||
"DataInputStream::readChar() but underlying stream is nullptr\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -190,8 +194,9 @@ bool DataInputStream::readFully(std::vector<uint8_t>& b) {
|
||||
// InputStreams
|
||||
if (stream == nullptr) {
|
||||
fprintf(stderr,
|
||||
"DataInputStream::readFully(std::vector<uint8_t>) but underlying stream is "
|
||||
"nullptr\n");
|
||||
"DataInputStream::readFully(std::vector<uint8_t>) but "
|
||||
"underlying stream is "
|
||||
"nullptr\n");
|
||||
return false;
|
||||
}
|
||||
for (unsigned int i = 0; i < b.size(); i++) {
|
||||
@@ -212,8 +217,9 @@ bool DataInputStream::readFully(std::vector<char>& b) {
|
||||
// InputStreams
|
||||
if (stream == nullptr) {
|
||||
fprintf(stderr,
|
||||
"DataInputStream::readFully(std::vector<char>) but underlying stream is "
|
||||
"nullptr\n");
|
||||
"DataInputStream::readFully(std::vector<char>) but underlying "
|
||||
"stream is "
|
||||
"nullptr\n");
|
||||
return false;
|
||||
}
|
||||
for (unsigned int i = 0; i < b.size(); i++) {
|
||||
@@ -260,7 +266,8 @@ float DataInputStream::readFloat() {
|
||||
// interface DataOutput. Returns: the int value read.
|
||||
int DataInputStream::readInt() {
|
||||
if (stream == nullptr) {
|
||||
fprintf(stderr,
|
||||
fprintf(
|
||||
stderr,
|
||||
"DataInputStream::readInt() but underlying stream is nullptr\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -292,7 +299,8 @@ int DataInputStream::readInt() {
|
||||
// the long value read.
|
||||
int64_t DataInputStream::readLong() {
|
||||
if (stream == nullptr) {
|
||||
fprintf(stderr,
|
||||
fprintf(
|
||||
stderr,
|
||||
"DataInputStream::readLong() but underlying stream is nullptr\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -321,7 +329,8 @@ int64_t DataInputStream::readLong() {
|
||||
// method of interface DataOutput. Returns: the 16-bit value read.
|
||||
short DataInputStream::readShort() {
|
||||
if (stream == nullptr) {
|
||||
fprintf(stderr,
|
||||
fprintf(
|
||||
stderr,
|
||||
"DataInputStream::readShort() but underlying stream is nullptr\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -333,8 +342,8 @@ short DataInputStream::readShort() {
|
||||
unsigned short DataInputStream::readUnsignedShort() {
|
||||
if (stream == nullptr) {
|
||||
fprintf(stderr,
|
||||
"DataInputStream::readUnsignedShort() but underlying stream is "
|
||||
"nullptr\n");
|
||||
"DataInputStream::readUnsignedShort() but underlying stream is "
|
||||
"nullptr\n");
|
||||
return 0;
|
||||
}
|
||||
int a = stream->read();
|
||||
@@ -391,7 +400,8 @@ unsigned short DataInputStream::readUnsignedShort() {
|
||||
std::wstring DataInputStream::readUTF() {
|
||||
std::wstring outputString;
|
||||
if (stream == nullptr) {
|
||||
fprintf(stderr,
|
||||
fprintf(
|
||||
stderr,
|
||||
"DataInputStream::readUTF() but underlying stream is nullptr\n");
|
||||
return outputString;
|
||||
}
|
||||
@@ -519,8 +529,8 @@ int DataInputStream::readUTFChar() {
|
||||
int returnValue = -1;
|
||||
if (stream == nullptr) {
|
||||
fprintf(stderr,
|
||||
"DataInputStream::readUTFChar() but underlying stream is "
|
||||
"nullptr\n");
|
||||
"DataInputStream::readUTFChar() but underlying stream is "
|
||||
"nullptr\n");
|
||||
return returnValue;
|
||||
}
|
||||
int firstByte = stream->read();
|
||||
|
||||
@@ -25,8 +25,8 @@ void DataOutputStream::deleteChildStream() { delete stream; }
|
||||
void DataOutputStream::write(unsigned int b) {
|
||||
if (stream == nullptr) {
|
||||
fprintf(stderr,
|
||||
"DataOutputStream::write(unsigned int) called but underlying "
|
||||
"stream is nullptr\n");
|
||||
"DataOutputStream::write(unsigned int) called but underlying "
|
||||
"stream is nullptr\n");
|
||||
return;
|
||||
}
|
||||
stream->write(b);
|
||||
@@ -37,8 +37,8 @@ void DataOutputStream::write(unsigned int b) {
|
||||
void DataOutputStream::flush() {
|
||||
if (stream == nullptr) {
|
||||
fprintf(stderr,
|
||||
"DataOutputStream::flush() called but underlying stream is "
|
||||
"nullptr\n");
|
||||
"DataOutputStream::flush() called but underlying stream is "
|
||||
"nullptr\n");
|
||||
return;
|
||||
}
|
||||
stream->flush();
|
||||
@@ -47,7 +47,9 @@ void DataOutputStream::flush() {
|
||||
// Writes b.size() bytes from the specified byte array to this output stream.
|
||||
// The general contract for write(b) is that it should have exactly the same
|
||||
// effect as the call write(b, 0, b.size()). Parameters: b - the data.
|
||||
void DataOutputStream::write(const std::vector<uint8_t>& b) { write(b, 0, b.size()); }
|
||||
void DataOutputStream::write(const std::vector<uint8_t>& b) {
|
||||
write(b, 0, b.size());
|
||||
}
|
||||
|
||||
// Writes len bytes from the specified byte array starting at offset off to the
|
||||
// underlying output stream. If no exception is thrown, the counter written is
|
||||
@@ -57,8 +59,9 @@ void DataOutputStream::write(const std::vector<uint8_t>& b, unsigned int offset,
|
||||
unsigned int length) {
|
||||
if (stream == nullptr) {
|
||||
fprintf(stderr,
|
||||
"DataOutputStream::write(std::vector<uint8_t>,...) called but underlying "
|
||||
"stream is nullptr\n");
|
||||
"DataOutputStream::write(std::vector<uint8_t>,...) called but "
|
||||
"underlying "
|
||||
"stream is nullptr\n");
|
||||
return;
|
||||
}
|
||||
stream->write(b, offset, length);
|
||||
@@ -72,8 +75,8 @@ void DataOutputStream::write(const std::vector<uint8_t>& b, unsigned int offset,
|
||||
void DataOutputStream::close() {
|
||||
if (stream == nullptr) {
|
||||
fprintf(stderr,
|
||||
"DataOutputStream::close() called but underlying stream is "
|
||||
"nullptr\n");
|
||||
"DataOutputStream::close() called but underlying stream is "
|
||||
"nullptr\n");
|
||||
return;
|
||||
}
|
||||
stream->close();
|
||||
@@ -154,7 +157,8 @@ void DataOutputStream::writeShort(short a) {
|
||||
|
||||
void DataOutputStream::writeUnsignedShort(unsigned short a) {
|
||||
if (stream == nullptr) {
|
||||
fprintf(stderr,
|
||||
fprintf(
|
||||
stderr,
|
||||
"DataOutputStream::writeUnsignedShort() but underlying stream is "
|
||||
"nullptr\n");
|
||||
return;
|
||||
@@ -258,4 +262,6 @@ void DataOutputStream::writeUTF(const std::wstring& str) {
|
||||
}
|
||||
|
||||
// 4J Added
|
||||
void DataOutputStream::writePlayerUID(unsigned long long player) { writeLong(player); }
|
||||
void DataOutputStream::writePlayerUID(unsigned long long player) {
|
||||
writeLong(player);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "java/File.h"
|
||||
#include "java/InputOutputStream/FileOutputStream.h"
|
||||
|
||||
#include "console_helpers/StringHelpers.h" // 4jcraft TODO
|
||||
#include "console_helpers/StringHelpers.h" // 4jcraft TODO
|
||||
|
||||
// Creates a file output stream to write to the file represented by the
|
||||
// specified File object. A new FileDescriptor object is created to represent
|
||||
|
||||
Reference in New Issue
Block a user