Fixed issue where fastmode connections wouldn't properly be removed

This commit is contained in:
Ryan Ward 2022-12-30 15:22:37 -05:00
parent 8c3d66a7b1
commit 7ea6873c1f

View File

@ -246,7 +246,11 @@ function multi:newConnection(protect,func,kill)
function c:Unconnect(conn) function c:Unconnect(conn)
if conn.fast then if conn.fast then
table.remove(fast,conn.ind) for i = 1, #fast do
if conn.ref == fast[i] then
table.remove(fast, i)
end
end
elseif conn.Destroy then elseif conn.Destroy then
conn:Destroy() conn:Destroy()
end end
@ -261,7 +265,7 @@ function multi:newConnection(protect,func,kill)
end end
function self:Connect(func) function self:Connect(func)
table.insert(fast, func) table.insert(fast, func)
local temp = {fast = true, ind = #fast} local temp = {fast = true}
setmetatable(temp,{ setmetatable(temp,{
__call=function(s,...) __call=function(s,...)
return self:Connect(...) return self:Connect(...)
@ -279,6 +283,7 @@ function multi:newConnection(protect,func,kill)
rawset(t,k,v) rawset(t,k,v)
end, end,
}) })
temp.ref = func
return temp return temp
end end
return self return self
@ -337,6 +342,7 @@ function multi:newConnection(protect,func,kill)
end end
function temp:Destroy() function temp:Destroy()
multi.print("Calling Destroy on a connection link is deprecated and will be removed in v16.0.0")
for i=#call_funcs,1,-1 do for i=#call_funcs,1,-1 do
if call_funcs[i]~=nil then if call_funcs[i]~=nil then
if call_funcs[i]==self.func then if call_funcs[i]==self.func then