Files
Shiroha/shiroha-server/minecraft-patches/features/0024-Fix-incorrect-ticket-lock-size-computing.patch
T
NanaChiyo0721 1bb895c165
Shiroha CI / build (push) Canceled after 0s
Shiroha CI / Event File (push) Canceled after 0s
Fix incorrect ticket lock size computing
Yeah this would fully solve the issue of chunk unloading race condition

The same fix was already initially added at "Force clamp grid-exponent to 1~6"
2026-08-09 14:57:32 +08:00

32 lines
2.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: NanaChiyo0721 <nanachiyo0721@163.com>
Date: Sun, 9 Aug 2026 14:35:48 +0800
Subject: [PATCH] Fix incorrect ticket lock size computing
diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java
index 8b06d0c893e07c969d35c4d7528927552c27b48b..352325aeea9e4f797893911d81703262b198ecd5 100644
--- a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java
+++ b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java
@@ -941,14 +941,18 @@ public final class ChunkHolderManager {
final int lowerChunkX = CoordinateUtils.getChunkX(sectionKey) << sectionShift;
final int lowerChunkZ = CoordinateUtils.getChunkZ(sectionKey) << sectionShift;
+ // Shiroha start - Fix incorrect ticket lock size computing
+ final int upperChunkX = lowerChunkX + (1 << sectionShift) - 1;
+ final int upperChunkZ = lowerChunkZ + (1 << sectionShift) - 1;
+ // Shiroha end - Fix incorrect ticket lock size computing
final int ticketShift = ThreadedTicketLevelPropagator.SECTION_SHIFT;
final int ticketMask = (1 << ticketShift) - 1;
final ReentrantAreaLock.Node ticketLock = this.ticketLockArea.lock(
((lowerChunkX >> ticketShift) - 1) << ticketShift,
((lowerChunkZ >> ticketShift) - 1) << ticketShift,
- (((lowerChunkX >> ticketShift) + 1) << ticketShift) | ticketMask,
- (((lowerChunkZ >> ticketShift) + 1) << ticketShift) | ticketMask
+ (((upperChunkX >> ticketShift) + 1) << ticketShift) | ticketMask, // Shiroha - Fix incorrect ticket lock size computing
+ (((upperChunkZ >> ticketShift) + 1) << ticketShift) | ticketMask // Shiroha - Fix incorrect ticket lock size computing
);
try {