From 129e676106ccd18086e2fe60c0097f3cc2e733de Mon Sep 17 00:00:00 2001 From: Waverunner Date: Thu, 28 May 2015 08:16:41 -0400 Subject: [PATCH] Fixed getObjectAwareness including children objects sometimes leading to duplicate packets being sent. In order to get children object's included in the awareness list, you must now specifically call getChildrenAwareness() This commit fixes duplicate chat as well. --- src/resources/objects/SWGObject.java | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/resources/objects/SWGObject.java b/src/resources/objects/SWGObject.java index 3e777058d..e546cb4b4 100644 --- a/src/resources/objects/SWGObject.java +++ b/src/resources/objects/SWGObject.java @@ -50,6 +50,7 @@ import resources.network.BaselineBuilder; import resources.network.DeltaBuilder; import resources.player.Player; import resources.player.PlayerState; +import resources.server_info.Log; import utilities.Encoder.StringType; public class SWGObject implements Serializable, Comparable { @@ -175,7 +176,7 @@ public class SWGObject implements Serializable, Comparable { // TODO Slot occupation check, old version was not working properly, always returning SLOT_OCCUPIED // Get a pre-parent-removal list of the observers so we can send create/destroy/update messages - List oldObservers = getObjectsAware(); + List oldObservers = getChildrenAwareness(); // Remove this object from the old parent if one exists if (parent != null) { @@ -185,7 +186,7 @@ public class SWGObject implements Serializable, Comparable { container.addObject(this); // Observer notification - sendUpdatedContainment(oldObservers, new ArrayList<>(container.getObjectsAware())); + sendUpdatedContainment(oldObservers, new ArrayList<>(container.getChildrenAwareness())); return ContainerResult.SUCCESS; } @@ -472,6 +473,7 @@ public class SWGObject implements Serializable, Comparable { } protected void createObject(Player target) { + Log.i("ContainerPermissions", "Sending baselines for %s with owner %s to %s", this, this.getOwner(), target); sendSceneCreateObject(target); createChildrenObjects(target); target.sendPacket(new SceneEndBaselines(getObjectId())); @@ -487,14 +489,14 @@ public class SWGObject implements Serializable, Comparable { awarenessOutOfRange(o); } } - + public List getObjectsAware() { synchronized (objectsAware) { - return Collections.unmodifiableList(getChildrenAwareness()); + return Collections.unmodifiableList(objectsAware); } } - private List getChildrenAwareness() { + public List getChildrenAwareness() { List awareness = new ArrayList<>(objectsAware); if (getParent() != null && !(awareness.contains(getParent()))) @@ -519,6 +521,8 @@ public class SWGObject implements Serializable, Comparable { if (p == null || p.getPlayerState() != PlayerState.ZONED_IN) continue; p.sendPacket(packets); + + //System.out.println("Sent " + packets + " for " + this + " to objAware " + obj); } List childrenAwareness = getChildrenAwareness(); @@ -533,12 +537,16 @@ public class SWGObject implements Serializable, Comparable { if (p == null || p.getPlayerState() != PlayerState.ZONED_IN) continue; p.sendPacket(packets); + + //System.out.println("Sent " + packets + " of " + this + " to child " + childObserver); } SWGObject parent = getParent(); - if(parent != null) + if(parent != null) { parent.sendObservers(packets); + //System.out.println("Sent " + packets + " to observers of " + this); + } } }