chore: format Minecraft.World

This commit is contained in:
Tropical
2026-03-13 17:06:56 -05:00
parent bd6284025d
commit 33d0737d1d
1511 changed files with 108661 additions and 115521 deletions

View File

@@ -2,103 +2,97 @@
#include "BufferedOutputStream.h"
//Creates a new buffered output stream to write data to the specified underlying output stream with the specified buffer size.
//Parameters:
//out - the underlying output stream.
//size - the buffer size.
BufferedOutputStream::BufferedOutputStream(OutputStream *out, int size)
{
stream = out;
buf = byteArray( size );
count = 0;
// Creates a new buffered output stream to write data to the specified
// underlying output stream with the specified buffer size. Parameters: out -
// the underlying output stream. size - the buffer size.
BufferedOutputStream::BufferedOutputStream(OutputStream* out, int size) {
stream = out;
buf = byteArray(size);
count = 0;
}
BufferedOutputStream::~BufferedOutputStream()
{
//4jcraft, changed to [], deallocates internal buffer
//TODO: ArrayWithLength.h doesnt have a destructor.
//this wouldnt need to be done manually.
//but for some reason the destructor is commented out in the source code?
delete[] buf.data;
BufferedOutputStream::~BufferedOutputStream() {
// 4jcraft, changed to [], deallocates internal buffer
// TODO: ArrayWithLength.h doesnt have a destructor.
// this wouldnt need to be done manually.
// but for some reason the destructor is commented out in the source code?
delete[] buf.data;
}
//Flushes this buffered output stream. This forces any buffered output bytes to be written out to the underlying output stream.
void BufferedOutputStream::flush()
{
if (stream == NULL)
{
app.DebugPrintf("BufferedOutputStream::flush() called but underlying stream is NULL\n");
return;
}
// Flushes this buffered output stream. This forces any buffered output bytes to
// be written out to the underlying output stream.
void BufferedOutputStream::flush() {
if (stream == NULL) {
app.DebugPrintf(
"BufferedOutputStream::flush() called but underlying stream is "
"NULL\n");
return;
}
if (count > 0)
{
stream->write( buf, 0, count );
count = 0;
}
if (count > 0) {
stream->write(buf, 0, count);
count = 0;
}
}
//Closes this output stream and releases any system resources associated with the stream.
//The close method of FilterOutputStream calls its flush method, and then calls the close method of its underlying output stream.
void BufferedOutputStream::close()
{
flush();
if (stream == NULL)
{
app.DebugPrintf("BufferedOutputStream::close() called but underlying stream is NULL\n");
return;
}
stream->close();
// Closes this output stream and releases any system resources associated with
// the stream. The close method of FilterOutputStream calls its flush method,
// and then calls the close method of its underlying output stream.
void BufferedOutputStream::close() {
flush();
if (stream == NULL) {
app.DebugPrintf(
"BufferedOutputStream::close() called but underlying stream is "
"NULL\n");
return;
}
stream->close();
}
//Writes len bytes from the specified byte array starting at offset off to this buffered output stream.
//Ordinarily this method stores bytes from the given array into this stream's buffer, flushing the buffer to the
//underlying output stream as needed. If the requested length is at least as large as this stream's buffer, however,
//then this method will flush the buffer and write the bytes directly to the underlying output stream.
//Thus redundant BufferedOutputStreams will not copy data unnecessarily.
// Writes len bytes from the specified byte array starting at offset off to this
// buffered output stream. Ordinarily this method stores bytes from the given
// array into this stream's buffer, flushing the buffer to the underlying output
// stream as needed. If the requested length is at least as large as this
// stream's buffer, however, then this method will flush the buffer and write
// the bytes directly to the underlying output stream. Thus redundant
// BufferedOutputStreams will not copy data unnecessarily.
//
//Overrides:
//write in class FilterOutputStream
//Parameters:
//b - the data.
//off - the start offset in the data.
//len - the number of bytes to write.
void BufferedOutputStream::write(byteArray 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.length )
{
flush();
stream->write(b, offset, length);
}
else
{
for(unsigned int i = 0; i < length; i++ )
{
write( static_cast<unsigned int>(b[offset+i]));
}
}
// Overrides:
// write in class FilterOutputStream
// Parameters:
// b - the data.
// off - the start offset in the data.
// len - the number of bytes to write.
void BufferedOutputStream::write(byteArray 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.length) {
flush();
stream->write(b, offset, length);
} else {
for (unsigned int i = 0; i < length; i++) {
write(static_cast<unsigned int>(b[offset + i]));
}
}
}
//Writes b.length bytes to this output stream.
//The write method of FilterOutputStream calls its write method of three arguments with the arguments b, 0, and b.length.
// Writes b.length bytes to this output stream.
// The write method of FilterOutputStream calls its write method of three
// arguments with the arguments b, 0, and b.length.
//
//Note that this method does not call the one-argument write method of its underlying stream with the single argument b.
void BufferedOutputStream::write(byteArray b)
{
write( b, 0, b.length );
}
// Note that this method does not call the one-argument write method of its
// underlying stream with the single argument b.
void BufferedOutputStream::write(byteArray b) { write(b, 0, b.length); }
//Writes the specified byte to this buffered output stream.
//Overrides:
//write in class FilterOutputStream
//Parameters:
//b - the byte to be written.
void BufferedOutputStream::write(unsigned int b)
{
buf[count++] = (uint8_t) b;
if( count == buf.length )
{
flush();
}
// Writes the specified byte to this buffered output stream.
// Overrides:
// write in class FilterOutputStream
// Parameters:
// b - the byte to be written.
void BufferedOutputStream::write(unsigned int b) {
buf[count++] = (uint8_t)b;
if (count == buf.length) {
flush();
}
}