godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.11k stars 69 forks source link

Improve MultiplayerAPI to enable RPC filtering #5370

Open darthLeviN opened 1 year ago

darthLeviN commented 1 year ago

Describe the project you are working on

A game with multiplayer. it needs a reconnecting system, an authentication system. it relies on rpc calls and needs to filter these calls properly.

Describe the problem or limitation you are having in your project

Godot offers almost no control on rpc calls. you can't block certain rpc calls from reaching certain users.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Add a mechanism to filter rpc calls. also redirect failed rpc calls for more handling.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

I just have to mention when i say something like "disable rpc calls" i also mean rpc_id, reliable or unreliable. rset, reliable or unreliable

Changes to Node :

Implement a new Object type called Rpc_call with the properties below (this is just to give a gist of the idea):

Simimilarly implement a new Object type called Rset_call:

Changes to MultiplayerAPI :

A thing that i didn't cover is that i don't know if one should also disable rpc calls for peer_id = 1 (host itself) or just let them pass. maybe a variable could control that behavior if needed?

Also a flaw that rpc_meta has is that it will be copying the same data over and over so we have to use a data that's easy to copy to not have noticable performance drawbacks. a better approach would be to make the rpc calls more flexible with an extra argument to attach whatever we like. but that wouldn't be backwards compatible.

If this enhancement will not be used often, can it be worked around with a few lines of script?

Nope. It has to be built in.

Is there a reason why this should be core and not an add-on in the asset library?

It's one of the most important multiplayer features.

Faless commented 1 year ago

See this draft PR for a proposed system which suppress RPCs and replication until authentication completes: https://github.com/godotengine/godot/pull/67917 . Once the peers connects, the replication system already supports peer filtering (visibility), via the MultiplayerSynchronizer node, the RPC system likely need to be updated to respect that visibility (though it might get tricky in case of relayed peers, so it deserves some more investigation).