diff options
author | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2022-02-21 19:05:04 +0100 |
---|---|---|
committer | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2022-02-21 19:05:04 +0100 |
commit | 1e0d56346715e14f01b0684584adae42d9b17699 (patch) | |
tree | f450f88a081b52dc83979ee8c5cdd2edf9f1503a | |
parent | b0ba9468ee40dad636dc9c5cd7b53c24041390d8 (diff) |
[Net] Fix multi-peer path-only replication.
It used to check if a net_id was ever assigned to that node to detect
when to send the path confirm to the remote peer.
This is wrong, because the same net_id is shared for all the remote
peers, but sent one by one.
Instead we now check if it's either not assigned or if the assigned
net_id is a cache ID, and in that case ensure that the remote peer has
been notified.
This can be further improved by unifying the cache interface, but for
now it's a fast fix to get path-only sync to work.
-rw-r--r-- | scene/multiplayer/scene_replication_interface.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/scene/multiplayer/scene_replication_interface.cpp b/scene/multiplayer/scene_replication_interface.cpp index 25a704b37e..0764f136e4 100644 --- a/scene/multiplayer/scene_replication_interface.cpp +++ b/scene/multiplayer/scene_replication_interface.cpp @@ -350,11 +350,12 @@ void SceneReplicationInterface::_send_sync(int p_peer, uint64_t p_msec) { } if (size) { uint32_t net_id = rep_state->get_net_id(oid); - if (net_id == 0) { + if (net_id == 0 || (net_id & 0x80000000)) { // First time path based ID. NodePath rel_path = multiplayer->get_root_path().rel_path_to(sync->get_path()); int path_id = 0; multiplayer->send_object_cache(sync, rel_path, p_peer, path_id); + ERR_CONTINUE_MSG(net_id && net_id != (uint32_t(path_id) | 0x80000000), "This should never happen!"); net_id = path_id; rep_state->set_net_id(oid, net_id | 0x80000000); } |