Skip to content

Commit cea75d5

Browse files
committed
Prevent tracking links that only connect an entity to itself
No reason to link an entity to itself, also prevents an error Most prominently this occurred from constraining a ragdoll to itself
1 parent 3252785 commit cea75d5

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lua/cfw/core/connectivity_sv.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ function CFW.connect(a, b)
2828
-- If a link already exists, add to the link counter
2929
-- If not, create a new link between the two entities and resolve their contraptions
3030

31+
if a == b then return end -- Should not happen normally, but ragdolls allow you to constrain to other bones on the same ragdoll, and it is the same entity. We'll head it off here since we don't want to track links that don't actually link anything
32+
3133
local link = a:GetLink(b)
3234

3335
if link then
@@ -61,6 +63,8 @@ function CFW.connect(a, b)
6163
end
6264

6365
function CFW.disconnect(entA, indexB)
66+
if entA:EntIndex() == indexB then return end -- Should not happen normally, but ragdolls allow you to constrain to other bones on the same ragdoll, and it is the same entity
67+
6468
local link = entA._links[indexB]
6569
local contraptionPopped = link:Sub()
6670

0 commit comments

Comments
 (0)