mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-05-31 11:45:58 +00:00
chore: format Minecraft.World
This commit is contained in:
@@ -2,57 +2,52 @@
|
||||
#include "../../IO/Streams/ByteBuffer.h"
|
||||
#include "ZoneIO.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
bool SeekFile(std::FILE *file, __int64 offset)
|
||||
{
|
||||
namespace {
|
||||
bool SeekFile(std::FILE* file, __int64 offset) {
|
||||
#if defined(_WIN32)
|
||||
return _fseeki64(file, offset, SEEK_SET) == 0;
|
||||
return _fseeki64(file, offset, SEEK_SET) == 0;
|
||||
#else
|
||||
return fseeko(file, static_cast<off_t>(offset), SEEK_SET) == 0;
|
||||
return fseeko(file, static_cast<off_t>(offset), SEEK_SET) == 0;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
ZoneIo::ZoneIo(std::FILE* channel, __int64 pos) {
|
||||
this->channel = channel;
|
||||
this->pos = pos;
|
||||
}
|
||||
|
||||
ZoneIo::ZoneIo(std::FILE *channel, __int64 pos)
|
||||
{
|
||||
this->channel = channel;
|
||||
this->pos = pos;
|
||||
}
|
||||
|
||||
void ZoneIo::write(byteArray bb, int size)
|
||||
{
|
||||
ByteBuffer *buff = ByteBuffer::wrap(bb);
|
||||
// if (bb.length != size) throw new IllegalArgumentException("Expected " + size + " bytes, got " + bb.length); // 4J - TODO
|
||||
void ZoneIo::write(byteArray bb, int size) {
|
||||
ByteBuffer* buff = ByteBuffer::wrap(bb);
|
||||
// if (bb.length != size) throw new IllegalArgumentException("Expected "
|
||||
// + size + " bytes, got " + bb.length); // 4J - TODO
|
||||
buff->order(ZonedChunkStorage::BYTEORDER);
|
||||
buff->position(bb.length);
|
||||
buff->flip();
|
||||
write(buff, size);
|
||||
delete buff;
|
||||
delete buff;
|
||||
}
|
||||
|
||||
void ZoneIo::write(ByteBuffer *bb, int size)
|
||||
{
|
||||
SeekFile(channel, pos);
|
||||
std::fwrite(bb->getBuffer(), 1, bb->getSize(), channel);
|
||||
void ZoneIo::write(ByteBuffer* bb, int size) {
|
||||
SeekFile(channel, pos);
|
||||
std::fwrite(bb->getBuffer(), 1, bb->getSize(), channel);
|
||||
pos += size;
|
||||
}
|
||||
|
||||
ByteBuffer *ZoneIo::read(int size)
|
||||
{
|
||||
ByteBuffer* ZoneIo::read(int size) {
|
||||
byteArray bb = byteArray(size);
|
||||
SeekFile(channel, pos);
|
||||
ByteBuffer *buff = ByteBuffer::wrap(bb);
|
||||
// 4J - to investigate - why is this buffer flipped before anything goes in it?
|
||||
SeekFile(channel, pos);
|
||||
ByteBuffer* buff = ByteBuffer::wrap(bb);
|
||||
// 4J - to investigate - why is this buffer flipped before anything goes in
|
||||
// it?
|
||||
buff->order(ZonedChunkStorage::BYTEORDER);
|
||||
buff->position(size);
|
||||
buff->flip();
|
||||
std::fread(buff->getBuffer(), 1, buff->getSize(), channel);
|
||||
std::fread(buff->getBuffer(), 1, buff->getSize(), channel);
|
||||
pos += size;
|
||||
return buff;
|
||||
}
|
||||
|
||||
void ZoneIo::flush()
|
||||
{
|
||||
// 4J - was channel.force(false);
|
||||
void ZoneIo::flush() {
|
||||
// 4J - was channel.force(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user