Skip to content

Fix small Wire runtime edge cases#3649

Draft
ShiroKSH wants to merge 7 commits into
wiremod:masterfrom
ShiroKSH:fix/reviewed-wire-runtime-fixes
Draft

Fix small Wire runtime edge cases#3649
ShiroKSH wants to merge 7 commits into
wiremod:masterfrom
ShiroKSH:fix/reviewed-wire-runtime-fixes

Conversation

@ShiroKSH

@ShiroKSH ShiroKSH commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

splited

remaining unsure changes

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is necessary.
The != operator is provided by garry's mod, we should have a gmod-based linter already in here.
Your LLM may not have context to understand that the language is a modified version to include c-style operators.

Make sure that changes like these don't appear in PRs as its considered a "style change" which is not necessary in a feature-based PR, more so a different PR would be required for this.

This can make histories difficult to view in blame as well, I suggest reverting this.

@ShiroKSH ShiroKSH Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok thanks thats not mine fix i deleted

@blueshank-gh

Copy link
Copy Markdown

Also if PR's are still in progress, i.e. your still finding things to change, you should make it a draft, its there to help you before releasing to the public to review.

@ShiroKSH ShiroKSH marked this pull request as draft July 9, 2026 16:18

@Grocel Grocel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please separate "Passed" and "OK" changes into a new PR. Keep the "Unsure" and questionable changes to this PR.

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())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not passed. As far as I have been told player:UniqueID() is not expected there. This needs testing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks correct

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright.

for name, contexts in pairs_ac(signals) do
-- to remove all signals the chip registered for.
contexts[self] = nil
contexts[receiverid] = nil

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not passed. I am too unsure about that one too. This needs testing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine, I guess.

Comment thread addon.json Outdated
"gitrid.sh",
"LICENSE",
"wiremod.*"
"wiremod.*",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passed.

Comment thread lua/wire/wirenet.lua
Comment on lines +52 to +59
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the receiver reflect these changes too? I don't see it in this PR.

Comment thread lua/wire/server/wirelib.lua Outdated
Comment on lines +1183 to +1186
local sent = scripted_ents.Get(Data.Class)
if not sent or not sent.ClassName then return false end

Data.Class = sent.ClassName

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passed.

Comment on lines +101 to +103
local folder = fop .. "/"
net.WriteUInt(#folder, 16)
net.WriteData(folder)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does the "other side" deal with the change? Was it somehow compensated? Can the hardcoded slash be removed or moved to the receiver?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trailing forward-slash was getting trimmed before but now it's not.

table.insert(plist.data, net.ReadData(net.ReadUInt(16)))

Should test that this change in behavior is ok.

There's another bug on line 95 I just noticed where non-txt files will cause a mismatch in amount of data written and number of files specified at line 93.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is tested, I would give it a pass.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested the file list roundtrip in GMod with file and folder entries. The folder keeps the trailing /, and the count now only includes the transmitted .txt files, so non-txt files do not shift the receiver.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thegrb93 What do you thing? It seems to be the only point left before passing.

Comment thread lua/wire/server/sents_registry.lua Outdated
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passed.

Comment thread lua/wire/server/sents_registry.lua Outdated
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passed.

Comment thread lua/wire/server/sents_registry.lua Outdated
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))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passed.

Comment thread lua/wire/server/sents_registry.lua Outdated
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

@Grocel Grocel Jul 9, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was steamid before? Strange. Looks ok, though.

@ShiroKSH

ShiroKSH commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

@Grocel splited, moved the passed review changes to #3650.

@ShiroKSH

ShiroKSH commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Pushed a small WireNet update so the handler-name update stays inline if compression fails or does not fit the 12-bit path.

Tested in GMod on gm_construct: signalSendToPlayer delivery, signal listener cleanup on chip removal, E2 file list roundtrip with file + folder entries, and WireLib.Net.Trivial normal/nil-compress/too-large-compress cases.

Should be ready for another look.

@ShiroKSH ShiroKSH marked this pull request as ready for review July 9, 2026 19:02
@ShiroKSH ShiroKSH requested a review from Grocel July 9, 2026 19:09
@ShiroKSH ShiroKSH marked this pull request as draft July 9, 2026 19:09
Comment thread lua/wire/wirenet.lua

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is all wrong. Please change it back to how it was in the first pr.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gets difficult to keep track of, lol.

Comment thread lua/wire/wirenet.lua Outdated
for name, contexts in pairs_ac(signals) do
-- to remove all signals the chip registered for.
contexts[self] = nil
contexts[receiverid] = nil

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine, I guess.

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())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright.

Comment thread lua/wire/wirenet.lua

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gets difficult to keep track of, lol.

Comment on lines +101 to +103
local folder = fop .. "/"
net.WriteUInt(#folder, 16)
net.WriteData(folder)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is tested, I would give it a pass.


--local function table_IsEmpty(t) return not pairs(t)(t) end
local function table_IsEmpty(t) return not next(t) end

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passed. But I would avoid adding more stuff during the review process. This change can stay in, though.

@blueshank-gh

blueshank-gh commented Jul 9, 2026

Copy link
Copy Markdown

@ShiroKSH once you feel everything about these guys have been addressed according to Grocel, simply change this to open state, and they can have the final say on merge, which from how this looks is 100% going to happen.

@ShiroKSH

ShiroKSH commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

once you feel everything about these guys have been addressed according to Grocel, simply change this to open state, and they can have the final say on merge, which from how this looks is 100% going to happen.

ye i knew ty <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants