BREAKS OLD UNDO FILES + better compression

Reduce block position entropy by encoding coordinates relative to last
position
This commit is contained in:
Jesse Boyd 2016-12-21 06:22:03 +11:00
parent 0e26ce6e1e
commit dcc0c15c03
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
3 changed files with 36 additions and 22 deletions

View File

@ -24,12 +24,15 @@ import org.bukkit.event.entity.ItemSpawnEvent;
public class ChunkListener implements Listener {
int rateLimit = 0;
public ChunkListener() {
if (Settings.TICK_LIMITER.ENABLED) {
Bukkit.getPluginManager().registerEvents(ChunkListener.this, Fawe.<FaweBukkit>imp().getPlugin());
TaskManager.IMP.repeat(new Runnable() {
@Override
public void run() {
rateLimit--;
physicsFreeze = false;
itemFreeze = false;
counter.clear();
@ -99,7 +102,10 @@ public class ChunkListener implements Listener {
lastPhysY = y;
if (++count.x == Settings.TICK_LIMITER.PHYSICS) {
badChunks.add(MathMan.pairInt(cx, cz));
Fawe.debug("[Tick Limiter] Detected and cancelled physics lag source at " + block.getLocation());
if (rateLimit <= 0) {
rateLimit = 120;
Fawe.debug("[Tick Limiter] Detected and cancelled physics lag source at " + block.getLocation());
}
}
return;
}
@ -148,10 +154,13 @@ public class ChunkListener implements Listener {
count.x = Settings.TICK_LIMITER.PHYSICS;
cleanup(loc.getChunk());
badChunks.add(MathMan.pairInt(cx, cz));
Fawe.debug("[Tick Limiter] Detected and cancelled item lag source at " + loc);
if (rateLimit <= 0) {
rateLimit = 120;
Fawe.debug("[Tick Limiter] Detected and cancelled item lag source at " + loc);
}
}
event.setCancelled(true);
return;
}
}
}
}

View File

@ -124,13 +124,17 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
}
if (mode == 1 || mode == 4) { // small
posDel = new FaweStreamPositionDelegate() {
int lx,ly,lz;
@Override
public void write(OutputStream out, int x, int y, int z) throws IOException {
byte b1 = (byte) y;
byte b2 = (byte) (x);
byte b3 = (byte) (z);
int x16 = (x >> 8) & 0xF;
int z16 = (z >> 8) & 0xF;
int rx = -lx + (lx = x);
int ry = -ly + (ly = y);
int rz = -lz + (lz = z);
byte b1 = (byte) (ry);
byte b2 = (byte) (rx);
byte b3 = (byte) (rz);
int x16 = (rx >> 8) & 0xF;
int z16 = (rz >> 8) & 0xF;
byte b4 = MathMan.pair16(x16, z16);
out.write(b1);
out.write(b2);
@ -145,31 +149,33 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
if (in.read(buffer) == -1) {
throw new EOFException();
}
return (((buffer[1] & 0xFF) + ((MathMan.unpair16x(buffer[3])) << 8)) << 20) >> 20;
return lx = lx + ((((buffer[1] & 0xFF) + ((MathMan.unpair16x(buffer[3])) << 8)) << 20) >> 20);
}
@Override
public int readY(InputStream in) {
return buffer[0] & 0xFF;
return (ly = ly + buffer[0]) & 0xFF;
}
@Override
public int readZ(InputStream in) throws IOException {
return (((buffer[2] & 0xFF) + ((MathMan.unpair16y(buffer[3])) << 8)) << 20) >> 20;
return lz = lz + ((((buffer[2] & 0xFF) + ((MathMan.unpair16y(buffer[3])) << 8)) << 20) >> 20);
}
};
} else {
posDel = new FaweStreamPositionDelegate() {
byte[] buffer = new byte[5];
int lx,ly,lz;
@Override
public void write(OutputStream stream, int x, int y, int z) throws IOException {
stream.write((x) & 0xff);
stream.write(((x) >> 8) & 0xff);
stream.write((z) & 0xff);
stream.write(((z) >> 8) & 0xff);
stream.write((byte) y);
int rx = -lx + (lx = x);
int ry = -ly + (ly = y);
int rz = -lz + (lz = z);
stream.write((rx) & 0xff);
stream.write(((rx) >> 8) & 0xff);
stream.write((rz) & 0xff);
stream.write(((rz) >> 8) & 0xff);
stream.write((byte) ry);
}
@Override
@ -177,17 +183,17 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
if (is.read(buffer) == -1) {
throw new EOFException();
}
return (buffer[0] & 0xFF) + (buffer[1] << 8);
return lx = (lx + (buffer[0] & 0xFF) + (buffer[1] << 8));
}
@Override
public int readY(InputStream is) throws IOException {
return buffer[4] & 0xFF;
return (ly = (ly + (buffer[4]))) & 0xFF;
}
@Override
public int readZ(InputStream is) throws IOException {
return (buffer[2] & 0xFF) + (buffer[3] << 8);
return lz = (lz + (buffer[2] & 0xFF) + (buffer[3] << 8));
}
};
}

View File

@ -283,7 +283,6 @@ public class MainUtil {
return new FaweInputStream(is);
}
int amountAbs = Math.abs(amount);
LZ4Factory factory = LZ4Factory.fastestInstance();
if (amountAbs > 6) {
if (amount > 0) {
is = new BufferedInputStream(new GZIPInputStream(is, buffer));