Skip to content

Commit 1f81873

Browse files
committed
Fixed annoying missing ENT._links table error
1 parent 0a31f7e commit 1f81873

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

lua/cfw/core/connectivity_sv.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ local function floodFill(source, sinkIndex)
1313

1414
if entIndex == sinkIndex then return true, closed end
1515

16-
for neighborIndex, _ in pairs(Entity(entIndex)._links) do -- neighborIndex, neighborLink
16+
for neighborIndex in pairs(Entity(entIndex)._links) do -- neighborIndex, neighborLink
1717
if not closed[neighborIndex] then
1818
open[neighborIndex] = true
1919
end

lua/cfw/core/parenting_sv.lua

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,18 @@ hook.Add("Initialize", "CFW", function()
9292
end)
9393

9494
hook.Remove("Initialize", "CFW")
95-
end)
95+
end)
96+
97+
-- In order to prevent NULL entities flooding the ENT._links table, we'll just get rid of them before they get removed
98+
-- This is a fix for a really annoying issue that was showing up in multiple different ways
99+
hook.Add("EntityRemoved", "cfw.entityRemoved", function(ent)
100+
if not IsValid(ent) then return end
101+
102+
local links = ent:GetLinks()
103+
104+
if not links then return end
105+
106+
for index in pairs(links) do
107+
disconnect(ent, index)
108+
end
109+
end)

0 commit comments

Comments
 (0)