diff options
author | Travis Watkins <amaranth@ubuntu.com> | 2012-08-04 02:22:57 -0500 |
---|---|---|
committer | Travis Watkins <amaranth@ubuntu.com> | 2012-08-04 18:08:26 -0500 |
commit | e5acb6cf3a05e7e1d7e0256096ac5033c0e11e09 (patch) | |
tree | 6a82ce7f794f7c09323c52787f6b6a067138ea30 | |
parent | fdd01feb8c3468176c4a2fc312c37da34cc0152c (diff) | |
download | craftbukkit-e5acb6cf3a05e7e1d7e0256096ac5033c0e11e09.tar craftbukkit-e5acb6cf3a05e7e1d7e0256096ac5033c0e11e09.tar.gz craftbukkit-e5acb6cf3a05e7e1d7e0256096ac5033c0e11e09.tar.lz craftbukkit-e5acb6cf3a05e7e1d7e0256096ac5033c0e11e09.tar.xz craftbukkit-e5acb6cf3a05e7e1d7e0256096ac5033c0e11e09.zip |
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.
-rw-r--r-- | src/main/java/net/minecraft/server/ChunkProviderServer.java | 4 | ||||
-rw-r--r-- | src/main/java/net/minecraft/server/World.java | 29 |
2 files changed, 30 insertions, 3 deletions
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<Chunk> chunks = new LongHashtable<Chunk>(); 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 } } |