[MP] Handle cleanup of "scene cache" nodes

Make sure we delete the relevant ObjectID from the cache when the nodes
are removed from tree.
This commit is contained in:
Fabio Alessandrelli
2023-12-10 14:40:18 +01:00
parent 2ababdcc06
commit 853df2895a
2 changed files with 109 additions and 82 deletions
+13 -14
View File
@@ -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();