@colyseus/schema 3.0.15 → 3.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1540,15 +1540,6 @@ function decodeValue(decoder, operation, ref, index, type, bytes, it, allChanges
1540
1540
  else if (Schema.is(type)) {
1541
1541
  const refId = decode.number(bytes, it);
1542
1542
  value = $root.refs.get(refId);
1543
- if (previousValue) {
1544
- const previousRefId = $root.refIds.get(previousValue);
1545
- if (previousRefId &&
1546
- refId !== previousRefId &&
1547
- // FIXME: we may need to check for REPLACE operation as well
1548
- ((operation & exports.OPERATION.DELETE) === exports.OPERATION.DELETE)) {
1549
- $root.removeRef(previousRefId);
1550
- }
1551
- }
1552
1543
  if ((operation & exports.OPERATION.ADD) === exports.OPERATION.ADD) {
1553
1544
  const childType = decoder.getInstanceType(bytes, it, type);
1554
1545
  if (!value) {
@@ -1576,7 +1567,6 @@ function decodeValue(decoder, operation, ref, index, type, bytes, it, allChanges
1576
1567
  if (previousValue) {
1577
1568
  let previousRefId = $root.refIds.get(previousValue);
1578
1569
  if (previousRefId !== undefined && refId !== previousRefId) {
1579
- $root.removeRef(previousRefId);
1580
1570
  //
1581
1571
  // enqueue onRemove if structure has been replaced.
1582
1572
  //
@@ -1601,7 +1591,8 @@ function decodeValue(decoder, operation, ref, index, type, bytes, it, allChanges
1601
1591
  }
1602
1592
  }
1603
1593
  }
1604
- $root.addRef(refId, value, (valueRef !== previousValue));
1594
+ $root.addRef(refId, value, (valueRef !== previousValue ||
1595
+ (operation === exports.OPERATION.DELETE_AND_ADD && valueRef === previousValue)));
1605
1596
  }
1606
1597
  return { value, previousValue };
1607
1598
  }