summaryrefslogtreecommitdiffstats
path: root/modules/multiplayer/scene_cache_interface.h
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2023-12-10 14:40:18 +0100
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2024-01-18 21:18:54 +0100
commit853df2895ad652fb9bbc4d4a38f33ccdc7ec8e54 (patch)
tree7f806e6498e559b04fed451e769ca47cf7a94683 /modules/multiplayer/scene_cache_interface.h
parent2ababdcc065e76decc12747a3c84e01f7bdc90dd (diff)
downloadredot-engine-853df2895ad652fb9bbc4d4a38f33ccdc7ec8e54.tar.gz
[MP] Handle cleanup of "scene cache" nodes
Make sure we delete the relevant ObjectID from the cache when the nodes are removed from tree.
Diffstat (limited to 'modules/multiplayer/scene_cache_interface.h')
-rw-r--r--modules/multiplayer/scene_cache_interface.h27
1 files changed, 13 insertions, 14 deletions
diff --git a/modules/multiplayer/scene_cache_interface.h b/modules/multiplayer/scene_cache_interface.h
index e63beb5f84..ab4a20c078 100644
--- a/modules/multiplayer/scene_cache_interface.h
+++ b/modules/multiplayer/scene_cache_interface.h
@@ -43,27 +43,26 @@ private:
SceneMultiplayer *multiplayer = nullptr;
//path sent caches
- struct PathSentCache {
- HashMap<int, bool> confirmed_peers;
- int id;
+ struct NodeCache {
+ int cache_id;
+ HashMap<int, int> recv_ids; // peer id, remote cache id
+ HashMap<int, bool> confirmed_peers; // peer id, confirmed
};
- //path get caches
- struct PathGetCache {
- struct NodeInfo {
- NodePath path;
- ObjectID instance;
- };
-
- HashMap<int, NodeInfo> nodes;
+ struct PeerInfo {
+ HashMap<int, ObjectID> recv_nodes; // remote cache id, ObjectID
+ HashSet<ObjectID> sent_nodes;
};
- HashMap<ObjectID, PathSentCache> path_send_cache;
- HashMap<int, PathGetCache> path_get_cache;
+ HashMap<ObjectID, NodeCache> nodes_cache;
+ HashMap<int, PeerInfo> peers_info;
int last_send_cache_id = 1;
+ void _remove_node_cache(ObjectID p_oid);
+ NodeCache &_track(Node *p_node);
+
protected:
- Error _send_confirm_path(Node *p_node, PathSentCache *psc, const List<int> &p_peers);
+ Error _send_confirm_path(Node *p_node, NodeCache &p_cache, const List<int> &p_peers);
public:
void clear();