Skip to content

Commit

Permalink
Fixed annoying missing ENT._links table error
Browse files Browse the repository at this point in the history
  • Loading branch information
TwistedTail committed Jun 23, 2024
1 parent 0a31f7e commit 1f81873
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lua/cfw/core/connectivity_sv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ local function floodFill(source, sinkIndex)

if entIndex == sinkIndex then return true, closed end

for neighborIndex, _ in pairs(Entity(entIndex)._links) do -- neighborIndex, neighborLink
for neighborIndex in pairs(Entity(entIndex)._links) do -- neighborIndex, neighborLink
if not closed[neighborIndex] then
open[neighborIndex] = true
end
Expand Down
16 changes: 15 additions & 1 deletion lua/cfw/core/parenting_sv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,18 @@ hook.Add("Initialize", "CFW", function()
end)

hook.Remove("Initialize", "CFW")
end)
end)

-- In order to prevent NULL entities flooding the ENT._links table, we'll just get rid of them before they get removed
-- This is a fix for a really annoying issue that was showing up in multiple different ways
hook.Add("EntityRemoved", "cfw.entityRemoved", function(ent)
if not IsValid(ent) then return end

local links = ent:GetLinks()

if not links then return end

for index in pairs(links) do
disconnect(ent, index)
end
end)

0 comments on commit 1f81873

Please sign in to comment.