-
Notifications
You must be signed in to change notification settings - Fork 7
Fix debugger not detaching when CPU entity is removed #73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
DerelictDrone
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works well, but in my testing detaching manually (by pressing R with the cpu tool) reports the detach message twice.
(first detached with no attached debugger, second attached, then detaching will produce two messages)
This is due to a second net send for invalidating the debugger within the stool's own file, present here:
wire-cpu/lua/wire/stools/cpu.lua
Lines 48 to 68 in 1113394
| if player:KeyDown(IN_SPEED) then | |
| if (trace.Entity:IsValid()) and | |
| (trace.Entity:GetClass() == "gmod_wire_cpu") then | |
| trace.Entity:SetMemoryModel(self:GetClientInfo("memorymodel"),self:GetClientInfo("customram"),self:GetClientInfo("customrom")) | |
| trace.Entity:FlashData({}) | |
| net.Start("CPULib.InvalidateDebugger") net.WriteUInt(0,2) net.Send(player) | |
| end | |
| else | |
| if (not trace.Entity:IsPlayer()) and | |
| (trace.Entity:IsValid()) and | |
| (trace.Entity:GetClass() == "gmod_wire_cpu") then | |
| CPULib.AttachDebugger(trace.Entity,player) | |
| CPULib.SendDebugData(trace.Entity.VM,nil,player) | |
| net.Start("CPULib.InvalidateDebugger") net.WriteUInt(2,2) net.Send(player) | |
| else | |
| CPULib.AttachDebugger(nil,player) | |
| net.Start("CPULib.InvalidateDebugger") net.WriteUInt(1,2) net.Send(player) | |
| end | |
| end | |
| return true | |
| end |
Once resolved, this should be ready for merge tomorrow.
|
I believe I've fixed it! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to clear this flag and on remove hook during detach if possible, as deleting the CPU after detaching your debugger reports that it was detached(again), after that we should be good assuming nothing else crops up
https://github.com/wiremod/wire-cpu/pull/73/files#diff-7ef44bc4870f2b9b65b05f458388a300de8f00377bfa7430d5e5b7e5026ce3b7R617-R623
|
Working on it |
|
I hope everthing is correct now. |
DerelictDrone
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and working as intended.
When a debugger is attached to a CPU entity, removing the entity does not currently detach the debugger. As a result, the debugger remains attached to a non-existent CPU, which can be confusing.
This PR ensures the debugger is properly detached when the CPU entity is removed, also creates a DetachDebugger method that removes the giant chunk of code in the original AttachDebugger method that was responsible for detaching it manually.