13
0
geforkt von Mirrors/Paper

Fix chunk leak issue with queued light updates

Dieser Commit ist enthalten in:
Aikar 2016-05-13 01:34:37 -04:00
Ursprung f623f903cd
Commit b6d0dd32c6
3 geänderte Dateien mit 38 neuen und 20 gelöschten Zeilen

Datei anzeigen

@ -1,32 +1,20 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 12 May 2016 01:55:17 -0400
Subject: [PATCH] Fix chunk unload leak issues due to neighbor updates
Subject: [PATCH] Do not mark chunks as active for neighbor updates
Fixes chunk unload issues
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -0,0 +0,0 @@ public class ChunkProviderServer implements IChunkProvider {
}
}
+ // Paper start
+ @Nullable
+ public Chunk getLoadedChunkAtWithoutMarkingActive(int i, int j) {
+ return this.chunks.get(ChunkCoordIntPair.a(i, j));
+ }
+ // Paper end
@Nullable
public Chunk getLoadedChunkAt(int i, int j) {
@@ -0,0 +0,0 @@ public class ChunkProviderServer implements IChunkProvider {
continue;
}
- Chunk neighbor = this.getLoadedChunkAt(chunk.locX + x, chunk.locZ + z);
+ Chunk neighbor = this.getLoadedChunkAtWithoutMarkingActive(chunk.locX + x, chunk.locZ + z); // Paper
+ Chunk neighbor = MCUtil.getLoadedChunkWithoutMarkingActive(this, chunk.locX + x, chunk.locZ + z); // Paper
if (neighbor != null) {
neighbor.setNeighborLoaded(-x, -z);
chunk.setNeighborLoaded(x, z);
@ -35,7 +23,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
- Chunk neighbor = this.chunks.get(ChunkCoordIntPair.a(chunk.locX + x, chunk.locZ + z));
+ Chunk neighbor = this.getLoadedChunkAtWithoutMarkingActive(chunk.locX + x, chunk.locZ + z); // Paper
+ Chunk neighbor = MCUtil.getLoadedChunkWithoutMarkingActive(this, chunk.locX + x, chunk.locZ + z); // Paper
if (neighbor != null) {
neighbor.setNeighborUnloaded(-x, -z);
chunk.setNeighborUnloaded(x, z);
@ -48,7 +36,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
- net.minecraft.server.Chunk neighbor = world.getChunkProviderServer().getLoadedChunkAt(chunk.locX + x, chunk.locZ + z);
+ net.minecraft.server.Chunk neighbor = world.getChunkProviderServer().getLoadedChunkAtWithoutMarkingActive(chunk.locX + x, chunk.locZ + z); // Paper
+ net.minecraft.server.Chunk neighbor = net.minecraft.server.MCUtil.getLoadedChunkWithoutMarkingActive(world, chunk.locX + x, chunk.locZ + z); // Paper
if (neighbor != null) {
neighbor.setNeighborUnloaded(-xx, -zz);
chunk.setNeighborUnloaded(xx, zz);
@ -57,7 +45,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
- net.minecraft.server.Chunk neighbor = world.getChunkProviderServer().getLoadedChunkAt(chunk.locX + x, chunk.locZ + z);
+ net.minecraft.server.Chunk neighbor = world.getChunkProviderServer().getLoadedChunkAtWithoutMarkingActive(chunk.locX + x, chunk.locZ + z); // Paper
+ net.minecraft.server.Chunk neighbor = net.minecraft.server.MCUtil.getLoadedChunkWithoutMarkingActive(world, chunk.locX + x, chunk.locZ + z); // Paper
if (neighbor != null) {
neighbor.setNeighborLoaded(-x, -z);
chunk.setNeighborLoaded(x, z);
@ -65,12 +53,20 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java b
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java
+++ b/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java
@@ -0,0 +0,0 @@ import net.minecraft.server.Chunk;
import net.minecraft.server.ChunkCoordIntPair;
import net.minecraft.server.ChunkRegionLoader;
import net.minecraft.server.NBTTagCompound;
-
import org.bukkit.Server;
import org.bukkit.craftbukkit.util.AsynchronousExecutor;
@@ -0,0 +0,0 @@ class ChunkIOProvider implements AsynchronousExecutor.CallBackProvider<QueuedChu
continue;
}
- Chunk neighbor = queuedChunk.provider.getLoadedChunkAt(chunk.locX + x, chunk.locZ + z);
+ Chunk neighbor = queuedChunk.provider.getLoadedChunkAtWithoutMarkingActive(chunk.locX + x, chunk.locZ + z); // Paper
+ Chunk neighbor = net.minecraft.server.MCUtil.getLoadedChunkWithoutMarkingActive(queuedChunk.provider, chunk.locX + x, chunk.locZ + z); // Paper
if (neighbor != null) {
neighbor.setNeighborLoaded(-x, -z);
chunk.setNeighborLoaded(x, z);

Datei anzeigen

@ -122,7 +122,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ continue;
+ }
+
+ Chunk chunk = world.getChunkIfLoaded(x, z);
+ Chunk chunk = MCUtil.getLoadedChunkWithoutMarkingActive(world, x, z);
+ if (chunk != null && chunk.lightUpdates > 0) {
+ return true;
+ }

Datei anzeigen

@ -15,6 +15,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
+import org.bukkit.Location;
+
+import javax.annotation.Nullable;
+import java.util.regex.Pattern;
+
+public class MCUtil {
@ -129,6 +130,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ final int modZ = pos.getZ() & 15;
+ return (modX == 0 || modX == 15 || modZ == 0 || modZ == 15);
+ }
+
+ /**
+ * Gets a chunk without changing its boolean for should unload
+ * @param world
+ * @param x
+ * @param z
+ * @return
+ */
+ @Nullable public static Chunk getLoadedChunkWithoutMarkingActive(World world, int x, int z) {
+ return ((ChunkProviderServer) world.chunkProvider).chunks.get(ChunkCoordIntPair.a(x, z));
+ }
+ /**
+ * Gets a chunk without changing its boolean for should unload
+ * @param provider
+ * @param x
+ * @param z
+ * @return
+ */
+ @Nullable public static Chunk getLoadedChunkWithoutMarkingActive(ChunkProviderServer provider, int x, int z) {
+ return provider.chunks.get(ChunkCoordIntPair.a(x, z));
+ }
+}
diff --git a/src/main/java/net/minecraft/server/NBTTagCompound.java b/src/main/java/net/minecraft/server/NBTTagCompound.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644