summaryrefslogtreecommitdiffstats
path: root/core/io/multiplayer_api.h
Commit message (Collapse)AuthorAgeFilesLines
* [Net] Move multiplayer to core subdir, split RPCManager.Fabio Alessandrelli2021-09-071-182/+0
| | | | | | | | | | | Move multiplayer classes to "core/multiplayer" subdir. Move the RPCConfig and enums (TransferMode, RPCMode) to a separate file (multiplayer.h), and bind them to the global namespace. Move the RPC handling code to its own class (RPCManager). Renames "get_rpc_sender_id" to "get_remote_sender_id".
* [Net] Rename RPC "puppet" to "auth" (authority). Drop "master".Fabio Alessandrelli2021-08-301-3/+2
| | | | | | | | | | | | | | | | | | | | | | This commit completely removes the RPC_MODE_MASTER ("master" keyword), and renames the RPC_MODE_PUPPET to RPC_MODE_AUTHORITY ("auth" keyword). This commit also renames the "Node.[get|set]_network_master" methods to "Node.[get|set]_network_authority". This commit also renames the RPC_MODE_REMOTE constant to RPC_MODE_ANY. RPC_MODE_MASTER in Godot 3.x meant that a given RPC would be callable by any puppet peer on the master, while RPC_MODE_PUPPET meant that it would be callable by the master on any puppet. Beside proving to be very confusing to the user (referring to where it could be called instead of who can call it) the RPC_MODE_MASTER is quite useless. It is almost the same as RPC_MODE_REMOTE (anyone can call) with the exception that the network master cannot. While this could be useful to check in some case, in such a function you would anyway need to check in code who is the caller via get_rpc_sender_id(), so adding the check there for those rare cases does not warrants a dedicated mode.
* [Net] Add state sync to replicator.Fabio Alessandrelli2021-08-181-0/+1
| | | | | | | | | | | | Like the spawn/despawn feature, it can be completely overridden with 2 custom callables. The callables will be called with the list of tracked objects. In SERVER mode, objects are automatically tracked, while in CUSTOM mode you can manually track them via `track`/`untrack` (but that's optional). The default sync only happens from server to client, with batch updates, over unreliable channel (but with custom ordering). The default sync will warn you, if your state representation gets too big.
* [Net] MultiplayerReplicator with initial state.Fabio Alessandrelli2021-08-181-38/+38
| | | | | | | | | | | | | | | | | | | | | Move the former "spawnables" functions to a dedicated MultiplayerReplicator class. Support custom overrides in replicator. Spawn/despawn messages can now contain a state. The state can be automatically encoded/decoded by passing the desired object properties to `spawnable_config`. You can use script properties to optimize the state representation. 2 Callables can be also specified to completely override the default implementation for sending and receiving the spawn/despawn event. (9 bytes overhead, and there's room for improvement here). When using a custom implementation `spawn` and `despawn` can be called with any Object, `send_spawn`/`send_despawn` can receive any Variant as a state, and the path is not required. Two new functions, `spawn` and `despawn`, convey the implementation independent method for requesting a spawn/despawn of an Object, while `send_spawn` and `send_despawn` represent the more low-level send event for a Variant to be used by the custom implementations.
* [Net] Basic extensible MultiplayerAPI spawn/despawn.Fabio Alessandrelli2021-08-091-0/+19
| | | | | | | | | | | | | | | | | | | | | | `PackedScene`s can be configured to be spawnable via a new `MultiplayerAPI.spawnable_config` method. They can be configured either to be spawned automatically when coming from the server or to always require verification. Another method, `MultiplayerAPI.send_spawn` lets you request a spawn on the remote peers. When a peer receive a spawn request: - If it comes from the server and the scene is configured as `SPAWN_MODE_SERVER`: - Spawn the scene (instantiate it, add it to tree). - Emit signal `network_spawn`. - Else: - Emit signal `network_spawn_request`. In a similar way, `despawn`s are handled automatically in `SPAWN_MODE_SERVER`. In `SPAWN_MODE_SERVER`, when a new client connects it will also receive, from the server all the spawned (and not yet despawned) instances.
* [Net] Implement RPC channels in MultiplayerAPI.Fabio Alessandrelli2021-07-301-1/+1
|
* [Net] Single `rpc` annotation. "sync" no longer part of mode.Fabio Alessandrelli2021-07-201-3/+1
| | | | | | | | | | | | | | | | - 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).
* [Net] Rename NetworkedMultiplayerPeer to MultiplayerPeer.Fabio Alessandrelli2021-07-121-6/+6
|
* Rename Reference to RefCountedPedro J. Estébanez2021-06-111-3/+3
|
* [Net] Refactor RPCs, remove RSETsFabio Alessandrelli2021-06-011-15/+30
| | | | | | | | | | In this PR: - Removed rset - rpc_config can now optionally configure transfer mode (reliable/unreliable/ordered) and channel (channels are not actually implemented yet.) - Refactor how the RPC id is computed to minimize the logic in Node and scripts that now only needs a single `get_rpc_methods` function.
* Update copyright statements to 2021Rémi Verschelde2021-01-011-2/+2
| | | | | | | | | | | | | | Happy new year to the wonderful Godot community! 2020 has been a tough year for most of us personally, but a good year for Godot development nonetheless with a huge amount of work done towards Godot 4.0 and great improvements backported to the long-lived 3.2 branch. We've had close to 400 contributors to engine code this year, authoring near 7,000 commit! (And that's only for the `master` branch and for the engine code, there's a lot more when counting docs, demos and other first-party repos.) Here's to a great year 2021 for all Godot users 🎆
* Merge pull request #40136 from Jummit/multiplayer-root-node-gettersFabio Alessandrelli2020-11-271-0/+1
|\ | | | | Add root_node as property of MultiplayerAPI
| * add root_node as property of MultiplayerAPIJummit2020-07-051-0/+1
| |
* | Remove empty lines around braces with the formatting scriptAaron Franke2020-11-161-1/+0
| |
* | Reorganized core/ directory, it was too fatty alreadyreduz2020-11-071-1/+1
|/ | | | | | -Removed FuncRef, since Callable makes it obsolete -Removed int_types.h as its obsolete in c++11+ -Changed color names code
* Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocksRémi Verschelde2020-05-141-1/+0
| | | | | | | | | | | | | | Which means that reduz' beloved style which we all became used to will now be changed automatically to remove the first empty line. This makes us lean closer to 1TBS (the one true brace style) instead of hybridating it with some Allman-inspired spacing. There's still the case of braces around single-statement blocks that needs to be addressed (but clang-format can't help with that, but clang-tidy may if we agree about it). Part of #33027.
* Port member initialization from constructor to declaration (C++11)Rémi Verschelde2020-05-141-3/+3
| | | | | | | | | | Using `clang-tidy`'s `modernize-use-default-member-init` check and manual review of the changes, and some extra manual changes that `clang-tidy` failed to do. Also went manually through all of `core` to find occurrences that `clang-tidy` couldn't handle, especially all initializations done in a constructor without using initializer lists.
* Style: Harmonize header guards to style guide [Core]Rémi Verschelde2020-03-251-3/+3
|
* Refactor ScriptDebugger.Fabio Alessandrelli2020-03-081-34/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | EngineDebugger is the new interface to access the debugger. It tries to be as agnostic as possible on the data that various subsystems can expose. It allows 2 types of interactions: - Profilers: A subsystem can register a profiler, assigning it a unique name. That name can be used to activate the profiler or add data to it. The registered profiler can be composed of up to 3 functions: - Toggle: called when the profiler is activated/deactivated. - Add: called whenever data is added to the debugger (via `EngineDebugger::profiler_add_frame_data`) - Tick: called every frame (during idle), receives frame times. - Captures: (Only relevant in remote debugger for now) A subsystem can register a capture, assigning it a unique name. When receiving a message, the remote debugger will check if it starts with `[prefix]:` and call the associated capture with name `prefix`. Port MultiplayerAPI, Servers, Scripts, Visual, Performance to the new profiler system. Port SceneDebugger and RemoteDebugger to the new capture system. The LocalDebugger also uses the new profiler system for scripts profiling.
* PoolVector is gone, replaced by VectorJuan Linietsky2020-02-181-1/+1
| | | | | Typed `PoolTypeArray` types are now renamed `PackedTypeArray` and are sugar for `Vector<Type>`.
* Remove deprecated sync and slave networking keywordsRémi Verschelde2020-02-131-2/+0
| | | | | | Those keywords were deprecated for 3.1 in #22087. Also fix token name for `TK_REMOTE`, should be "remote" like the keyword.
* Optmized data sent during RPC and RSet calls.Andrea Catania2020-02-121-5/+19
| | | | | | | | | | - Now is sent the method ID rather the full function name. - The passed IDs (Node and Method) are compressed so to use less possible space. - The variant (INT and BOOL) is now encoded and compressed so to use much less data. - Optimized RPCMode retrieval for GDScript functions. - Added checksum to assert the methods are the same across peers. This work has been kindly sponsored by IMVU.
* Update copyright statements to 2020Rémi Verschelde2020-01-011-2/+2
| | | | | | | | | | | Happy new year to the wonderful Godot community! We're starting a new decade with a well-established, non-profit, free and open source game engine, and tons of further improvements in the pipeline from hundreds of contributors. Godot will keep getting better, and we're looking forward to all the games that the community will keep developing and releasing with it.
* Add network profilerjfons2019-09-051-0/+34
|
* Some code changed with Clang-Tidyqarmin2019-06-261-1/+1
|
* Add object encoding param to serialization methodsFabio Alessandrelli2019-04-011-0/+4
| | | | | | | | | Network peers get_var/put_var File get_var/store_var GDScript/Mono/VisualScript bytes2var/var2bytes Add MultiplayerAPI.allow_object_decoding member which deprecates PacketPeer.allow_object_decoding. Break ABI compatibaility (API compatibility for GDNative).
* Update copyright statements to 2019Rémi Verschelde2019-01-011-2/+2
| | | | Happy new year to the wonderful Godot community!
* Clearly deprecate sync too in favor of remotesync.Fabio Alessandrelli2018-09-151-2/+2
| | | | | NOTE: This changes the RPC_MODE_* enum values. Games should be re-exported. GDNative rebuilt.
* Rename slave keyword to puppetFabio Alessandrelli2018-09-151-2/+3
| | | | | The slave keyword will still be available as deprecated in 3.1 but will be dropped from future releases.
* MultiplayerAPI::send_bytes transfer mode support.Fabio Alessandrelli2018-07-081-1/+1
| | | | | Added as extra parameter, allow you to specify which transfer mode to use for those specific bytes
* New sync RPC modes to match all combinationsFabio Alessandrelli2018-05-291-0/+3
|
* Refactor RPCMode enum and checksFabio Alessandrelli2018-05-291-0/+11
|
* Revert "RPCMode refactor, more sync modes"Max Hilbrunner2018-05-291-14/+0
|
* New sync RPC modes to match all combinationsFabio Alessandrelli2018-05-261-0/+3
|
* Refactor RPCMode enum and checksFabio Alessandrelli2018-05-261-0/+11
|
* Add missing copyright headersGuilherme Felipe2018-05-161-0/+30
|
* Allow sending raw bytes through MultiplayerAPIFabio Alessandrelli2018-05-121-0/+3
|
* Internal methods in MultiplayerAPI start with _Fabio Alessandrelli2018-05-081-5/+5
|
* Add new MultiplayerAPI classFabio Alessandrelli2018-03-031-0/+87
Handles all the high level networking stuff