diff options
author | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2023-03-28 09:30:58 +0200 |
---|---|---|
committer | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2023-05-24 05:21:41 +0200 |
commit | f1e0d50841930c46efb01d23b7dadbf6c5596353 (patch) | |
tree | a3e9fb45d58e7b6f37cd73fd89db159379b2888b /modules/multiplayer/scene_replication_interface.h | |
parent | f581f21dd61a8fb581b80d07755cdf60c95d146d (diff) | |
download | redot-engine-f1e0d50841930c46efb01d23b7dadbf6c5596353.tar.gz |
[MP] Implement "watched" properties.
Checked at "delta_interval" (default = every frame), synchronized
(reliably) if changes are detected.
Diffstat (limited to 'modules/multiplayer/scene_replication_interface.h')
-rw-r--r-- | modules/multiplayer/scene_replication_interface.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/modules/multiplayer/scene_replication_interface.h b/modules/multiplayer/scene_replication_interface.h index cf45db2138..0af45c16b4 100644 --- a/modules/multiplayer/scene_replication_interface.h +++ b/modules/multiplayer/scene_replication_interface.h @@ -62,6 +62,7 @@ private: struct PeerInfo { HashSet<ObjectID> sync_nodes; HashSet<ObjectID> spawn_nodes; + HashMap<ObjectID, uint64_t> last_watch_usecs; HashMap<uint32_t, ObjectID> recv_sync_ids; HashMap<uint32_t, ObjectID> recv_nodes; uint16_t last_sent_sync = 0; @@ -88,12 +89,17 @@ private: SceneMultiplayer *multiplayer = nullptr; PackedByteArray packet_cache; int sync_mtu = 1350; // Highly dependent on underlying protocol. + int delta_mtu = 65535; TrackedNode &_track(const ObjectID &p_id); void _untrack(const ObjectID &p_id); void _node_ready(const ObjectID &p_oid); - void _send_sync(int p_peer, const HashSet<ObjectID> p_synchronizers, uint16_t p_sync_net_time, uint64_t p_msec); + bool _verify_synchronizer(int p_peer, MultiplayerSynchronizer *p_sync, uint32_t &r_net_id); + MultiplayerSynchronizer *_find_synchronizer(int p_peer, uint32_t p_net_ida); + + void _send_sync(int p_peer, const HashSet<ObjectID> p_synchronizers, uint16_t p_sync_net_time, uint64_t p_usec); + void _send_delta(int p_peer, const HashSet<ObjectID> p_synchronizers, uint64_t p_usec, const HashMap<ObjectID, uint64_t> p_last_watch_usecs); Error _make_spawn_packet(Node *p_node, MultiplayerSpawner *p_spawner, int &r_len); Error _make_despawn_packet(Node *p_node, int &r_len); Error _send_raw(const uint8_t *p_buffer, int p_size, int p_peer, bool p_reliable); @@ -127,9 +133,16 @@ public: Error on_spawn_receive(int p_from, const uint8_t *p_buffer, int p_buffer_len); Error on_despawn_receive(int p_from, const uint8_t *p_buffer, int p_buffer_len); Error on_sync_receive(int p_from, const uint8_t *p_buffer, int p_buffer_len); + Error on_delta_receive(int p_from, const uint8_t *p_buffer, int p_buffer_len); bool is_rpc_visible(const ObjectID &p_oid, int p_peer) const; + void set_max_sync_packet_size(int p_size); + int get_max_sync_packet_size() const; + + void set_max_delta_packet_size(int p_size); + int get_max_delta_packet_size() const; + SceneReplicationInterface(SceneMultiplayer *p_multiplayer) { multiplayer = p_multiplayer; } |