diff --git a/src/network/packets/swg/zone/UpdateContainmentMessage.java b/src/network/packets/swg/zone/UpdateContainmentMessage.java index 6ba83b3f..e3f6c83f 100644 --- a/src/network/packets/swg/zone/UpdateContainmentMessage.java +++ b/src/network/packets/swg/zone/UpdateContainmentMessage.java @@ -58,8 +58,7 @@ public class UpdateContainmentMessage extends SWGPacket { } public ByteBuffer encode() { - int length = 26; - ByteBuffer data = ByteBuffer.allocate(length); + ByteBuffer data = ByteBuffer.allocate(26); addShort(data, 4); addInt( data, CRC); addLong( data, objectId); diff --git a/src/resources/collections/SWGList.java b/src/resources/collections/SWGList.java index 4b762ce6..cfcc9cd5 100644 --- a/src/resources/collections/SWGList.java +++ b/src/resources/collections/SWGList.java @@ -169,7 +169,7 @@ public class SWGList extends AbstractList implements Encodable { if (size != data.size()) { // Data got out of sync with the list, so lets clean that up! - data.clear(); + clearAllData(); for (int i = 0; i < size; i++) { addObjectData(i, list.get(i), (byte) 0); } @@ -206,7 +206,13 @@ public class SWGList extends AbstractList implements Encodable { deltas.clear(); deltaSize = 0; } - + + private void clearAllData() { + data.clear(); + dataSize = 0; + clearDeltaQueue(); + } + public void setUpdateCount(int count) { this.updateCount = count; } diff --git a/src/resources/collections/SWGMap.java b/src/resources/collections/SWGMap.java index 6b3f2ab9..63ecc9a1 100644 --- a/src/resources/collections/SWGMap.java +++ b/src/resources/collections/SWGMap.java @@ -163,7 +163,7 @@ public class SWGMap extends AbstractMap implements Encodable { if (data.size() != size) { // Data got out of sync with the map, so lets clean that up! - data.clear(); + clearAllData(); for (Entry entry : map.entrySet()) { addData(entry.getKey(), entry.getValue(), (byte) 0); } @@ -188,7 +188,7 @@ public class SWGMap extends AbstractMap implements Encodable { DeltaBuilder builder = new DeltaBuilder(target, baseline, view, updateType, getDeltaData()); builder.send(); - + // Clear the queue since the delta has been sent to observers through the builder clearDeltaQueue(); } @@ -222,7 +222,14 @@ public class SWGMap extends AbstractMap implements Encodable { deltas.put(key, combindedUpdate); } } - + + private void clearAllData() { + dataSize = 0; + data.clear(); + + clearDeltaQueue(); + } + private void addData(Object key, Object value, byte update) { byte[] encodedKey = Encoder.encode(key, strType); byte[] encodedValue = Encoder.encode(value, strType); diff --git a/src/resources/objects/SWGObject.java b/src/resources/objects/SWGObject.java index cdcab77b..9cc3e4e2 100644 --- a/src/resources/objects/SWGObject.java +++ b/src/resources/objects/SWGObject.java @@ -579,6 +579,8 @@ public abstract class SWGObject implements Serializable, Comparable { } private void sendUpdatedContainment(List oldObservers, List newObservers) { + if (parent == null) + return; List same = new ArrayList<>(oldObservers); same.retainAll(newObservers);