use different method for history flushing/close
This commit is contained in:
parent
0af82fd31f
commit
1cd090ce01
@ -62,12 +62,12 @@ public class ChunkListener implements Listener {
|
||||
lastX = cx;
|
||||
lastZ = cz;
|
||||
long pair = MathMan.pairInt(cx, cz);
|
||||
lastCount = counter.get(pair);
|
||||
if (lastCount == null) {
|
||||
lastCount = new IntegerTrio();
|
||||
counter.put(pair, lastCount);
|
||||
IntegerTrio tmp = lastCount = counter.get(pair);
|
||||
if (tmp == null) {
|
||||
lastCount = tmp = new IntegerTrio();
|
||||
counter.put(pair, tmp);
|
||||
}
|
||||
return lastCount;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
public void cleanup(Chunk chunk) {
|
||||
|
@ -81,8 +81,8 @@ public class RollbackOptimizedHistory extends DiskStorageHistory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean flush() {
|
||||
if (super.flush()) {
|
||||
public boolean close() {
|
||||
if (super.close()) {
|
||||
// Save to DB
|
||||
RollbackDatabase db = DBHandler.IMP.getDatabase(getWorld());
|
||||
db.logEdit(this);
|
||||
|
@ -19,7 +19,7 @@ public class NullChangeSet extends FaweChangeSet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean flush() {
|
||||
public final boolean close() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -29,13 +29,13 @@ public class AbstractDelegateChangeSet extends FaweChangeSet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean flushAsync() {
|
||||
return super.flushAsync();
|
||||
public boolean closeAsync() {
|
||||
return super.closeAsync();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean flush() {
|
||||
return super.flush() && parent.flush();
|
||||
public boolean close() {
|
||||
return super.close() && parent.close();
|
||||
}
|
||||
|
||||
public final FaweChangeSet getParent() {
|
||||
|
@ -95,7 +95,7 @@ public class CPUOptimizedChangeSet extends FaweChangeSet {
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
if (changes.isEmpty()) {
|
||||
flush();
|
||||
close();
|
||||
return changes.isEmpty();
|
||||
} else {
|
||||
return false;
|
||||
|
@ -168,6 +168,25 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
||||
@Override
|
||||
public boolean flush() {
|
||||
super.flush();
|
||||
synchronized (this) {
|
||||
boolean flushed = osBD != null || osBIO != null || osNBTF != null || osNBTT != null && osENTCF != null || osENTCT != null;
|
||||
try {
|
||||
if (osBD != null) osBD.flush();
|
||||
if (osBIO != null) osBIO.flush();
|
||||
if (osNBTF != null) osNBTF.flush();
|
||||
if (osNBTT != null) osNBTT.flush();
|
||||
if (osENTCF != null) osENTCF.flush();
|
||||
if (osENTCT != null) osENTCT.flush();
|
||||
} catch (Exception e) {
|
||||
MainUtil.handleError(e);
|
||||
}
|
||||
return flushed;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean close() {
|
||||
super.close();
|
||||
synchronized (this) {
|
||||
boolean flushed = osBD != null || osBIO != null || osNBTF != null || osNBTT != null && osENTCF != null || osENTCT != null;
|
||||
try {
|
||||
|
@ -69,7 +69,7 @@ public abstract class FaweChangeSet implements ChangeSet {
|
||||
return world;
|
||||
}
|
||||
|
||||
public boolean flushAsync() {
|
||||
public boolean closeAsync() {
|
||||
waitingAsync.incrementAndGet();
|
||||
TaskManager.IMP.async(new Runnable() {
|
||||
@Override
|
||||
@ -78,7 +78,7 @@ public abstract class FaweChangeSet implements ChangeSet {
|
||||
synchronized (waitingAsync) {
|
||||
waitingAsync.notifyAll();
|
||||
}
|
||||
flush();
|
||||
close();
|
||||
}
|
||||
});
|
||||
return true;
|
||||
@ -104,6 +104,10 @@ public abstract class FaweChangeSet implements ChangeSet {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean close() {
|
||||
return flush();
|
||||
}
|
||||
|
||||
public abstract void add(int x, int y, int z, int combinedFrom, int combinedTo);
|
||||
|
||||
@Override
|
||||
|
@ -655,7 +655,7 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
||||
}
|
||||
|
||||
public Iterator<Change> getIterator(final boolean dir) {
|
||||
flush();
|
||||
close();
|
||||
try {
|
||||
final Iterator<MutableTileChange> tileCreate = getTileIterator(getTileCreateIS(), true, dir);
|
||||
final Iterator<MutableTileChange> tileRemove = getTileIterator(getTileRemoveIS(), false, dir);
|
||||
|
@ -56,6 +56,25 @@ public class MemoryOptimizedHistory extends FaweStreamChangeSet {
|
||||
@Override
|
||||
public boolean flush() {
|
||||
super.flush();
|
||||
synchronized (this) {
|
||||
try {
|
||||
if (idsStream != null) idsStreamZip.flush();
|
||||
if (biomeStream != null) biomeStreamZip.flush();
|
||||
if (entCStream != null) entCStreamZip.flush();
|
||||
if (entRStream != null) entRStreamZip.flush();
|
||||
if (tileCStream != null) tileCStreamZip.flush();
|
||||
if (tileRStream != null) tileRStreamZip.flush();
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
MainUtil.handleError(e);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean close() {
|
||||
super.close();
|
||||
synchronized (this) {
|
||||
try {
|
||||
if (idsStream != null) {
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.boydti.fawe.object.clipboard;
|
||||
|
||||
import com.boydti.fawe.object.RunnableVal2;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.ReflectionUtils;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.IntTag;
|
||||
@ -49,7 +48,6 @@ public class WorldCopyClipboard extends ReadOnlyClipboard {
|
||||
|
||||
@Override
|
||||
public void forEach(final RunnableVal2<Vector, BaseBlock> task, boolean air) {
|
||||
MainUtil.stacktrace();
|
||||
Vector min = region.getMinimumPoint();
|
||||
Vector max = region.getMaximumPoint();
|
||||
final Vector pos = new Vector();
|
||||
|
@ -585,7 +585,7 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
|
||||
public void enableQueue() {}
|
||||
|
||||
/**
|
||||
* Disable the queue. This will flush the queue.
|
||||
* Disable the queue. This will close the queue.
|
||||
*/
|
||||
public void disableQueue() {
|
||||
if (this.isQueueEnabled()) {
|
||||
@ -1313,9 +1313,9 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting
|
||||
}
|
||||
if (getChangeSet() != null) {
|
||||
if (Settings.IMP.HISTORY.COMBINE_STAGES) {
|
||||
((FaweChangeSet) getChangeSet()).flushAsync();
|
||||
((FaweChangeSet) getChangeSet()).closeAsync();
|
||||
} else {
|
||||
((FaweChangeSet) getChangeSet()).flush();
|
||||
((FaweChangeSet) getChangeSet()).close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -430,7 +430,7 @@ public class LocalSession {
|
||||
private FaweChangeSet getChangeSet(Object o) {
|
||||
if (o instanceof FaweChangeSet) {
|
||||
FaweChangeSet cs = (FaweChangeSet) o;
|
||||
cs.flush();
|
||||
cs.close();
|
||||
return cs;
|
||||
}
|
||||
if (o instanceof Integer) {
|
||||
|
@ -234,13 +234,11 @@ public class EllipsoidRegion extends AbstractRegion {
|
||||
return false;
|
||||
}
|
||||
if (sphere) {
|
||||
System.out.println((cx2 + cy2 + cz2) + " | " + radiusLengthSqr);
|
||||
return cx2 + cy2 + cz2 <= radiusLengthSqr;
|
||||
}
|
||||
double cxd = (double) cx / radius.getBlockX();
|
||||
double cyd = (double) cy / radius.getBlockY();
|
||||
double czd = (double) cz / radius.getBlockZ();
|
||||
System.out.println((cxd * cxd + cyd * cyd + czd * czd) + " | " + 1);
|
||||
return cxd * cxd + cyd * cyd + czd * czd <= 1;
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ public class Sniper {
|
||||
}
|
||||
if (tmpQueue != null) {
|
||||
FaweChangeSet changeSet = tmpQueue.getChangeSet();
|
||||
changeSet.flushAsync();
|
||||
changeSet.closeAsync();
|
||||
FawePlayer<Object> fp = FawePlayer.wrap(getPlayer());
|
||||
LocalSession session = fp.getSession();
|
||||
session.remember(changeSet.toEditSession(fp));
|
||||
|
Loading…
Reference in New Issue
Block a user