Skip to content

Commit

Permalink
Fix NULL error
Browse files Browse the repository at this point in the history
  • Loading branch information
Astralcircle authored Nov 8, 2024
1 parent 14a2832 commit d74df0a
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lua/webaudio/receiver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -329,13 +329,16 @@ function updateObject(id, modify_enum, handle_bass, inside_net)
self.parented = net.ReadBool()
if self.parented then
local ent = net.ReadEntity()
self.parent = ent
if self.pos ~= nil then
-- We've initialized and received a changed position before
self.parent_pos = ent:WorldToLocal(self.pos)
else
-- self.pos hasn't been touched, play the sound at the entity's position.
self.parent_pos = nil

if IsValid(ent) then
self.parent = ent
if self.pos ~= nil then
-- We've initialized and received a changed position before
self.parent_pos = ent:WorldToLocal(self.pos)
else
-- self.pos hasn't been touched, play the sound at the entity's position.
self.parent_pos = nil
end
end
else
self.parent = nil
Expand Down

0 comments on commit d74df0a

Please sign in to comment.