Paper/patches/server/0759-Do-not-allow-ticket-level-changes-when-updating-chun.patch
Spottedleaf 1c4f87a258
Ensure priority updates are determined by current level, not deferred level (#6507)
* Ensure priority updates are determined by current level, not deferred level

Deferral could cause an infinite loop to occur.

Also, re-add the light engine priority logic.

* Rebase

Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com>
2021-08-27 19:20:31 -07:00

41 lines
2.2 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Sun, 20 Jun 2021 00:08:13 -0700
Subject: [PATCH] Do not allow ticket level changes when updating chunk ticking
state
This WILL cause state corruption if it happens. So, don't
allow it.
diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java
index ee71e8678e58441287a9cd6cf00d5635daddc60f..7c0d404e5ac6819326276fb6424e33949c4ee08b 100644
--- a/src/main/java/net/minecraft/server/level/ChunkHolder.java
+++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java
@@ -599,7 +599,13 @@ public class ChunkHolder {
CompletableFuture<Void> completablefuture1 = new CompletableFuture();
completablefuture1.thenRunAsync(() -> {
+ // Paper start - do not allow ticket level changes
+ boolean unloadingBefore = this.chunkMap.unloadingPlayerChunk;
+ this.chunkMap.unloadingPlayerChunk = true;
+ try {
+ // Paper end - do not allow ticket level changes
playerchunkmap.onFullChunkStatusChange(this.pos, playerchunk_state);
+ } finally { this.chunkMap.unloadingPlayerChunk = unloadingBefore; } // Paper - do not allow ticket level changes
}, executor);
this.pendingFullStateConfirmation = completablefuture1;
completablefuture.thenAccept((either) -> {
@@ -623,7 +629,12 @@ public class ChunkHolder {
private void demoteFullChunk(ChunkMap playerchunkmap, ChunkHolder.FullChunkStatus playerchunk_state) {
this.pendingFullStateConfirmation.cancel(false);
+ // Paper start - do not allow ticket level changes
+ boolean unloadingBefore = this.chunkMap.unloadingPlayerChunk;
+ this.chunkMap.unloadingPlayerChunk = true;
+ try { // Paper end - do not allow ticket level changes
playerchunkmap.onFullChunkStatusChange(this.pos, playerchunk_state);
+ } finally { this.chunkMap.unloadingPlayerChunk = unloadingBefore; } // Paper - do not allow ticket level changes
}
protected long updateCount; // Paper - correctly handle recursion