mirror of
https://github.com/wiremod/wire.git
synced 2025-03-04 03:03:04 -05:00
Add nil check for ports (#3254)
This commit is contained in:
parent
7d156f3a5f
commit
158ec276c6
@ -616,26 +616,30 @@ if SERVER then
|
||||
|
||||
function WireLib._SetInputs(ent)
|
||||
local eid = ent:EntIndex()
|
||||
local inputs = ent.Inputs
|
||||
if not inputs then return end
|
||||
|
||||
local ent_input_array = {}
|
||||
ents_with_inputs[eid] = ent_input_array
|
||||
|
||||
for Name, CurPort in pairs_sortvalues(ent.Inputs, WireLib.PortComparator) do
|
||||
for Name, CurPort in pairs_sortvalues(inputs, WireLib.PortComparator) do
|
||||
ent_input_array[#ent_input_array+1] = { Name, CurPort.Type, CurPort.Desc or "", CurPort.Num }
|
||||
end
|
||||
SendPortInfo(WirePortQueue, eid, PORT_TYPE_INPUT, ent.Inputs)
|
||||
SendPortInfo(WirePortQueue, eid, PORT_TYPE_INPUT, inputs)
|
||||
end
|
||||
|
||||
function WireLib._SetOutputs(ent)
|
||||
local eid = ent:EntIndex()
|
||||
local outputs = ent.Outputs
|
||||
if not outputs then return end
|
||||
|
||||
local ent_output_array = {}
|
||||
ents_with_outputs[eid] = ent_output_array
|
||||
|
||||
for Name, CurPort in pairs_sortvalues(ent.Outputs, WireLib.PortComparator) do
|
||||
for Name, CurPort in pairs_sortvalues(outputs, WireLib.PortComparator) do
|
||||
ent_output_array[#ent_output_array+1] = { Name, CurPort.Type, CurPort.Desc or "", CurPort.Num }
|
||||
end
|
||||
SendPortInfo(WirePortQueue, eid, PORT_TYPE_OUTPUT, ent.Outputs)
|
||||
SendPortInfo(WirePortQueue, eid, PORT_TYPE_OUTPUT, outputs)
|
||||
end
|
||||
|
||||
function WireLib._SetLink(input)
|
||||
@ -645,10 +649,14 @@ if SERVER then
|
||||
hook.Add("PlayerInitialSpawn", "wire_ports", function(ply)
|
||||
local queue = WirePortQueue.plyqueues[ply]
|
||||
for eid, _ in pairs(ents_with_inputs) do
|
||||
SendPortInfo(queue, eid, PORT_TYPE_INPUT, Entity(eid).Inputs)
|
||||
local ports = Entity(eid).Inputs
|
||||
if not ports then continue end
|
||||
SendPortInfo(queue, eid, PORT_TYPE_INPUT, ports)
|
||||
end
|
||||
for eid, _ in pairs(ents_with_outputs) do
|
||||
SendPortInfo(queue, eid, PORT_TYPE_OUTPUT, Entity(eid).Outputs)
|
||||
local ports = Entity(eid).Outputs
|
||||
if not ports then continue end
|
||||
SendPortInfo(queue, eid, PORT_TYPE_OUTPUT, ports)
|
||||
end
|
||||
WirePortQueue:flushQueue(ply, queue)
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user