From e5acb6cf3a05e7e1d7e0256096ac5033c0e11e09 Mon Sep 17 00:00:00 2001 From: Travis Watkins Date: Sat, 4 Aug 2012 02:22:57 -0500 Subject: Don't tick chunks or entities on chunks that are queued for unload. Treat chunks in the unload queue as if they are already unloaded to prevent processing on them removing them from the unload queue and leaking. --- .../net/minecraft/server/ChunkProviderServer.java | 4 +-- src/main/java/net/minecraft/server/World.java | 29 +++++++++++++++++++++- 2 files changed, 30 insertions(+), 3 deletions(-) (limited to 'src/main/java/net') diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java index ace09490..3de2e480 100644 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java +++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java @@ -23,7 +23,7 @@ public class ChunkProviderServer implements IChunkProvider { public Chunk emptyChunk; public IChunkProvider chunkProvider; // CraftBukkit private IChunkLoader e; - public boolean forceChunkLoad = false; // true -> false + public boolean forceChunkLoad = true; public LongHashtable chunks = new LongHashtable(); public List chunkList = new ArrayList(); public WorldServer world; @@ -37,7 +37,7 @@ public class ChunkProviderServer implements IChunkProvider { } public boolean isChunkLoaded(int i, int j) { - return this.chunks.containsKey(i, j); // CraftBukkit + return !this.unloadQueue.containsKey(i, j) && this.chunks.containsKey(i, j); // CraftBukkit } public void queueUnload(int i, int j) { diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java index 830ed872..d552df0f 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -1053,7 +1053,12 @@ public abstract class World implements IBlockAccess { for (i = 0; i < this.j.size(); ++i) { entity = (Entity) this.j.get(i); - // CraftBukkit start - fixed an NPE + // CraftBukkit start - fixed an NPE, don't process entities in chunks queued for unload + ChunkProviderServer chunkProviderServer = ((WorldServer) entity.world).chunkProviderServer; + if (chunkProviderServer.unloadQueue.containsKey(MathHelper.floor(entity.locX) >> 4, MathHelper.floor(entity.locZ) >> 4)) { + continue; + } + if (entity == null) { continue; } @@ -1092,6 +1097,14 @@ public abstract class World implements IBlockAccess { for (i = 0; i < this.entityList.size(); ++i) { entity = (Entity) this.entityList.get(i); + + // CraftBukkit start - don't tick entities in chunks queued for unload + ChunkProviderServer chunkProviderServer = ((WorldServer) entity.world).chunkProviderServer; + if (chunkProviderServer.unloadQueue.containsKey(MathHelper.floor(entity.locX) >> 4, MathHelper.floor(entity.locZ) >> 4)) { + continue; + } + // CraftBukkit end + if (entity.vehicle != null) { if (!entity.vehicle.dead && entity.vehicle.passenger == entity) { continue; @@ -1129,6 +1142,13 @@ public abstract class World implements IBlockAccess { while (iterator.hasNext()) { TileEntity tileentity = (TileEntity) iterator.next(); + // CraftBukkit start - don't tick entities in chunks queued for unload + ChunkProviderServer chunkProviderServer = ((WorldServer) tileentity.world).chunkProviderServer; + if (chunkProviderServer.unloadQueue.containsKey(tileentity.x >> 4, tileentity.z >> 4)) { + continue; + } + // CraftBukkit end + if (!tileentity.p() && tileentity.m() && this.isLoaded(tileentity.x, tileentity.y, tileentity.z)) { tileentity.g(); } @@ -1791,6 +1811,13 @@ public abstract class World implements IBlockAccess { for (int l = -b0; l <= b0; ++l) { for (int i1 = -b0; i1 <= b0; ++i1) { + // CraftBukkit start - don't tick chunks queued for unload + ChunkProviderServer chunkProviderServer = ((WorldServer) entityhuman.world).chunkProviderServer; + if (chunkProviderServer.unloadQueue.containsKey(l + j, i1 + k)) { + continue; + } + // CraftBukkit end + this.chunkTickList.add(org.bukkit.craftbukkit.util.LongHash.toLong(l + j, i1 + k)); // CraftBukkit } } -- cgit v1.2.3