summaryrefslogtreecommitdiffstats
path: root/modules/multiplayer/scene_cache_interface.h
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2024-03-29 22:35:03 +0100
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2024-03-29 23:11:04 +0100
commit4b973f451e4c5d929baeac7e86ebd3cb3e4c60a8 (patch)
tree37e649b99987a605f890bb3c7d5fe0be5f8a372c /modules/multiplayer/scene_cache_interface.h
parent29b3d9e9e538f0aa8effc8ad8bf19a2915292a89 (diff)
downloadredot-engine-4b973f451e4c5d929baeac7e86ebd3cb3e4c60a8.tar.gz
[MP] Gracefully handle cache confirmation of deleted nodes
It's possible that after sending a cached node reference (e.g. RPC or static MultiplayerSynchronizer) the reference node is removed from tree before the remote peer(s) can confirm the referenced path. To better detect that case, and avoid spamming errors when it happens, this commit modifies the multiplayer API caching protocol, to send the received ID instead of the Node path when sending the confirmation packet. **This is a breaking change** because it makes the runtime multiplayer protocol incompatible with previous versions of Godot.
Diffstat (limited to 'modules/multiplayer/scene_cache_interface.h')
-rw-r--r--modules/multiplayer/scene_cache_interface.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/modules/multiplayer/scene_cache_interface.h b/modules/multiplayer/scene_cache_interface.h
index ab4a20c078..73d6bde6ef 100644
--- a/modules/multiplayer/scene_cache_interface.h
+++ b/modules/multiplayer/scene_cache_interface.h
@@ -44,7 +44,7 @@ private:
//path sent caches
struct NodeCache {
- int cache_id;
+ int cache_id = 0;
HashMap<int, int> recv_ids; // peer id, remote cache id
HashMap<int, bool> confirmed_peers; // peer id, confirmed
};
@@ -55,6 +55,7 @@ private:
};
HashMap<ObjectID, NodeCache> nodes_cache;
+ HashMap<int, ObjectID> assigned_ids;
HashMap<int, PeerInfo> peers_info;
int last_send_cache_id = 1;