Skip to content

Commit

Permalink
Combination of @DDoSQc 's pull request, additional checks to prevent …
Browse files Browse the repository at this point in the history
…spamming of the queue method and adds the chunk for population if an observer is added
  • Loading branch information
Raphfrk committed Jun 9, 2012
1 parent 8c43b4b commit 9aedcb5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/main/java/org/spout/engine/world/SpoutChunk.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 9aedcb5

Please sign in to comment.