Skip to content

Restrict client object destroying option (Networking)#46

Closed
jusvit wants to merge 5 commits intoFacepunch:masterfrom
dxura:feature/restrict_client_destroying
Closed

Restrict client object destroying option (Networking)#46
jusvit wants to merge 5 commits intoFacepunch:masterfrom
dxura:feature/restrict_client_destroying

Conversation

@jusvit
Copy link
Copy Markdown
Contributor

@jusvit jusvit commented Nov 27, 2025

Adds a permission check to prevent clients from destroying objects they own unless explicitly allowed.

Introduces a new CanDestroyObjects flag on the ConnectionInfo and Connection classes, controlled by a project setting.

This allows the host to grant specific clients the ability to destroy objects, improving security and control over the networked environment.

Notably this is ideal for games which lean into client authority, but don't want to let clients (maybe modified?) to destroy random game objects they have permission for, instead requiring the host to do it.

image

It's granted by default (for existing and new projects), follows the same schematics as the other options.

Aside from this change, I also adjusted some comments and added explicit warnings when a client tries to destroy something it doesn't have permission for.

I also grouped these options in the UI.

image

Adds a permission check to prevent clients from destroying objects they own unless explicitly allowed.

Introduces a new `CanDestroyObjects` flag on the `ConnectionInfo` and `Connection` classes, controlled by a project setting.

This allows the host to grant specific clients the ability to destroy objects, improving security and control over the networked environment.
@jusvit
Copy link
Copy Markdown
Contributor Author

jusvit commented Dec 7, 2025

Resolves #850

@kurozael
Copy link
Copy Markdown
Contributor

This is a good addition that makes sense. I'd like to add per-object permissions at some point in addition to these defaults, but for now this is okay. If clients are making objects such as projectiles, it makes sense they can control their lifecycle - this option would then prevent that functionality just so they can't destroy their player.

However, overall, it makes sense to have a global option for it as we have permissions for the other parts of an object's lifecycle.

@kurozael
Copy link
Copy Markdown
Contributor

@jusvit Can you run dotnet format please 👍

Copilot AI review requested due to automatic review settings January 16, 2026 06:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a new CanDestroyObjects permission flag to control whether clients can destroy networked objects they own. The feature introduces a project-level setting that defaults to true (maintaining backward compatibility) and can be configured per-connection after join.

Changes:

  • Added ClientsCanDestroyObjects project setting with default value true and grouped UI with other client permissions
  • Implemented CanDestroyObjects property on ConnectionInfo and Connection classes
  • Added server-side permission checks with detailed warning messages when unauthorized destroy attempts occur

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
NetworkingSettings.cs Added ClientsCanDestroyObjects setting with UI grouping and documentation fixes
Connection.cs Implemented CanDestroyObjects property following the pattern of existing permission properties
ConnectionInfoManager.cs Added CanDestroyObjects field with initialization, serialization, and deserialization support
SceneNetworkSystem.cs Added permission check and warning messages in OnObjectDestroy method

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread engine/Sandbox.Engine/Scene/Networking/SceneNetworkSystem.cs Outdated
Comment thread engine/Sandbox.Engine/Scene/Networking/SceneNetworkSystem.cs Outdated
@jusvit
Copy link
Copy Markdown
Contributor Author

jusvit commented Jan 16, 2026

@jusvit Can you run dotnet format please 👍

Should be good now

@kurozael kurozael added the triaged triaged pull-requests are replicated on the internal sbox repo label Jan 17, 2026
@sboxbot sboxbot added the accepted this pull request was accepted, hurrah! label Jan 19, 2026
@sboxbot
Copy link
Copy Markdown
Contributor

sboxbot commented Jan 19, 2026

This PR has been merged upstream.

@sboxbot sboxbot closed this Jan 19, 2026
@jusvit jusvit deleted the feature/restrict_client_destroying branch January 20, 2026 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accepted this pull request was accepted, hurrah! triaged triaged pull-requests are replicated on the internal sbox repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants