diff options
author | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2022-07-20 21:18:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-20 21:18:58 +0200 |
commit | 1cf7ebda501a1e0fe15d610bded7772324168b6e (patch) | |
tree | 102ff5f099b0e2ec99214849fe6c2f5ae96a1aa7 /scene/multiplayer/scene_cache_interface.cpp | |
parent | e1c50152a034e9a6605d113ff6956206caad3a26 (diff) | |
parent | ddee5f605018c77e92378b525bd23ba32fb1263a (diff) |
Merge pull request #62961 from Faless/mp/4.x_interest
Add peer visibility to MultiplayerSynchronizer.
Diffstat (limited to 'scene/multiplayer/scene_cache_interface.cpp')
-rw-r--r-- | scene/multiplayer/scene_cache_interface.cpp | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/scene/multiplayer/scene_cache_interface.cpp b/scene/multiplayer/scene_cache_interface.cpp index 7c271341db..79a7dc2d5a 100644 --- a/scene/multiplayer/scene_cache_interface.cpp +++ b/scene/multiplayer/scene_cache_interface.cpp @@ -187,18 +187,29 @@ bool SceneCacheInterface::is_cache_confirmed(NodePath p_path, int p_peer) { return F->value; } -bool SceneCacheInterface::send_object_cache(Object *p_obj, NodePath p_path, int p_peer_id, int &r_id) { +int SceneCacheInterface::make_object_cache(Object *p_obj) { Node *node = Object::cast_to<Node>(p_obj); - ERR_FAIL_COND_V(!node, false); + ERR_FAIL_COND_V(!node, -1); + NodePath for_path = multiplayer->get_root_path().rel_path_to(node->get_path()); // See if the path is cached. - PathSentCache *psc = path_send_cache.getptr(p_path); + PathSentCache *psc = path_send_cache.getptr(for_path); if (!psc) { // Path is not cached, create. - path_send_cache[p_path] = PathSentCache(); - psc = path_send_cache.getptr(p_path); + path_send_cache[for_path] = PathSentCache(); + psc = path_send_cache.getptr(for_path); psc->id = last_send_cache_id++; } - r_id = psc->id; + return psc->id; +} + +bool SceneCacheInterface::send_object_cache(Object *p_obj, int p_peer_id, int &r_id) { + Node *node = Object::cast_to<Node>(p_obj); + ERR_FAIL_COND_V(!node, false); + + r_id = make_object_cache(p_obj); + ERR_FAIL_COND_V(r_id < 0, false); + NodePath for_path = multiplayer->get_root_path().rel_path_to(node->get_path()); + PathSentCache *psc = path_send_cache.getptr(for_path); bool has_all_peers = true; List<int> peers_to_add; // If one is missing, take note to add it. @@ -233,7 +244,7 @@ bool SceneCacheInterface::send_object_cache(Object *p_obj, NodePath p_path, int } if (peers_to_add.size()) { - _send_confirm_path(node, p_path, psc, peers_to_add); + _send_confirm_path(node, for_path, psc, peers_to_add); } return has_all_peers; |