Index is not a stable pointer
Some checks failed
analysis / Run Luau Analyze (push) Has been cancelled
unit-testing / Run Luau Tests (push) Has been cancelled

This commit is contained in:
Ukendio 2025-04-25 23:53:09 +02:00
parent b1a2bc48a7
commit d3b032666b

View file

@ -215,11 +215,11 @@ local function observers_add(world: jecs.World & { [string]: any }): PatchedWorl
end end
world:set(component, jecs.OnAdd, on_add) world:set(component, jecs.OnAdd, on_add)
end end
local max = #listeners + 1 table.insert(listeners, fn)
listeners[max] = fn
return function() return function()
local n = #listeners local n = #listeners
listeners[max] = listeners[n] local i = table.find(listeners, fn)
listeners[i] = listeners[n]
listeners[n] = nil listeners[n] = nil
end end
end end
@ -238,11 +238,11 @@ local function observers_add(world: jecs.World & { [string]: any }): PatchedWorl
end end
world:set(component, jecs.OnChange, on_change) world:set(component, jecs.OnChange, on_change)
end end
local max = #listeners + 1 table.insert(listeners, fn)
listeners[max] = fn
return function() return function()
local n = #listeners local n = #listeners
listeners[max] = listeners[n] local i = table.find(listeners, fn)
listeners[i] = listeners[n]
listeners[n] = nil listeners[n] = nil
end end
end end
@ -261,11 +261,11 @@ local function observers_add(world: jecs.World & { [string]: any }): PatchedWorl
end end
world:set(component, jecs.OnRemove, on_remove) world:set(component, jecs.OnRemove, on_remove)
end end
local max = #listeners + 1 table.insert(listeners, fn)
listeners[max] = fn
return function() return function()
local n = #listeners local n = #listeners
listeners[max] = listeners[n] local i = table.find(listeners, fn)
listeners[i] = listeners[n]
listeners[n] = nil listeners[n] = nil
end end
end end