Handle cycles in deletion

This commit is contained in:
Ukendio 2024-08-14 01:15:04 +02:00
parent 49d5bd0d4a
commit 33f359a150
2 changed files with 18 additions and 0 deletions

View file

@ -908,6 +908,9 @@ do
for archetype_id in idr.cache do for archetype_id in idr.cache do
local compatibleArchetype = archetypes[archetype_id] local compatibleArchetype = archetypes[archetype_id]
if #compatibleArchetype.entities == 0 then
continue
end
local records = compatibleArchetype.records local records = compatibleArchetype.records
local skip = false local skip = false

View file

@ -847,6 +847,21 @@ TEST("world:delete", function()
CHECK(not world:contains(entity)) CHECK(not world:contains(entity))
end end
end end
do CASE "cycle"
local world = jecs.World.new()
local Likes = world:component()
world:add(Likes, jecs.Delete)
local bob = world:entity()
local alice = world:entity()
world:add(bob, pair(Likes, alice))
world:add(alice, pair(Likes, bob))
world:delete(bob)
CHECK(not world:contains(bob))
CHECK(not world:contains(alice))
end
end) end)
TEST("world:contains", function() TEST("world:contains", function()