Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Combination of @DDoSQc 's pull request, additional checks to prevent …

…spamming of the queue method and adds the chunk for population if an observer is added
  • Loading branch information...
commit 9aedcb53d44f67722a4815f71755da76d8341101 1 parent 8c43b4b
Raphfrk Raphfrk authored
Showing with 8 additions and 1 deletion.
  1. +8 −1 src/main/java/org/spout/engine/world/SpoutChunk.java
9 src/main/java/org/spout/engine/world/SpoutChunk.java
View
@@ -671,6 +671,9 @@ public boolean refreshObserver(Entity entity) {
Integer oldDistance = observers.put(entity, distance);
if (oldDistance == null) {
parentRegion.unloadQueue.remove(this);
+ if (!isPopulated()) {
+ parentRegion.queueChunkForPopulation(this);
+ }
return true;
} else {
return false;
@@ -731,7 +734,7 @@ public boolean isDirty() {
@Override
public boolean canSend() {
boolean canSend = this.isPopulated() && !this.isCalculatingLighting();
- if (!canSend && !isPopulated()) {
+ if (!canSend && !isPopulated() && this.observers.get().size() > 0 && this.observers.getLive().size() > 0) {
((SpoutRegion)parentRegion).queueChunkForPopulation(this);
}
return canSend;
@@ -820,6 +823,10 @@ public void populate() {
@Override
public void populate(boolean force) {
+ if (this.observers.get().size() == 0 || this.observers.getLive().size() == 0) {
+ return;
+ }
+
if (this.populated.getAndSet(true) && !force) {
return;
}
Please sign in to comment.
Something went wrong with that request. Please try again.