format everything

This commit is contained in:
Tropical
2026-04-01 13:48:29 -05:00
parent 3e813592e4
commit dd93cfe91e
380 changed files with 2698 additions and 2595 deletions

View File

@@ -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.

View File

@@ -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'/';

View File

@@ -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:

View File

@@ -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() {}

View File

@@ -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 ); //

View File

@@ -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();

View File

@@ -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);
}

View File

@@ -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