@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.
@@ -1538,15 +1538,6 @@ function decodeValue(decoder, operation, ref, index, type, bytes, it, allChanges
1538
1538
  else if (Schema.is(type)) {
1539
1539
  const refId = decode.number(bytes, it);
1540
1540
  value = $root.refs.get(refId);
1541
- if (previousValue) {
1542
- const previousRefId = $root.refIds.get(previousValue);
1543
- if (previousRefId &&
1544
- refId !== previousRefId &&
1545
- // FIXME: we may need to check for REPLACE operation as well
1546
- ((operation & OPERATION.DELETE) === OPERATION.DELETE)) {
1547
- $root.removeRef(previousRefId);
1548
- }
1549
- }
1550
1541
  if ((operation & OPERATION.ADD) === OPERATION.ADD) {
1551
1542
  const childType = decoder.getInstanceType(bytes, it, type);
1552
1543
  if (!value) {
@@ -1574,7 +1565,6 @@ function decodeValue(decoder, operation, ref, index, type, bytes, it, allChanges
1574
1565
  if (previousValue) {
1575
1566
  let previousRefId = $root.refIds.get(previousValue);
1576
1567
  if (previousRefId !== undefined && refId !== previousRefId) {
1577
- $root.removeRef(previousRefId);
1578
1568
  //
1579
1569
  // enqueue onRemove if structure has been replaced.
1580
1570
  //
@@ -1599,7 +1589,8 @@ function decodeValue(decoder, operation, ref, index, type, bytes, it, allChanges
1599
1589
  }
1600
1590
  }
1601
1591
  }
1602
- $root.addRef(refId, value, (valueRef !== previousValue));
1592
+ $root.addRef(refId, value, (valueRef !== previousValue ||
1593
+ (operation === OPERATION.DELETE_AND_ADD && valueRef === previousValue)));
1603
1594
  }
1604
1595
  return { value, previousValue };
1605
1596
  }