Skip to content

Commit

Permalink
Prevent tracking links that only connect an entity to itself
Browse files Browse the repository at this point in the history
No reason to link an entity to itself, also prevents an error
Most prominently this occurred from constraining a ragdoll to itself
  • Loading branch information
LiddulBOFH committed Jun 10, 2024
1 parent 3252785 commit cea75d5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lua/cfw/core/connectivity_sv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ function CFW.connect(a, b)
-- If a link already exists, add to the link counter
-- If not, create a new link between the two entities and resolve their contraptions

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

local link = a:GetLink(b)

if link then
Expand Down Expand Up @@ -61,6 +63,8 @@ function CFW.connect(a, b)
end

function CFW.disconnect(entA, indexB)
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

local link = entA._links[indexB]
local contraptionPopped = link:Sub()

Expand Down

0 comments on commit cea75d5

Please sign in to comment.