mirror of
https://github.com/ProjectSWGCore/Holocore.git
synced 2026-09-11 21:45:26 -04:00
Fixed SWGList and SWGMap sending excessive data after a delta and then relogging, which often lead to a "blue ghost" for equipment
Blue Ghost. Never Forget. RIP.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -169,7 +169,7 @@ public class SWGList<E> extends AbstractList<E> 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<E> extends AbstractList<E> implements Encodable {
|
||||
deltas.clear();
|
||||
deltaSize = 0;
|
||||
}
|
||||
|
||||
|
||||
private void clearAllData() {
|
||||
data.clear();
|
||||
dataSize = 0;
|
||||
clearDeltaQueue();
|
||||
}
|
||||
|
||||
public void setUpdateCount(int count) {
|
||||
this.updateCount = count;
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ public class SWGMap<K, V> extends AbstractMap<K, V> implements Encodable {
|
||||
|
||||
if (data.size() != size) {
|
||||
// Data got out of sync with the map, so lets clean that up!
|
||||
data.clear();
|
||||
clearAllData();
|
||||
for (Entry<K, V> entry : map.entrySet()) {
|
||||
addData(entry.getKey(), entry.getValue(), (byte) 0);
|
||||
}
|
||||
@@ -188,7 +188,7 @@ public class SWGMap<K, V> extends AbstractMap<K, V> 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<K, V> extends AbstractMap<K, V> 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);
|
||||
|
||||
@@ -579,6 +579,8 @@ public abstract class SWGObject implements Serializable, Comparable<SWGObject> {
|
||||
}
|
||||
|
||||
private void sendUpdatedContainment(List<SWGObject> oldObservers, List<SWGObject> newObservers) {
|
||||
if (parent == null)
|
||||
return;
|
||||
List<SWGObject> same = new ArrayList<>(oldObservers);
|
||||
same.retainAll(newObservers);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user