Facepunch / sbox-issues

175 stars 12 forks source link

`[Property]` on a `NetworkMode.Never` GameObject is attempted to be read by other players #6172

Open PolSpock opened 2 months ago

PolSpock commented 2 months ago

Describe the bug

Hi,

Adding a [Property] attribute to a GameObject whose NetworkMode is set to NetworkMode.Never will be attempted to be read by other players, triggering an Unknown GameObject c8401b65-398b-4d71-a9e6-511b3d4489f3 warning in the console.

To Reproduce

1) Download https://github.com/Facepunch/sbox-scenestaging 2) Edit NetworkTest.cs by adding the following code:

    [Property] public GameObject NeverNetworked { get; set; }
    [Property] public Gun ComponentIntoNeverNetworkedGameObject { get; set; }

    protected override void OnStart()
    {
        base.OnStart();

        if (IsProxy) return;

        NeverNetworked = new GameObject();
        NeverNetworked.Name = "NeverNetworked";
        NeverNetworked.Parent = GameObject;
        NeverNetworked.NetworkMode = NetworkMode.Never;

        ComponentIntoNeverNetworkedGameObject = NeverNetworked.Components.Create<Gun>();
    }

3) Play networking.scene and join with another user. Check the console and see the warning image 4) Remove the Property attribute from public GameObject NeverNetworked { get; set; } and restart: no error should occur.

Expected behavior

A GameObject set to NetworkMode.Never should not print an error even if the [Property] attribute is present

Media/Files

No response

Additional context

No response

kurozael commented 2 months ago

Yeah this was a fix actually to prevent deserialisation error I wanted to prove. I can make it silent...