mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 12:27:59 +01:00
Fix unload queue storing chunks in wrong sections
The unload queue stored the chunks in the same section as the chunk coordinate, when it needed to apply the unload shift. Additionally, change the default region shift to the ticket propagator shift as there is no benefit to using a low region shift since no regionizing is occuring. This makes the unload queue shift 6, which should reduce the number of sections to deal with while processing unloads.
This commit is contained in:
parent
31ddf26e18
commit
89961bad94
@ -8627,12 +8627,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ final int shift = this.coordinateShift;
|
||||
+ final int sectionX = chunkX >> shift;
|
||||
+ final int sectionZ = chunkZ >> shift;
|
||||
+ final long sectionKey = CoordinateUtils.getChunkKey(sectionX, sectionZ);
|
||||
+ final long chunkKey = CoordinateUtils.getChunkKey(chunkX, chunkZ);
|
||||
+
|
||||
+ UnloadSection section = this.unloadSections.get(chunkKey);
|
||||
+ UnloadSection section = this.unloadSections.get(sectionKey);
|
||||
+ if (section == null) {
|
||||
+ section = new UnloadSection(this.orderGenerator.getAndIncrement());
|
||||
+ this.unloadSections.put(chunkKey, section);
|
||||
+ this.unloadSections.put(sectionKey, section);
|
||||
+ }
|
||||
+
|
||||
+ return section.chunks.add(chunkKey);
|
||||
@ -8644,9 +8645,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ final int shift = this.coordinateShift;
|
||||
+ final int sectionX = chunkX >> shift;
|
||||
+ final int sectionZ = chunkZ >> shift;
|
||||
+ final long sectionKey = CoordinateUtils.getChunkKey(sectionX, sectionZ);
|
||||
+ final long chunkKey = CoordinateUtils.getChunkKey(chunkX, chunkZ);
|
||||
+
|
||||
+ final UnloadSection section = this.unloadSections.get(chunkKey);
|
||||
+ final UnloadSection section = this.unloadSections.get(sectionKey);
|
||||
+
|
||||
+ if (section == null) {
|
||||
+ return false;
|
||||
@ -8657,7 +8659,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ }
|
||||
+
|
||||
+ if (section.chunks.isEmpty()) {
|
||||
+ this.unloadSections.remove(chunkKey);
|
||||
+ this.unloadSections.remove(sectionKey);
|
||||
+ }
|
||||
+
|
||||
+ return true;
|
||||
@ -8678,7 +8680,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ sectionJson.add("coordinates", coordinates);
|
||||
+
|
||||
+ final UnloadSection actualSection = this.getSectionUnsynchronized(section.sectionX(), section.sectionZ());
|
||||
+ for (final LongIterator iterator = actualSection.chunks.clone().iterator(); iterator.hasNext();) {
|
||||
+ if (actualSection != null) {
|
||||
+ for (final LongIterator iterator = actualSection.chunks.clone().iterator(); iterator.hasNext(); ) {
|
||||
+ final long coordinate = iterator.nextLong();
|
||||
+
|
||||
+ final JsonObject coordinateJson = new JsonObject();
|
||||
@ -8688,6 +8691,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ coordinateJson.addProperty("chunkZ", Integer.valueOf(CoordinateUtils.getChunkZ(coordinate)));
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return ret;
|
||||
+ }
|
||||
@ -22859,7 +22863,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+public class TickRegions {
|
||||
+
|
||||
+ public static int getRegionChunkShift() {
|
||||
+ return 2;
|
||||
+ return ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ThreadedTicketLevelPropagator.SECTION_SHIFT;
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
|
Loading…
Reference in New Issue
Block a user