Fix Wire runtime and tool handling edge cases#3648
Conversation
| end | ||
|
|
||
| local data = table.concat(tbl) | ||
| local compressed = util.Compress(data) |
There was a problem hiding this comment.
Either move this back into the if-branch or change the net.WriteStream to net.WriteStream(compressed, nil, true) and update the receive to add a decompress.
There was a problem hiding this comment.
Thanks @thegrb93, good catch. I moved compression back under the small-payload branch and kept the compressed-size guard before the 12-bit WriteUInt path; fallback still uses the existing raw WriteStream path.
There was a problem hiding this comment.
I think this conflicts with the other currently open CD PR.
| net.WriteBool(false) | ||
| net.WriteUInt(#data, 12) | ||
| net.WriteData(data) | ||
| local compressed = util.Compress(data) |
There was a problem hiding this comment.
This is not right. Are you just trying to add a check for if compressed is nil?
If compressed is nil, you can instead do
net.WriteBool(false)
net.WriteUInt(0, 12)
There was a problem hiding this comment.
Thanks @thegrb93, yes, I was only trying to guard the nil-compress case. Updated it to keep the inline compressed packet path: write false, then length/data when compression succeeds, or length 0 when it does not. No small-payload stream fallback now.
There was a problem hiding this comment.
local compressed = util.Compress(data) or "" might do the trick as well. But that depends on how it is handled on the other side.
There was a problem hiding this comment.
Good point @Grocel. Since the receive side branches on the bool and then reads the advertised length, I kept the nil case explicit as length 0 rather than substituting an empty compressed payload. It stays in the same inline path and avoids changing the stream protocol.
|
This really does look like an automated AI agent going around popular Gmod repo. |
| local folder = fop .. "/" | ||
| net.WriteUInt(#folder, 16) | ||
| net.WriteData(folder, #folder) |
There was a problem hiding this comment.
Is this needed to have the length data twice? Why did the old version (pre PR) had two length parameter? It is also not needed to set the length in net.WriteData as it automaticity takes it from the input string.
There was a problem hiding this comment.
Thanks @Grocel. The WriteUInt is the protocol length prefix for the server-side net.ReadData(net.ReadUInt(16)); the folder bug was that it wrote #fop before sending fop .. "/". You are right that the explicit second arg to net.WriteData is redundant with the current API, though. I kept it explicit while fixing the advertised length.
There was a problem hiding this comment.
Sending the advertised length separately is not needed, as WriteData already does it for you. According to the wiki You can still read the advertised using net.ReadUInt(16). Even more this seem to be the only place with a separately send length. Other places do not have these.
Edit: My bad, I got a bit confused. Your changes are fine.
There was a problem hiding this comment.
@Grocel I removed the redundant WriteData(..., len) args in 79b276f. I kept the WriteUInt though: WriteData does not put a length field into the message, its length arg only limits how many bytes from the string are written. This message sends multiple variable-length names, so the receiver still needs a per-entry boundary before ReadData.
| local index = net.ReadUInt(16) | ||
| local creationIndex = net.ReadUInt(32) |
There was a problem hiding this comment.
Nice find. Looks like that the old version had a global pollution
| for name, contexts in pairs_ac(signals) do | ||
| -- to remove all signals the chip registered for. | ||
| contexts[self] = nil | ||
| contexts[receiverid] = nil |
There was a problem hiding this comment.
Yeah, it is better to index by entity index than by entity object, as entity references in indexes are not being GC'd when they become null (being removed). Be careful to when doing this kind of changes, make sure to adjust every instance of such tables.
There was a problem hiding this comment.
Yep @Grocel, I checked the table use before changing this. runOnSignal stores by self.entity:EntIndex(), signal dispatch uses receiver IDs, and destruct was the odd cleanup path still indexing by context object.
| return changed | ||
| end, | ||
| } No newline at end of file | ||
| } |
There was a problem hiding this comment.
What, was that missing before?
There was a problem hiding this comment.
Yes @Grocel, the file was missing the final newline. The actual runtime fix there is the != to ~= replacement in the postExecution checks above.
| 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 |
There was a problem hiding this comment.
Nice find. This looks like an oversight from the distant past.
| TOOL.ClientConVar[ "model" ] = "models/jaanus/wiretool/wiretool_siren.mdl" | ||
| TOOL.ClientConVar[ "outColor" ] = "0" | ||
| TOOL.ClientConVar[ "range" ] = "2000" | ||
|
|
||
| function TOOL.BuildCPanel(panel) | ||
| WireToolHelpers.MakePresetControl(panel, "wire_colorer") | ||
| WireDermaExts.ModelSelect(panel, "wire_colorer_model", list.Get( "Wire_Laser_Tools_Models" ), 1, true) | ||
| panel:CheckBox("#WireColorerTool_outColor", "wire_colorer_outColor") | ||
| panel:NumSlider("#WireColorerTool_Range", "wire_colorer_Range", 1, 10000, 2) | ||
| panel:NumSlider("#WireColorerTool_Range", "wire_colorer_range", 1, 10000, 2) |
There was a problem hiding this comment.
I like that this PR fixes a lot oversights. Convars should always be lowercase.
| CreateConVar("sbox_wire_igniters_maxlen", 30) | ||
| CreateConVar("sbox_wire_igniters_allowtrgply",1) | ||
|
|
||
| function TOOL:GetConVars() | ||
| return self:GetClientNumber( "trgply" )~=0, self:GetClientNumber("range") | ||
| return self:GetClientNumber("trgply") ~= 0, self:GetClientNumber("range") | ||
| end |
There was a problem hiding this comment.
Linter changes and clean up, I guess.
There was a problem hiding this comment.
Yep @Grocel, this part is cleanup only; the behavior-relevant change in the file is the lowercase model cvar name.
| net.WriteBool(false) | ||
| net.WriteUInt(#data, 12) | ||
| net.WriteData(data) | ||
| local compressed = util.Compress(data) |
There was a problem hiding this comment.
local compressed = util.Compress(data) or "" might do the trick as well. But that depends on how it is handled on the other side.
| end | ||
|
|
||
| Net.Receivers = registered_handlers No newline at end of file | ||
| Net.Receivers = registered_handlers |
There was a problem hiding this comment.
What is that, where did this came from? Was it missing?
There was a problem hiding this comment.
Yes @Grocel, it was missing a trailing newline before. No behavior change; just editor/git normalization from touching the file. I can revert the whitespace if you would rather keep the diff tighter.
There was a problem hiding this comment.
Nevermind, it looked like that Net.Receivers = registered_handlers was missing.
There was a problem hiding this comment.
No worries, easy to miss in the diff. That one was just the EOF newline.
| "gitrid.sh", | ||
| "LICENSE", | ||
| "wiremod.*" | ||
| "wiremod.*", |
There was a problem hiding this comment.
Was this file ever used, e.g. by workshop uploads? Hard to imagine that it worked with the syntax error like that.
There was a problem hiding this comment.
Yeah @Grocel, I was not assuming the upload path, just noticed it is invalid JSON as-is. The comma only preserves the existing two ignore entries (wiremod.* and benchmark_*) so any consumer that parses it will not choke.
|
@ax255 fair concern. I know this PR touches several old corners at once, and I have been trimming anything that overlaps with other work or feels too noisy. The remaining changes are meant to be small concrete runtime/lint fixes; happy to split or drop parts if maintainers prefer. |
|
the automated slop dispensers have reached the wire repo too let's go |
:с im am sloop its sound like "not happy" |
finally got a real human response |
|
I would like to give this PR an honest and fair chance. Edit: It's over, no pass from me. |
| e2function void printCaption(string text, number duration) | ||
| send_caption(self, text, duration, false) | ||
| end No newline at end of file | ||
| end |
There was a problem hiding this comment.
Don't do unnecessary styling changes until it changes something behavior
@ShiroKSH: What are you even doing? |
checking public repos with me team and PR, clearly it's can be not good bt i do it and its all |
|
its insane to think that someone would go this low for a PR... as it is my personal opinion. for the future please in my opinion, do not just blind-side implementation with AI. |
|
I don't have a say in this obviously but I vote to have this PR closed for irresponsible usage of AI. |
I don't know why you think it isn't used with controls, but if that's what you think, buddy, that's your right. In today's world, we have to admit that AI and AI agents have long since become mainstream, and generally speaking, if users believe they're preventing something with AI, well, if you don’t believe that I’m not an AI, just add a ban on AI agents to MD, and they’ll simply refuse when you ask them to do something. Here’s an example: |
|
This is not a corporate repo, this is a community maintained project for the people, by the people. AI has absolutely no place in this project, you need to close this PR and try again without AI |
again AI has its wins, there are clear benefits to it, but just for next time usage, make sure to specify it and understand what its doing, a lot of what is in here doesn't make sense. mainstream usage of it consist of having a competency to back up the claims yourself on the changes. its frustrating to have people generate these and expect the reviewers to go through all of it themselves, find odd styling changes that are not required and ultimately have to deal with histories being changed due to them. I don't think it should be banned, but rather have some form of competency included when PRs are made from here on out, last thing someone wants is to review a ton of changes that don't play a role into the "feature", and just makes things a living hell for them to review back and forth because the AI either made mistakes, odd styling changes that are not required for said feature, or more. I am asking that in the future to try to have this level of integrity for PRs, last you want as an individual is to get flamed back and forth for this, let this be a lesson, not scrutiny. |
Okay, thanks. I understand your point of view. I certainly didn't mean any harm; I actually found the error on my own at first, and as for what happened next, I agree I was just following |
np, best of luck to ya, I'm sure you can make another PR. |
the good ending |
|
closing and re-pr, for myself |


Summary
Why
These are small runtime correctness fixes found while reviewing obvious failure paths. The changes avoid nil indexing, malformed net writes, stale controller/link state, and invalid client/server option data without changing normal tool behavior.
Validation