Restrict client object destroying option (Networking)#46
Restrict client object destroying option (Networking)#46jusvit wants to merge 5 commits intoFacepunch:masterfrom
Conversation
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.
|
Resolves #850 |
|
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. |
|
@jusvit Can you run |
There was a problem hiding this comment.
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
ClientsCanDestroyObjectsproject setting with default valuetrueand grouped UI with other client permissions - Implemented
CanDestroyObjectsproperty onConnectionInfoandConnectionclasses - 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.
Should be good now |
|
This PR has been merged upstream. |
Adds a permission check to prevent clients from destroying objects they own unless explicitly allowed.
Introduces a new
CanDestroyObjectsflag on theConnectionInfoandConnectionclasses, 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.
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.