Skip to content

Commit 1c72f11

Browse files
committed
small tweak to initial ownership setter for new ents
1 parent 8d00292 commit 1c72f11

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

lua/warden/ownership/sv_ownership.lua

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ timer.Create("WardenSendAllOwnerData", 120, 0, Warden._SendAllOwnerData)
151151

152152
local PLAYER = FindMetaTable("Player")
153153

154-
local function getInternalOwner(ent)
154+
local function setInitialOwner(ent)
155155
local owner = ent:GetInternalVariable("m_hOwnerEntity") or NULL
156156

157157
if owner == NULL then
@@ -166,9 +166,11 @@ local function getInternalOwner(ent)
166166
owner = ent:GetMoveParent() or NULL
167167
end
168168

169-
if owner == NULL then return end
170-
171-
return owner
169+
if owner == NULL then
170+
Warden.SetOwnerWorld(ent)
171+
else
172+
Warden.SetOwner(ent, owner)
173+
end
172174
end
173175

174176
hook.Add("OnEntityCreated", "Warden", function(ent)
@@ -186,12 +188,7 @@ hook.Add("OnEntityCreated", "Warden", function(ent)
186188
end
187189

188190
if not Warden.GetOwner(ent) then
189-
local owner = getInternalOwner(ent)
190-
if owner then
191-
Warden.SetOwner(ent, owner)
192-
else
193-
Warden.SetOwnerWorld(ent)
194-
end
191+
setInitialOwner(ent)
195192
end
196193
end)
197194
end)

0 commit comments

Comments
 (0)