@rbxts/replecs 0.4.0-rc.4 → 0.4.0-rc.5

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.
@@ -777,13 +777,18 @@ local function process_full_entity(
777
777
  end
778
778
  end
779
779
 
780
+ -- removals resolve their target with find_entity: a target this client never
781
+ -- saw (filtered out, or deleted earlier in the same packet) has nothing to
782
+ -- remove, and creating a placeholder for it would leak a ghost entity
783
+
780
784
  -- pair tag removal: [target id, relation]
781
785
  local function process_entity_pair_removal(self: Client, entity: Entity, c: Cursor, custom_ids: CustomIdMap)
782
786
  local relation = read_component_id(self, c)
783
787
  local relation_hooks = self.network_hooks.removed[PAIR(self.components.relation, relation)]
784
- process_entity(self, c, custom_ids, function(target)
788
+ local target = find_entity(self, c)
789
+ if target then
785
790
  entity_remove_pair(self, entity, relation, target, relation_hooks)
786
- end)
791
+ end
787
792
  end
788
793
 
789
794
  -- relation target removals: [target ids..., vlq count, relation]
@@ -793,9 +798,10 @@ local function process_entity_relation_removals(self: Client, entity: Entity, c:
793
798
  local relation_hooks = self.network_hooks.removed[PAIR(self.components.relation, relation)]
794
799
 
795
800
  for _ = 1, total_targets do
796
- process_entity(self, c, custom_ids, function(target)
801
+ local target = find_entity(self, c)
802
+ if target then
797
803
  entity_remove_pair(self, entity, relation, target, relation_hooks)
798
- end)
804
+ end
799
805
  end
800
806
  end
801
807
 
@@ -1595,8 +1601,7 @@ function client.resolve_dirty(self: Client)
1595
1601
  end
1596
1602
  end
1597
1603
 
1598
- self.shared =
1599
- shared.resolve_shared(self.world, self.components, self.registered_custom_ids, serdes, preprocessors)
1604
+ self.shared = shared.resolve_shared(self.world, self.components, self.registered_custom_ids, serdes, preprocessors)
1600
1605
  self.is_shared_dirty = false
1601
1606
  end
1602
1607
 
@@ -1759,6 +1764,8 @@ return {
1759
1764
 
1760
1765
  process_entity_pair = process_entity_pair,
1761
1766
  process_entity_pair_value = process_entity_pair_value,
1767
+ process_entity_pair_removal = process_entity_pair_removal,
1768
+ process_entity_relation_removals = process_entity_relation_removals,
1762
1769
  process_entity_relations = process_entity_relations,
1763
1770
  process_entity_relation_values = process_entity_relation_values,
1764
1771
  process_full_entity = process_full_entity,
@@ -30,7 +30,6 @@ export type FilterNodeClass = {
30
30
  input_versions: Array<number>,
31
31
  dependents: Set<FilterNode>,
32
32
 
33
-
34
33
  value: Bitmask?,
35
34
  scratch: Bitmask?,
36
35
  version: number,
@@ -173,7 +172,6 @@ local function resolve_computed(node: FilterNode, scratch: Bitmask): boolean
173
172
  return true
174
173
  end
175
174
 
176
-
177
175
  function filter_node.resolve(node: FilterNode): Bitmask
178
176
  local reg = node.registry
179
177
  if not reg then
@@ -263,7 +261,6 @@ function filter_node.clear(self: FilterNode)
263
261
  mark_dirty(self)
264
262
  end
265
263
 
266
-
267
264
  function filter_node.create_source(reg: Registry?, initial: FilterSimple?): FilterNode
268
265
  local node = create_node(KINDS.source, reg)
269
266
  node.member_set = {}
@@ -331,7 +328,6 @@ function filter_node.exclude(self: FilterNode, ...: FilterOperand): FilterNode
331
328
  return create_computed(KINDS.exclude, self, { ... })
332
329
  end
333
330
 
334
-
335
331
  function filter_node.members(self: FilterNode): Set<Player>
336
332
  local value = filter_node.resolve(self)
337
333
  local index_clients = (self.registry :: Registry).index_clients
@@ -1876,7 +1876,11 @@ function push_relation_updates(
1876
1876
  local is_component = storage.is_component
1877
1877
 
1878
1878
  for target in storage.dirty_targets do
1879
- if WORLD_HAS(world, entity, PAIR(rel, target)) then
1879
+ -- the pair id only keeps the target's index: a target deleted and
1880
+ -- recycled in the same frame aliases the live pair, so the pair must
1881
+ -- resolve back to this exact generation to count as present
1882
+ local id = PAIR(rel, target)
1883
+ if WORLD_HAS(world, entity, id) and PAIR_SECOND(world, id) == target then
1880
1884
  if is_component then
1881
1885
  local changed = bucket.changed[rel]
1882
1886
  if not changed then
@@ -1884,7 +1888,7 @@ function push_relation_updates(
1884
1888
  bucket.changed[rel] = changed
1885
1889
  end
1886
1890
 
1887
- local value = WORLD_GET(world, entity, PAIR(rel, target))
1891
+ local value = WORLD_GET(world, entity, id)
1888
1892
  table.insert(changed.targets, target)
1889
1893
  table.insert(changed.values, SET_VALUE(value))
1890
1894
  else
@@ -2959,8 +2963,7 @@ function server.resolve_dirty(self: Server)
2959
2963
  end
2960
2964
  end
2961
2965
 
2962
- self.shared =
2963
- shared.resolve_shared(self.world, self.components, self.registered_custom_ids, serdes, preprocessors)
2966
+ self.shared = shared.resolve_shared(self.world, self.components, self.registered_custom_ids, serdes, preprocessors)
2964
2967
  self.is_shared_dirty = false
2965
2968
  end
2966
2969
 
@@ -1 +1 @@
1
- return "v0.4.0-rc.4"
1
+ return "v0.4.0-rc.5"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rbxts/replecs",
3
- "version": "0.4.0-rc.4",
3
+ "version": "0.4.0-rc.5",
4
4
  "description": "Replication library for Jecs",
5
5
  "main": "out/init.luau",
6
6
  "types": "out/index.d.ts",