Trying to get it to work
-Uses many streams to keep track of things -Fixed some bad things, still are a ton.
This commit is contained in:
parent
8167c40f64
commit
6891d3a095
@ -238,30 +238,41 @@ public class TestWorldDiskIO {
|
|||||||
if (sectorLength == 0)
|
if (sectorLength == 0)
|
||||||
{
|
{
|
||||||
int outputLen = (int) output.length();
|
int outputLen = (int) output.length();
|
||||||
offset = (int) (outputLen-fullOffset)/sectorSize;
|
offset = (int) (outputLen-fullOffset)/sectorSize+1;
|
||||||
output.seek(shortOffset);
|
output.seek(shortOffset);
|
||||||
output.writeInt(offset<<8);
|
output.writeInt(offset<<8);
|
||||||
|
output.seek(outputLen);
|
||||||
|
while (output.length()<fullOffset+sectorSize*offset)
|
||||||
|
{
|
||||||
|
output.write(0);
|
||||||
|
}
|
||||||
//output.write(200);
|
//output.write(200);
|
||||||
}
|
}
|
||||||
output.seek(fullOffset+sectorSize*offset);
|
output.seek((long) fullOffset+sectorSize*offset);
|
||||||
|
|
||||||
//int bytestoWrite = output.readInt();
|
//int bytestoWrite = output.readInt();
|
||||||
//output.mark(sectorSize*sectorLength);
|
//output.mark(sectorSize*sectorLength);
|
||||||
|
|
||||||
DataOutputStream trueOutput = new DataOutputStream(Channels.newOutputStream(output.getChannel()));
|
CountingOutputStream counter = new CountingOutputStream(new BufferedOutputStream(Channels.newOutputStream(output.getChannel())));
|
||||||
//CountingOutputStream countOutput = new CountingOutputStream(trueOutput);
|
DataOutputStream trueOutput = new DataOutputStream(
|
||||||
|
new DeflaterOutputStream(
|
||||||
|
counter
|
||||||
|
)
|
||||||
|
);
|
||||||
|
// CountingOutputStream countOutput = new
|
||||||
|
// CountingOutputStream(trueOutput);
|
||||||
|
|
||||||
//trueOutput.
|
//LOG.info("Before: {}",output.);
|
||||||
ChunkIO.save(chunk, trueOutput, IOContext.SAVE);
|
ChunkIO.save(chunk, trueOutput, IOContext.SAVE);
|
||||||
writeGenerationHint(chunk, trueOutput, server);
|
writeGenerationHint(chunk, trueOutput, server);
|
||||||
|
|
||||||
while (trueOutput.size()%sectorSize != 0) {
|
/*while (counter.getCount()%sectorSize != 0) {
|
||||||
trueOutput.write(0);
|
counter.write(0);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
output.seek(shortOffset+offsetBytes);
|
output.seek(shortOffset+offsetBytes);
|
||||||
LOG.info(trueOutput.size());
|
LOG.info("Wrote {} bytes to {},{},{}",counter.getCount(),chunk.getPosition().x,chunk.getPosition().y,chunk.getPosition().z);
|
||||||
output.write((int) trueOutput.size()/sectorSize);
|
output.write((int) counter.getCount()/sectorSize);
|
||||||
|
|
||||||
trueOutput.close();
|
trueOutput.close();
|
||||||
}
|
}
|
||||||
@ -490,28 +501,28 @@ public class TestWorldDiskIO {
|
|||||||
private static ChunkData loadRegion(Path path, Vec3i chunkPos, WorldData world, Server server) throws IOException, DecodingException
|
private static ChunkData loadRegion(Path path, Vec3i chunkPos, WorldData world, Server server) throws IOException, DecodingException
|
||||||
{
|
{
|
||||||
try (
|
try (
|
||||||
DataInputStream input = new DataInputStream(
|
BufferedInputStream input = new BufferedInputStream(Files.newInputStream(path))
|
||||||
new InflaterInputStream(new BufferedInputStream(Files.newInputStream(path)))
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
LOG.info(path.toString());
|
LOG.info(path.toString());
|
||||||
Vec3i pos = getRegionLoc(chunkPos);
|
Vec3i pos = getRegionLoc(chunkPos);
|
||||||
int shortOffset = (offsetBytes+1)*(pos.z+regionSize.z*(pos.y + regionSize.y*pos.x));
|
int shortOffset = (offsetBytes+1)*(pos.z+regionSize.z*(pos.y + regionSize.y*pos.x));
|
||||||
int fullOffset = (offsetBytes+1)*(chunksPerRegion);
|
int fullOffset = (offsetBytes+1)*(chunksPerRegion);
|
||||||
input.skipNBytes(shortOffset);
|
input.skipNBytes(shortOffset);
|
||||||
int offset = input.readInt();
|
int offset = 0;
|
||||||
/*for (int i=0;i<offsetBytes;i++)
|
for (int i=0;i<offsetBytes;i++)
|
||||||
{
|
{
|
||||||
offset*=256;
|
offset*=256;
|
||||||
offset += input.read();
|
offset += input.read();
|
||||||
}*/
|
}
|
||||||
int sectorLength = offset & 255;
|
int sectorLength = offset & 255;
|
||||||
offset = offset << 8;
|
offset = offset >> 8;
|
||||||
input.skipNBytes(fullOffset-shortOffset-offsetBytes-1);
|
input.skipNBytes(fullOffset-shortOffset-offsetBytes-1);
|
||||||
input.skipNBytes(sectorSize*offset);
|
input.skipNBytes(sectorSize*offset);
|
||||||
input.mark(sectorSize*sectorLength);
|
input.mark(sectorSize*sectorLength);
|
||||||
ChunkData chunk = ChunkIO.load(world, chunkPos, input, IOContext.SAVE);
|
DataInputStream trueInput = new DataInputStream(
|
||||||
readGenerationHint(chunk, input, server);
|
new InflaterInputStream(input));
|
||||||
|
ChunkData chunk = ChunkIO.load(world, chunkPos, trueInput, IOContext.SAVE);
|
||||||
|
readGenerationHint(chunk, trueInput, server);
|
||||||
return chunk;
|
return chunk;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user