Skip to content

Commit 14d289b

Browse files
committed
Didn't check for PreParented here
1 parent ac7cc2b commit 14d289b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lua/cfw/core/parenting_sv.lua

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ hook.Add("Initialize", "CFW", function()
5656
local detour = detours[newParent:GetClass()]
5757

5858
-- Store savedParent so we can do CFW_PreParented and CFW_OnParented later on the actual target
59-
if newParent.CFW_OnParented then
59+
if newParent.CFW_OnParented or newParent.CFW_PreParented then
6060
savedParent = newParent
6161
end
6262

@@ -71,8 +71,10 @@ hook.Add("Initialize", "CFW", function()
7171
-- Block parenting to self (why doesn't this just happen earlier on?? that case would never be valid!)
7272
if self == newParent then return end
7373

74+
local validSavedParent = IsValid(savedParent)
75+
7476
-- Check if the parent is willing to accept this child or not
75-
if IsValid(savedParent) and savedParent.CFW_PreParented and savedParent:CFW_PreParented(self) == false then
77+
if validSavedParent and savedParent.CFW_PreParented and savedParent:CFW_PreParented(self) == false then
7678
return
7779
end
7880

@@ -87,7 +89,7 @@ hook.Add("Initialize", "CFW", function()
8789
setParent(self, newParent, newAttach, ...)
8890

8991
-- Hook for post-new-child
90-
if IsValid(savedParent) then
92+
if validSavedParent and savedParent.CFW_OnParented then
9193
savedParent:CFW_OnParented(self, true)
9294
end
9395

0 commit comments

Comments
 (0)