garrysmod-issues icon indicating copy to clipboard operation
garrysmod-issues copied to clipboard

GetAttachment data is corrupted by unreliable netmessages being sent

Open Raox2 opened this issue 1 year ago • 4 comments

Details

It seems as though sending unreliable netmessages to clients will cause GetAttachment data to get corrupted and sometimes show errorenous positions. This is reproducible in Sandbox.

This issue has been occuring since the 27th of May on the 64 bit branch, but DOES NOT occur on at the 21st of may.

image

Steps to reproduce

Code for reproduction

if SERVER then
 util.AddNetworkString("test")
  timer.Create("t", 0.05, 0, function()
    net.Start("test", true)
    net.Broadcast()
  end)
else
  net.Receive("test", function(ln)
    local vm = Entity(1):GetViewModel()
    if not IsValid(vm) then return end
    
    local att = vm:GetAttachment(1)
    if att then
    debugoverlay.Sphere(att.Pos, 12, 3, Color(0, 0, 255), true)
    end
    
    --Entity(1):EmitSound("NPC_Hunter.FlechetteShoot")
  end)
end
  1. set developer 1 for debugoverlay
  2. Place in lua/autorun
  3. Switch to SMG1 and fire
  4. Attachments will erroneously appear at center of map

Raox2 avatar Aug 05 '24 10:08 Raox2

I have tried rolling my GMod build back to March 15 2024 and February 20 2024 versions, and it appears to function identically there, so I don't think this is by any means a regression or changed behavior as you claim, so I don't know where you got your dates from.

Furthermore, from what I can see, the unreliable flag (or shooting in general) seems to have nothing to do with it.

Testing in Singleplayer, dev beta.

robotboy655 avatar Aug 05 '24 14:08 robotboy655

Testing in Singleplayer, dev beta.

Should be a local MP server, also on 64 bit

DiscordPTB_dcNnrLNBj5

I had a friend run through and attempt to reproduce it on different dates.

Raox2 avatar Aug 05 '24 14:08 Raox2

x86-64 from May 14, local multiplayer: image

it's not a new issue.

robotboy655 avatar Aug 05 '24 15:08 robotboy655

I have investigated it further a bit, and it appears to be related to bone positions for the viewmodel entity at point in time. It is evident by printing out vm:GetBoneMatrix(att.Bone):GetTranslation(). Don't have a fix yet, but it seems to be just related to a missing local to world transformation somewhere, or something along those lines.

robotboy655 avatar Aug 05 '24 18:08 robotboy655