3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-05 19:10:07 +01:00

better locking of lighting and use correct method for relight without removing first

Fixes #847
Dieser Commit ist enthalten in:
dordsor21 2021-01-13 17:24:14 +00:00
Ursprung b066ca8349
Commit 97209d5680
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 1E53E88969FFCF0B
4 geänderte Dateien mit 30 neuen und 12 gelöschten Zeilen

Datei anzeigen

@ -71,6 +71,7 @@ public class NMSRelighter implements Relighter {
private final int maxY;
private final boolean calculateHeightMaps;
private final ReentrantLock lightingLock;
private final AtomicBoolean finished = new AtomicBoolean(false);
private boolean removeFirst;
public NMSRelighter(IQueueExtent<IQueueChunk> queue, boolean calculateHeightMaps) {
@ -99,6 +100,11 @@ public class NMSRelighter implements Relighter {
return lightingLock;
}
@Override
public boolean isFinished() {
return finished.get();
}
@Override public synchronized void removeAndRelight(boolean sky) {
removeFirst = true;
fixLightingSafe(sky);
@ -839,10 +845,12 @@ public class NMSRelighter implements Relighter {
}
if (Settings.IMP.LIGHTING.ASYNC) {
queue.flush();
finished.set(true);
} else {
TaskManager.IMP.sync(new RunnableVal<Object>() {
@Override public void run(Object value) {
queue.flush();
finished.set(true);
}
});
}
@ -873,6 +881,7 @@ public class NMSRelighter implements Relighter {
Fawe.imp().getPlatformAdapter().sendChunk(chunk.getOrCreateGet(), bitMask, true);
iter.remove();
}
finished.set(true);
}
};
if (Settings.IMP.LIGHTING.ASYNC) {

Datei anzeigen

@ -53,4 +53,9 @@ public class NullRelighter implements Relighter {
public ReentrantLock getLock() {
return null;
}
@Override
public boolean isFinished() {
return true;
}
}

Datei anzeigen

@ -70,6 +70,13 @@ public interface Relighter {
ReentrantLock getLock();
/**
* Returns true if the Relighter has been flushed
*
* @return true if finished
*/
boolean isFinished();
class SkipReason {
public static final byte NONE = 0;
public static final byte AIR = 1;

Datei anzeigen

@ -1098,18 +1098,15 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
limit.set(originalLimit);
try {
if (relighter != null && !(relighter instanceof NullRelighter)) {
// Only relight once!
if (Settings.IMP.LIGHTING.DELAY_PACKET_SENDING && !relighter.getLock().tryLock()) {
relighter.getLock().lock();
relighter.getLock().unlock();
} else {
if (Settings.IMP.LIGHTING.REMOVE_FIRST) {
relighter.removeAndRelight(true);
} else {
relighter.fixSkyLighting();
relighter.fixBlockLighting();
}
if (Settings.IMP.LIGHTING.DELAY_PACKET_SENDING) {
// Don't relight twice!
if (!relighter.isFinished() && relighter.getLock().tryLock()) {
try {
if (Settings.IMP.LIGHTING.REMOVE_FIRST) {
relighter.removeAndRelight(true);
} else {
relighter.fixLightingSafe(true);
}
} finally {
relighter.getLock().unlock();
}
}