use a Queue in ChunkMapDistance

An oversight in this patch may be to blame for several issues in certain
cases, we'll opt to using a queue as this will fall in line with what is
expected and may help some issues where chunks remain loaded or fail to
load
This commit is contained in:
Shane Freeder 2019-07-02 19:50:03 +01:00
parent dafc3dbcd5
commit 1bacdbd169
No known key found for this signature in database
GPG key ID: A3F61EA5A085289C
3 changed files with 33 additions and 23 deletions

View file

@ -1,37 +1,47 @@
From 75d7f6aa1662e91a24593022180ba867cbbabca0 Mon Sep 17 00:00:00 2001
From 4edf0cf5fcd69d7b5fc89c185144706f2de35667 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Wed, 29 May 2019 04:01:22 +0100
Subject: [PATCH] ChunkMapDistance CME
diff --git a/src/main/java/net/minecraft/server/ChunkMapDistance.java b/src/main/java/net/minecraft/server/ChunkMapDistance.java
index ed4e8d69ca..cd18150488 100644
index ed4e8d69ca..f72843119a 100644
--- a/src/main/java/net/minecraft/server/ChunkMapDistance.java
+++ b/src/main/java/net/minecraft/server/ChunkMapDistance.java
@@ -36,7 +36,7 @@ public abstract class ChunkMapDistance {
@@ -23,6 +23,7 @@ import it.unimi.dsi.fastutil.objects.ObjectSortedSet;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
+
import javax.annotation.Nullable;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -36,7 +37,7 @@ public abstract class ChunkMapDistance {
private final ChunkMapDistance.a e = new ChunkMapDistance.a();
private final ChunkMapDistance.b f = new ChunkMapDistance.b(8);
private final ChunkMapDistance.c g = new ChunkMapDistance.c(33);
- private final Set<PlayerChunk> h = Sets.newHashSet();
+ private Set<PlayerChunk> h = Sets.newHashSet(); // Paper - -final
+ private java.util.Queue<PlayerChunk> h = new java.util.LinkedList<>(); // Paper - -final
private final PlayerChunk.c i;
private final Mailbox<ChunkTaskQueueSorter.a<Runnable>> j;
private final Mailbox<ChunkTaskQueueSorter.b> k;
@@ -98,8 +98,12 @@ public abstract class ChunkMapDistance {
@@ -98,11 +99,12 @@ public abstract class ChunkMapDistance {
;
}
- if (!this.h.isEmpty()) {
- this.h.forEach((playerchunk) -> {
+ // Paper start
+ Set<PlayerChunk> currentPending = this.h;
+ this.h = Sets.newHashSet();
+ if (!currentPending.isEmpty()) {
+ currentPending.forEach((playerchunk) -> {
+ // Paper end
playerchunk.a(playerchunkmap);
});
this.h.clear();
if (!this.h.isEmpty()) {
- this.h.forEach((playerchunk) -> {
- playerchunk.a(playerchunkmap);
- });
- this.h.clear();
+ while(!this.h.isEmpty()) {
+ this.h.remove().a(playerchunkmap);
+ }
+ // Paper end
return true;
} else {
if (!this.l.isEmpty()) {
--
2.22.0

View file

@ -1,4 +1,4 @@
From fff0d1d37878fe9cf31980df2db36cc80037d815 Mon Sep 17 00:00:00 2001
From cf96fbf8f2765c7b40b3bf5d75e747af5d91d0f4 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Sat, 1 Jun 2019 13:00:55 -0700
Subject: [PATCH] Chunk debug command
@ -185,10 +185,10 @@ index 391726d99c..8db92edc36 100644
* Ported from MinecraftForge - author: LexManos <LexManos@gmail.com> - License: LGPLv2.1
*/
diff --git a/src/main/java/net/minecraft/server/ChunkMapDistance.java b/src/main/java/net/minecraft/server/ChunkMapDistance.java
index cd18150488..0c562a5f34 100644
index f72843119a..c1fdd7b7a4 100644
--- a/src/main/java/net/minecraft/server/ChunkMapDistance.java
+++ b/src/main/java/net/minecraft/server/ChunkMapDistance.java
@@ -32,7 +32,7 @@ public abstract class ChunkMapDistance {
@@ -33,7 +33,7 @@ public abstract class ChunkMapDistance {
private static final Logger LOGGER = LogManager.getLogger();
private static final int b = 33 + ChunkStatus.a(ChunkStatus.FULL) - 2;
private final Long2ObjectMap<ObjectSet<EntityPlayer>> c = new Long2ObjectOpenHashMap();

View file

@ -1,4 +1,4 @@
From 2132645f7895a363f1c726ccbe3a15639ab1d998 Mon Sep 17 00:00:00 2001
From d1f7563e1c33a5892e42263f6f79bbef7ff52840 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Sun, 16 Jun 2019 23:30:25 -0700
Subject: [PATCH] Fix MC-154214
@ -6,10 +6,10 @@ Subject: [PATCH] Fix MC-154214
Avoid adding player tickets when they're out of range of the closest player
diff --git a/src/main/java/net/minecraft/server/ChunkMapDistance.java b/src/main/java/net/minecraft/server/ChunkMapDistance.java
index 0c562a5f34..7a76db08fc 100644
index c1fdd7b7a4..1a6fe87cd8 100644
--- a/src/main/java/net/minecraft/server/ChunkMapDistance.java
+++ b/src/main/java/net/minecraft/server/ChunkMapDistance.java
@@ -333,12 +333,18 @@ public abstract class ChunkMapDistance {
@@ -331,12 +331,18 @@ public abstract class ChunkMapDistance {
}
private void a(long i, int j, boolean flag, boolean flag1) {
@ -28,7 +28,7 @@ index 0c562a5f34..7a76db08fc 100644
ChunkMapDistance.this.a(i, ticket);
ChunkMapDistance.this.l.add(i);
});
@@ -382,6 +388,7 @@ public abstract class ChunkMapDistance {
@@ -380,6 +386,7 @@ public abstract class ChunkMapDistance {
}
@ -36,7 +36,7 @@ index 0c562a5f34..7a76db08fc 100644
private boolean c(int i) {
return i <= this.e - 2;
}
@@ -389,7 +396,7 @@ public abstract class ChunkMapDistance {
@@ -387,7 +394,7 @@ public abstract class ChunkMapDistance {
class b extends ChunkMap {