Fix player chunk loader behaving poorly when limits are low

Need to use ceil() so that it always allows at least 1 addition
for the 50ms case.
This commit is contained in:
Spottedleaf 2023-02-24 00:03:00 -08:00
parent b772012778
commit 9b824e6406
2 changed files with 3 additions and 3 deletions

View File

@ -46,7 +46,7 @@ index 0e45a340ae534caf676b7f9d0adcbcee5829925e..6df1948b1204a7288ecb7238b6fc2a73
private ChunkSystem() {
diff --git a/src/main/java/io/papermc/paper/chunk/system/RegionisedPlayerChunkLoader.java b/src/main/java/io/papermc/paper/chunk/system/RegionisedPlayerChunkLoader.java
new file mode 100644
index 0000000000000000000000000000000000000000..a4d58352eebed11fafde8c381afe3572893b8f8f
index 0000000000000000000000000000000000000000..cb170d1039fd9dadfbc27da0b181c00742e72025
--- /dev/null
+++ b/src/main/java/io/papermc/paper/chunk/system/RegionisedPlayerChunkLoader.java
@@ -0,0 +1,1302 @@
@ -1081,7 +1081,7 @@ index 0000000000000000000000000000000000000000..a4d58352eebed11fafde8c381afe3572
+ final long interval = counter.getInterval();
+ // rate = sum / interval
+ // so, sum = rate*interval
+ final long maxSum = (long)Math.floor(rate * (1.0E-9 * (double)interval));
+ final long maxSum = (long)Math.ceil(rate * (1.0E-9 * (double)interval));
+ final long diff = maxSum - sum;
+ if (diff < count) {
+ count = diff;

View File

@ -2133,7 +2133,7 @@ index 6df1948b1204a7288ecb7238b6fc2a733f7d25b3..6a413abc67aa4dcbab64231be3eb1344
public static ChunkHolder getUnloadingChunkHolder(final ServerLevel level, final int chunkX, final int chunkZ) {
diff --git a/src/main/java/io/papermc/paper/chunk/system/RegionisedPlayerChunkLoader.java b/src/main/java/io/papermc/paper/chunk/system/RegionisedPlayerChunkLoader.java
index a4d58352eebed11fafde8c381afe3572893b8f8f..2d601807b0b2ddc332e45878d4350b3bd661f5e2 100644
index cb170d1039fd9dadfbc27da0b181c00742e72025..5cccfcf45b3c3cdfdebdf47dc674934441cc0c4c 100644
--- a/src/main/java/io/papermc/paper/chunk/system/RegionisedPlayerChunkLoader.java
+++ b/src/main/java/io/papermc/paper/chunk/system/RegionisedPlayerChunkLoader.java
@@ -231,14 +231,14 @@ public class RegionisedPlayerChunkLoader {