2021-08-26 04:16:27 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
|
|
|
Date: Sun, 21 Mar 2021 17:32:47 -0700
|
|
|
|
Subject: [PATCH] Correctly handle recursion for chunkholder updates
|
|
|
|
|
|
|
|
If a chunk ticket level is brought up while unloading it would
|
|
|
|
cause a recursive call which would handle the increase but then
|
|
|
|
the caller would think the chunk would be unloaded.
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
2021-11-25 12:20:13 +01:00
|
|
|
index 41333234cdda8127a239f591d8d2cd304e341852..0b4c10b71d29d01408cafb38cdc7e48e6f90d8a8 100644
|
2021-08-26 04:16:27 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
2021-11-25 12:20:13 +01:00
|
|
|
@@ -426,8 +426,10 @@ public class ChunkHolder {
|
2021-08-26 04:16:27 +02:00
|
|
|
playerchunkmap.onFullChunkStatusChange(this.pos, playerchunk_state);
|
|
|
|
}
|
|
|
|
|
|
|
|
+ protected long updateCount; // Paper - correctly handle recursion
|
|
|
|
protected void updateFutures(ChunkMap chunkStorage, Executor executor) {
|
2021-11-25 09:54:06 +01:00
|
|
|
io.papermc.paper.util.TickThread.ensureTickThread("Async ticket level update"); // Paper
|
2021-08-26 04:16:27 +02:00
|
|
|
+ long updateCount = ++this.updateCount; // Paper - correctly handle recursion
|
|
|
|
ChunkStatus chunkstatus = ChunkHolder.getStatus(this.oldTicketLevel);
|
|
|
|
ChunkStatus chunkstatus1 = ChunkHolder.getStatus(this.ticketLevel);
|
|
|
|
boolean flag = this.oldTicketLevel <= ChunkMap.MAX_CHUNK_DISTANCE;
|
2021-11-25 12:20:13 +01:00
|
|
|
@@ -469,6 +471,12 @@ public class ChunkHolder {
|
2021-08-26 04:16:27 +02:00
|
|
|
|
|
|
|
// Run callback right away if the future was already done
|
|
|
|
chunkStorage.callbackExecutor.run();
|
|
|
|
+ // Paper start - correctly handle recursion
|
|
|
|
+ if (this.updateCount != updateCount) {
|
|
|
|
+ // something else updated ticket level for us.
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // Paper end - correctly handle recursion
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2021-11-25 04:06:43 +01:00
|
|
|
|