mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-27 10:20:03 +00:00
Index is not a stable pointer
This commit is contained in:
parent
b1a2bc48a7
commit
d3b032666b
1 changed files with 9 additions and 9 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue