Skip to content

Commit d996efb

Browse files
committed
Run constraint.GetAllConstrainedEntities after timer
1 parent 3b233ed commit d996efb

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lua/fpp/server/ownability.lua

+6-6
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,11 @@ function FPP.RecalculateConstrainedEntities(players, entities)
499499
end
500500

501501
local entMem = {}
502-
local function constraintRemovedTimer(ent1, ent2, constrainedEnts)
503-
if not IsValid(ent1) and not IsValid(ent2) or not constrainedEnts then return end
502+
local function constraintRemovedTimer(ent1, ent2)
503+
if not IsValid(ent1) and not IsValid(ent2) then return end
504+
505+
local constrainedEnts = constraint.GetAllConstrainedEntities(ent1)
506+
if not constrainedEnts then return end
504507

505508
FPP.RecalculateConstrainedEntities(player.GetAll(), constrainedEnts)
506509
entMem = {}
@@ -516,10 +519,7 @@ local function handleConstraintRemoved(ent)
516519
entMem[ent1] = true
517520
entMem[ent2] = true
518521

519-
-- the constraint is still there, so this includes ent2's constraints
520-
local constrainedEnts = constraint.GetAllConstrainedEntities(ent1)
521-
522-
timer.Create("FPP_ConstraintRemovedTimer", 0, 1, function() constraintRemovedTimer(ent1, ent2, constrainedEnts) end)
522+
timer.Create("FPP_ConstraintRemovedTimer", 0, 1, function() constraintRemovedTimer(ent1, ent2) end)
523523
end
524524

525525
local function onEntityRemoved(ent)

0 commit comments

Comments
 (0)