From 3ff85ccf591c9a6af8d30727884b364f4c89d59a Mon Sep 17 00:00:00 2001 From: ShiroKSH Date: Thu, 9 Jul 2026 18:49:18 +0300 Subject: [PATCH 1/7] fix: keep reviewed wire runtime fixes --- addon.json | 2 +- lua/entities/gmod_wire_customprop/shared.lua | 4 ++-- lua/entities/gmod_wire_expression2/core/cl_files.lua | 5 +++-- lua/entities/gmod_wire_expression2/core/signal.lua | 8 +++++--- lua/wire/fpga_gates/execution.lua | 8 ++++---- lua/wire/server/sents_registry.lua | 12 ++++++------ lua/wire/server/wirelib.lua | 5 ++++- lua/wire/wirenet.lua | 10 +++++++--- 8 files changed, 32 insertions(+), 22 deletions(-) diff --git a/addon.json b/addon.json index dc706894f9..d50f9dd2ff 100644 --- a/addon.json +++ b/addon.json @@ -15,7 +15,7 @@ "git-hooks-pre-commit", "gitrid.sh", "LICENSE", - "wiremod.*" + "wiremod.*", "benchmark_*" ] } diff --git a/lua/entities/gmod_wire_customprop/shared.lua b/lua/entities/gmod_wire_customprop/shared.lua index 97a62c2be5..22264dff67 100644 --- a/lua/entities/gmod_wire_customprop/shared.lua +++ b/lua/entities/gmod_wire_customprop/shared.lua @@ -58,8 +58,8 @@ return { classname = "gmod_wire_customprop", readReliableEntity = function(callback) - index = net.ReadUInt(16) - creationIndex = net.ReadUInt(32) + local index = net.ReadUInt(16) + local creationIndex = net.ReadUInt(32) local startTime = CurTime() local function check() diff --git a/lua/entities/gmod_wire_expression2/core/cl_files.lua b/lua/entities/gmod_wire_expression2/core/cl_files.lua index 0cf2a1126e..714c137fac 100644 --- a/lua/entities/gmod_wire_expression2/core/cl_files.lua +++ b/lua/entities/gmod_wire_expression2/core/cl_files.lua @@ -98,8 +98,9 @@ net.Receive( "wire_expression2_request_list", function() end end for _,fop in pairs(folders) do - net.WriteUInt(#fop, 16) - net.WriteData(fop .. "/") + local folder = fop .. "/" + net.WriteUInt(#folder, 16) + net.WriteData(folder) end net.SendToServer() end) diff --git a/lua/entities/gmod_wire_expression2/core/signal.lua b/lua/entities/gmod_wire_expression2/core/signal.lua index 3a337a18e3..bf91263fa5 100644 --- a/lua/entities/gmod_wire_expression2/core/signal.lua +++ b/lua/entities/gmod_wire_expression2/core/signal.lua @@ -241,8 +241,8 @@ __e2setcost(20) --- sends signal S to chips owned by the given player, multiple calls for different players do not overwrite each other e2function void signalSendToPlayer(string name, entity player) - if not IsValid(player) then return end - broadcastSignal(self.data.signalgroup, name, 1, self.entity, player) + if not IsValid(player) or not player:IsPlayer() then return end + broadcastSignal(self.data.signalgroup, name, 1, self.entity, player:UniqueID()) end --[[************************************************************************]]-- @@ -253,6 +253,8 @@ registerCallback("construct",function(self) end) registerCallback("destruct",function(self) + local receiverid = self.entity:EntIndex() + -- loop through all scopes, ... for scope,groups in pairs_ac(scopes) do -- ... all groups ... @@ -260,7 +262,7 @@ registerCallback("destruct",function(self) -- ... and all signals ... for name, contexts in pairs_ac(signals) do -- to remove all signals the chip registered for. - contexts[self] = nil + contexts[receiverid] = nil end end end diff --git a/lua/wire/fpga_gates/execution.lua b/lua/wire/fpga_gates/execution.lua index a2b95c7da3..3afa9a870a 100644 --- a/lua/wire/fpga_gates/execution.lua +++ b/lua/wire/fpga_gates/execution.lua @@ -229,7 +229,7 @@ FPGAGateActions["execution-previous-normal"] = { gate.memory = 0 end, postExecution = function(gate) - local changed = gate.value != gate.memory + local changed = gate.value ~= gate.memory gate.value = gate.memory return changed end, @@ -254,7 +254,7 @@ FPGAGateActions["execution-previous-vector"] = { gate.memory = Vector(0, 0, 0) end, postExecution = function(gate) - local changed = gate.value != gate.memory + local changed = gate.value ~= gate.memory gate.value = gate.memory return changed end, @@ -279,7 +279,7 @@ FPGAGateActions["execution-previous-angle"] = { gate.memory = Angle(0, 0, 0) end, postExecution = function(gate) - local changed = gate.value != gate.memory + local changed = gate.value ~= gate.memory gate.value = gate.memory return changed end, @@ -304,7 +304,7 @@ FPGAGateActions["execution-previous-string"] = { gate.memory = "" end, postExecution = function(gate) - local changed = gate.value != gate.memory + local changed = gate.value ~= gate.memory gate.value = gate.memory return changed end, diff --git a/lua/wire/server/sents_registry.lua b/lua/wire/server/sents_registry.lua index 8ffc2cfdf4..4514b69ad4 100644 --- a/lua/wire/server/sents_registry.lua +++ b/lua/wire/server/sents_registry.lua @@ -1137,8 +1137,8 @@ register("gmod_wire_value", { VECTOR2 = function(val, e2TypeID) if e2TypeID == TYPE_TABLE and #val >= 2 and isnumber(val[1]) and isnumber(val[2]) then return val[1]..", "..val[2] end if e2TypeID == TYPE_STRING then - local x,y,z = string.match( val, "^ *([^%s,]+) *, *([^%s,]+) *$" ) - if x and y and z then return x..", "..y..", "..z end + local x,y = string.match( val, "^ *([^%s,]+) *, *([^%s,]+) *$" ) + if x and y then return x..", "..y end end return nil @@ -1201,7 +1201,7 @@ register("gmod_wire_value", { elseif e2TypeID == TYPE_VECTOR then val = {"VECTOR", castE2TypeToWireValueType["VECTOR"](val, e2TypeID)} elseif e2TypeID == TYPE_ANGLE then val = {"ANGLE", castE2TypeToWireValueType["ANGLE"](val, e2TypeID)} elseif e2TypeID == TYPE_STRING then val = {"STRING", castE2TypeToWireValueType["STRING"](val, e2TypeID)} - else return "Incorrect 'value' parameter #"..i.." type! Expected table (Ex. table(\"normal\", 0)). Got: "..type( steamid ) end + else return "Incorrect 'value' parameter #"..i.." type! Expected table (Ex. table(\"normal\", 0)). Got: "..type( val ) end elseif not isnumber(val[1]) then -- Plain table if TypeID(val[1]) ~= TYPE_STRING then return "Incorrect 'value' parameter #"..i.."[1] type! Expected string ('NORMAL/VECTOR/VECTOR2/VECTOR4/ANGLE/STRING'). Got: "..type( val ) end @@ -1214,15 +1214,15 @@ register("gmod_wire_value", { end val = {wireValueType, CastFunc(val[2], TypeID(val[2]))} elseif #val == 2 then -- vector2 - local tempVal = castE2TypeToWireValueType["VECTOR2"](val[2], typeID(val[2])) + local tempVal = castE2TypeToWireValueType["VECTOR2"](val, TypeID(val)) if not tempVal then return "Incorrect 'value' parameter #"..i.." value! Expected 'VECTOR2'. Got: "..tostring(val[2]) end val = {"VECTOR2", tempVal} elseif #val==4 then -- vector4 - local tempVal = castE2TypeToWireValueType["VECTOR4"](val[2], typeID(val[2])) - if not tempVal then return "Incorrect 'value' parameter #"..i.." value! Expected 'VECTOR2'. Got: "..tostring(val[2]) end + local tempVal = castE2TypeToWireValueType["VECTOR4"](val, TypeID(val)) + if not tempVal then return "Incorrect 'value' parameter #"..i.." value! Expected 'VECTOR4'. Got: "..tostring(val[2]) end val = {"VECTOR4", tempVal} else diff --git a/lua/wire/server/wirelib.lua b/lua/wire/server/wirelib.lua index 739c8939a3..b14e285e3a 100644 --- a/lua/wire/server/wirelib.lua +++ b/lua/wire/server/wirelib.lua @@ -1180,7 +1180,10 @@ function WireLib.CanModel(ply, model, skin) end function WireLib.MakeWireEnt( pl, Data, ... ) - Data.Class = scripted_ents.Get(Data.Class).ClassName + local sent = scripted_ents.Get(Data.Class) + if not sent or not sent.ClassName then return false end + + Data.Class = sent.ClassName if IsValid(pl) and not pl:CheckLimit(Data.Class:sub(6).."s") then return false end if Data.Model and not WireLib.CanModel(pl, Data.Model, Data.Skin) then return false end diff --git a/lua/wire/wirenet.lua b/lua/wire/wirenet.lua index e4fe6a1672..0fa82719da 100644 --- a/lua/wire/wirenet.lua +++ b/lua/wire/wirenet.lua @@ -49,10 +49,14 @@ if SERVER then local data = table.concat(tbl) if #data < 4096 then - data = util.Compress(data) + local compressed = util.Compress(data) net.WriteBool(false) - net.WriteUInt(#data, 12) - net.WriteData(data) + if compressed then + net.WriteUInt(#compressed, 12) + net.WriteData(compressed) + else + net.WriteUInt(0, 12) + end else net.WriteBool(true) net.WriteStream(data, nil, false) From a2a9973b384ea5b83d29c41a9a7bbedbe1258d2c Mon Sep 17 00:00:00 2001 From: ShiroKSH Date: Thu, 9 Jul 2026 19:17:27 +0300 Subject: [PATCH 2/7] fix: drop fpga operator change --- lua/wire/fpga_gates/execution.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lua/wire/fpga_gates/execution.lua b/lua/wire/fpga_gates/execution.lua index 3afa9a870a..a2b95c7da3 100644 --- a/lua/wire/fpga_gates/execution.lua +++ b/lua/wire/fpga_gates/execution.lua @@ -229,7 +229,7 @@ FPGAGateActions["execution-previous-normal"] = { gate.memory = 0 end, postExecution = function(gate) - local changed = gate.value ~= gate.memory + local changed = gate.value != gate.memory gate.value = gate.memory return changed end, @@ -254,7 +254,7 @@ FPGAGateActions["execution-previous-vector"] = { gate.memory = Vector(0, 0, 0) end, postExecution = function(gate) - local changed = gate.value ~= gate.memory + local changed = gate.value != gate.memory gate.value = gate.memory return changed end, @@ -279,7 +279,7 @@ FPGAGateActions["execution-previous-angle"] = { gate.memory = Angle(0, 0, 0) end, postExecution = function(gate) - local changed = gate.value ~= gate.memory + local changed = gate.value != gate.memory gate.value = gate.memory return changed end, @@ -304,7 +304,7 @@ FPGAGateActions["execution-previous-string"] = { gate.memory = "" end, postExecution = function(gate) - local changed = gate.value ~= gate.memory + local changed = gate.value != gate.memory gate.value = gate.memory return changed end, From dba9842b329657a3f451674ad5be76b1897c95b2 Mon Sep 17 00:00:00 2001 From: ShiroKSH Date: Thu, 9 Jul 2026 20:31:10 +0300 Subject: [PATCH 3/7] chore: split passed review fixes --- addon.json | 2 +- lua/entities/gmod_wire_customprop/shared.lua | 4 ++-- lua/wire/server/sents_registry.lua | 12 ++++++------ lua/wire/server/wirelib.lua | 5 +---- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/addon.json b/addon.json index d50f9dd2ff..dc706894f9 100644 --- a/addon.json +++ b/addon.json @@ -15,7 +15,7 @@ "git-hooks-pre-commit", "gitrid.sh", "LICENSE", - "wiremod.*", + "wiremod.*" "benchmark_*" ] } diff --git a/lua/entities/gmod_wire_customprop/shared.lua b/lua/entities/gmod_wire_customprop/shared.lua index 22264dff67..97a62c2be5 100644 --- a/lua/entities/gmod_wire_customprop/shared.lua +++ b/lua/entities/gmod_wire_customprop/shared.lua @@ -58,8 +58,8 @@ return { classname = "gmod_wire_customprop", readReliableEntity = function(callback) - local index = net.ReadUInt(16) - local creationIndex = net.ReadUInt(32) + index = net.ReadUInt(16) + creationIndex = net.ReadUInt(32) local startTime = CurTime() local function check() diff --git a/lua/wire/server/sents_registry.lua b/lua/wire/server/sents_registry.lua index 4514b69ad4..8ffc2cfdf4 100644 --- a/lua/wire/server/sents_registry.lua +++ b/lua/wire/server/sents_registry.lua @@ -1137,8 +1137,8 @@ register("gmod_wire_value", { VECTOR2 = function(val, e2TypeID) if e2TypeID == TYPE_TABLE and #val >= 2 and isnumber(val[1]) and isnumber(val[2]) then return val[1]..", "..val[2] end if e2TypeID == TYPE_STRING then - local x,y = string.match( val, "^ *([^%s,]+) *, *([^%s,]+) *$" ) - if x and y then return x..", "..y end + local x,y,z = string.match( val, "^ *([^%s,]+) *, *([^%s,]+) *$" ) + if x and y and z then return x..", "..y..", "..z end end return nil @@ -1201,7 +1201,7 @@ register("gmod_wire_value", { elseif e2TypeID == TYPE_VECTOR then val = {"VECTOR", castE2TypeToWireValueType["VECTOR"](val, e2TypeID)} elseif e2TypeID == TYPE_ANGLE then val = {"ANGLE", castE2TypeToWireValueType["ANGLE"](val, e2TypeID)} elseif e2TypeID == TYPE_STRING then val = {"STRING", castE2TypeToWireValueType["STRING"](val, e2TypeID)} - else return "Incorrect 'value' parameter #"..i.." type! Expected table (Ex. table(\"normal\", 0)). Got: "..type( val ) end + else return "Incorrect 'value' parameter #"..i.." type! Expected table (Ex. table(\"normal\", 0)). Got: "..type( steamid ) end elseif not isnumber(val[1]) then -- Plain table if TypeID(val[1]) ~= TYPE_STRING then return "Incorrect 'value' parameter #"..i.."[1] type! Expected string ('NORMAL/VECTOR/VECTOR2/VECTOR4/ANGLE/STRING'). Got: "..type( val ) end @@ -1214,15 +1214,15 @@ register("gmod_wire_value", { end val = {wireValueType, CastFunc(val[2], TypeID(val[2]))} elseif #val == 2 then -- vector2 - local tempVal = castE2TypeToWireValueType["VECTOR2"](val, TypeID(val)) + local tempVal = castE2TypeToWireValueType["VECTOR2"](val[2], typeID(val[2])) if not tempVal then return "Incorrect 'value' parameter #"..i.." value! Expected 'VECTOR2'. Got: "..tostring(val[2]) end val = {"VECTOR2", tempVal} elseif #val==4 then -- vector4 - local tempVal = castE2TypeToWireValueType["VECTOR4"](val, TypeID(val)) - if not tempVal then return "Incorrect 'value' parameter #"..i.." value! Expected 'VECTOR4'. Got: "..tostring(val[2]) end + local tempVal = castE2TypeToWireValueType["VECTOR4"](val[2], typeID(val[2])) + if not tempVal then return "Incorrect 'value' parameter #"..i.." value! Expected 'VECTOR2'. Got: "..tostring(val[2]) end val = {"VECTOR4", tempVal} else diff --git a/lua/wire/server/wirelib.lua b/lua/wire/server/wirelib.lua index b14e285e3a..739c8939a3 100644 --- a/lua/wire/server/wirelib.lua +++ b/lua/wire/server/wirelib.lua @@ -1180,10 +1180,7 @@ function WireLib.CanModel(ply, model, skin) end function WireLib.MakeWireEnt( pl, Data, ... ) - local sent = scripted_ents.Get(Data.Class) - if not sent or not sent.ClassName then return false end - - Data.Class = sent.ClassName + Data.Class = scripted_ents.Get(Data.Class).ClassName if IsValid(pl) and not pl:CheckLimit(Data.Class:sub(6).."s") then return false end if Data.Model and not WireLib.CanModel(pl, Data.Model, Data.Skin) then return false end From 5fe8d32915c938e092734e23a827e032551c9808 Mon Sep 17 00:00:00 2001 From: ShiroKSH Date: Thu, 9 Jul 2026 22:01:41 +0300 Subject: [PATCH 4/7] fix: keep wirenet fallback inline --- lua/wire/wirenet.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lua/wire/wirenet.lua b/lua/wire/wirenet.lua index 0fa82719da..cf05ec93d2 100644 --- a/lua/wire/wirenet.lua +++ b/lua/wire/wirenet.lua @@ -51,11 +51,14 @@ if SERVER then if #data < 4096 then local compressed = util.Compress(data) net.WriteBool(false) - if compressed then + if compressed and #compressed < 4096 then + net.WriteBool(true) net.WriteUInt(#compressed, 12) net.WriteData(compressed) else - net.WriteUInt(0, 12) + net.WriteBool(false) + net.WriteUInt(#data, 12) + net.WriteData(data) end else net.WriteBool(true) @@ -182,7 +185,10 @@ else -- CLIENT stripstrings(begin, last, lens, data) end) else - stripstrings(begin, last, lens, util.Decompress(net.ReadData(net.ReadUInt(12)))) + local compressed = net.ReadBool() + local data = net.ReadData(net.ReadUInt(12)) + if compressed then data = util.Decompress(data) end + stripstrings(begin, last, lens, data) end end From 452f57412fc23530d3b2892d0ad2f4b1744e2a71 Mon Sep 17 00:00:00 2001 From: ShiroKSH Date: Thu, 9 Jul 2026 22:07:15 +0300 Subject: [PATCH 5/7] fix: remove unused signal helper --- lua/entities/gmod_wire_expression2/core/signal.lua | 3 --- 1 file changed, 3 deletions(-) diff --git a/lua/entities/gmod_wire_expression2/core/signal.lua b/lua/entities/gmod_wire_expression2/core/signal.lua index bf91263fa5..29c732d381 100644 --- a/lua/entities/gmod_wire_expression2/core/signal.lua +++ b/lua/entities/gmod_wire_expression2/core/signal.lua @@ -91,9 +91,6 @@ local function broadcastSignal(group, name, scope, sender, filter_player) end end ---local function table_IsEmpty(t) return not pairs(t)(t) end -local function table_IsEmpty(t) return not next(t) end - local function setGroup(self, group) -- set the current group to the new group self.data.signalgroup = group From 44fe4aa233b6ecb4f7730034365cecc03dfcc2ba Mon Sep 17 00:00:00 2001 From: ShiroKSH Date: Thu, 9 Jul 2026 22:47:41 +0300 Subject: [PATCH 6/7] fix: align reviewed network payload changes --- lua/entities/gmod_wire_expression2/core/cl_files.lua | 10 +++++++--- lua/wire/wirenet.lua | 12 +++--------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/lua/entities/gmod_wire_expression2/core/cl_files.lua b/lua/entities/gmod_wire_expression2/core/cl_files.lua index 714c137fac..724580a8b0 100644 --- a/lua/entities/gmod_wire_expression2/core/cl_files.lua +++ b/lua/entities/gmod_wire_expression2/core/cl_files.lua @@ -90,13 +90,17 @@ net.Receive( "wire_expression2_request_list", function() net.Start("wire_expression2_file_list") local files, folders = file.Find( dir .. "*","DATA" ) - net.WriteUInt(#files + #folders, 16) + local txtfiles = {} for _,fop in pairs(files) do if string.GetExtensionFromFilename( fop ) == "txt" then - net.WriteUInt(#fop, 16) - net.WriteData(fop) + txtfiles[#txtfiles + 1] = fop end end + net.WriteUInt(#txtfiles + #folders, 16) + for _,fop in pairs(txtfiles) do + net.WriteUInt(#fop, 16) + net.WriteData(fop) + end for _,fop in pairs(folders) do local folder = fop .. "/" net.WriteUInt(#folder, 16) diff --git a/lua/wire/wirenet.lua b/lua/wire/wirenet.lua index cf05ec93d2..74e990d59b 100644 --- a/lua/wire/wirenet.lua +++ b/lua/wire/wirenet.lua @@ -52,13 +52,10 @@ if SERVER then local compressed = util.Compress(data) net.WriteBool(false) if compressed and #compressed < 4096 then - net.WriteBool(true) net.WriteUInt(#compressed, 12) net.WriteData(compressed) else - net.WriteBool(false) - net.WriteUInt(#data, 12) - net.WriteData(data) + net.WriteUInt(0, 12) end else net.WriteBool(true) @@ -185,10 +182,7 @@ else -- CLIENT stripstrings(begin, last, lens, data) end) else - local compressed = net.ReadBool() - local data = net.ReadData(net.ReadUInt(12)) - if compressed then data = util.Decompress(data) end - stripstrings(begin, last, lens, data) + stripstrings(begin, last, lens, util.Decompress(net.ReadData(net.ReadUInt(12)))) end end @@ -217,4 +211,4 @@ function Net.Trivial.Receive(name, callback) update_handlers(name:lower(), callback) end -Net.Receivers = registered_handlers \ No newline at end of file +Net.Receivers = registered_handlers From 8c1dbef677f25f73289ea4297ba0e7dbeb4b2d7c Mon Sep 17 00:00:00 2001 From: ShiroKSH Date: Thu, 9 Jul 2026 22:51:24 +0300 Subject: [PATCH 7/7] fix: drop redundant compression size check --- lua/wire/wirenet.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/wire/wirenet.lua b/lua/wire/wirenet.lua index 74e990d59b..138fdb91dc 100644 --- a/lua/wire/wirenet.lua +++ b/lua/wire/wirenet.lua @@ -51,7 +51,7 @@ if SERVER then if #data < 4096 then local compressed = util.Compress(data) net.WriteBool(false) - if compressed and #compressed < 4096 then + if compressed then net.WriteUInt(#compressed, 12) net.WriteData(compressed) else