Skip to content

Commit

Permalink
Fix linking netcode (#1698)
Browse files Browse the repository at this point in the history
  • Loading branch information
thegrb93 authored Apr 6, 2024
1 parent 9ac9580 commit fc173e2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
10 changes: 6 additions & 4 deletions lua/entities/starfall_processor/cl_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,13 @@ net.Receive("starfall_processor_link", function()
local component, proc

SF.WaitForEntity(componenti, componentci, function(e)
component = e if component and proc then SF.LinkEnt(component, proc) end
end)
SF.WaitForEntity(proci, procci, function(e)
proc = e if component and proc then SF.LinkEnt(component, proc) end
component = e if component and (proc or proci==0) then SF.LinkEnt(component, proc) end
end)
if proci~=0 then
SF.WaitForEntity(proci, procci, function(e)
proc = e if component and proc then SF.LinkEnt(component, proc) end
end)
end
end)

net.Receive("starfall_processor_kill", function()
Expand Down
9 changes: 8 additions & 1 deletion lua/entities/starfall_processor/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,14 @@ function SF.LinkEnt(self, ent, transmit)
if SERVER and (changed or transmit) then
net.Start("starfall_processor_link")
net.WriteUInt(self:EntIndex(), 16)
net.WriteUInt(IsValid(ent) and ent:EntIndex() or 0, 16)
net.WriteUInt(self:GetCreationID(), 32)
if IsValid(ent) then
net.WriteUInt(ent:EntIndex(), 16)
net.WriteUInt(ent:GetCreationID(), 32)
else
net.WriteUInt(0, 16)
net.WriteUInt(0, 32)
end
if transmit then net.Send(transmit) else net.Broadcast() end
end
end
Expand Down

0 comments on commit fc173e2

Please sign in to comment.