Something went wrong. Try again.
the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
Something went wrong. Try again.
1.3 kB · 48 lines
C++
at master
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748#include "stdafx.h"#include "ByteBuffer.h"#include "ZoneIo.h"
ZoneIo::ZoneIo(HANDLE 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 buff->order(ZonedChunkStorage::BYTEORDER); buff->position(bb.length); buff->flip(); write(buff, size); delete buff;}
void ZoneIo::write(ByteBuffer *bb, int size){ DWORD numberOfBytesWritten; SetFilePointer(channel,(int)pos,NULL,NULL); WriteFile(channel,bb->getBuffer(), bb->getSize(),&numberOfBytesWritten,NULL); pos += size;}
ByteBuffer *ZoneIo::read(int size){ DWORD numberOfBytesRead; byteArray bb = byteArray(size); SetFilePointer(channel,(int)pos,NULL,NULL); 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(); ReadFile(channel, buff->getBuffer(), buff->getSize(), &numberOfBytesRead, NULL); pos += size; return buff;}
void ZoneIo::flush(){ // 4J - was channel.force(false);}