[Net] Single rpc annotation. "sync" no longer part of mode.

- Move the "sync" property for RPCs to RPCConfig.

- Unify GDScript annotations into a single one:
  - `@rpc(master)` # default
  - `@rpc(puppet)`
  - `@rpc(any)` # former `@remote`

- Implement three additional `@rpc` options:
  - The second parameter is the "sync" option (which also calls the
    function locally when RPCing). One of "sync", "nosync".
  - The third parameter is the transfer mode (reliable, unreliable,
    ordered).
  - The third parameter is the channel (unused for now).
This commit is contained in:
Fabio Alessandrelli 2021-06-24 10:28:15 +02:00
parent 8b1c60c1a3
commit ddb68f76ff
17 changed files with 72 additions and 127 deletions

View file

@ -1165,15 +1165,11 @@ void GDScript::_init_rpc_methods_properties() {
while (cscript) {
// RPC Methods
for (Map<StringName, GDScriptFunction *>::Element *E = cscript->member_functions.front(); E; E = E->next()) {
if (E->get()->get_rpc_mode() != MultiplayerAPI::RPC_MODE_DISABLED) {
MultiplayerAPI::RPCConfig nd;
nd.name = E->key();
nd.rpc_mode = E->get()->get_rpc_mode();
// TODO
nd.transfer_mode = MultiplayerPeer::TRANSFER_MODE_RELIABLE;
nd.channel = 0;
if (-1 == rpc_functions.find(nd)) {
rpc_functions.push_back(nd);
MultiplayerAPI::RPCConfig config = E->get()->get_rpc_config();
if (config.rpc_mode != MultiplayerAPI::RPC_MODE_DISABLED) {
config.name = E->get()->get_name();
if (rpc_functions.find(config) == -1) {
rpc_functions.push_back(config);
}
}
}