summaryrefslogtreecommitdiffstats
path: root/modules/multiplayer/scene_rpc_interface.cpp
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2023-09-26 20:27:53 +0200
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2023-10-10 14:42:48 +0200
commit61cf7d180cc6ac1be1f9cb1c7369b2cae5d99b25 (patch)
treeb1d4d6ad7d8bc3ca6f6d3e81f06867f9ddf862db /modules/multiplayer/scene_rpc_interface.cpp
parentd80ce0c52a097c35bb4d441e7a9c0a76e6342ba4 (diff)
downloadredot-engine-61cf7d180cc6ac1be1f9cb1c7369b2cae5d99b25.tar.gz
[MP] Optimize multiplayer NodePath caching
Only use paths during network transfer. Use ObjectID instead of NodePaths for storing the Node <-> NetID relations locally.
Diffstat (limited to 'modules/multiplayer/scene_rpc_interface.cpp')
-rw-r--r--modules/multiplayer/scene_rpc_interface.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/modules/multiplayer/scene_rpc_interface.cpp b/modules/multiplayer/scene_rpc_interface.cpp
index 48e1d13f9c..bf0a261bd8 100644
--- a/modules/multiplayer/scene_rpc_interface.cpp
+++ b/modules/multiplayer/scene_rpc_interface.cpp
@@ -443,15 +443,14 @@ void SceneRPCInterface::_send_rpc(Node *p_node, int p_to, uint16_t p_rpc_id, con
// Not all verified path, so send one by one.
// Append path at the end, since we will need it for some packets.
- NodePath from_path = multiplayer->get_root_path().rel_path_to(p_node->get_path());
- CharString pname = String(from_path).utf8();
+ CharString pname = String(multiplayer->get_root_path().rel_path_to(p_node->get_path())).utf8();
int path_len = encode_cstring(pname.get_data(), nullptr);
MAKE_ROOM(ofs + path_len);
encode_cstring(pname.get_data(), &(packet_cache.write[ofs]));
// Not all verified path, so check which needs the longer packet.
for (const int P : targets) {
- bool confirmed = multiplayer->get_path_cache()->is_cache_confirmed(from_path, P);
+ bool confirmed = multiplayer->get_path_cache()->is_cache_confirmed(p_node, P);
if (confirmed) {
// This one confirmed path, so use id.
encode_uint32(psc_id, &(packet_cache.write[1]));