Fix Multiplayer Spawner freeing node after client disconnected Issue #92359
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes an error that happens when freeing a node that was synced using a MultiplayerSpawner after a client disconnects. Closes #92358
When a client disconnects on
on_peer_change
it looks like the intention of the code was to remove the peer ID from the list of received ids of that node withnc->recv_ids.erase(p_id);
but what is actually in the code today isnc->recv_ids.erase(E.key);
which in this case is trying to erase theremote cache id
of the node from the list of received ids of the node, which doesn't really make sense since that is a list of peer ids that received that node.I'm assuming it was a mistake, this one line fix fixes it.
The error happens because since the id wasn't being removed from the list of recv_ids when the node was eventually freed it tried to get the peer_info for that id and failed since the peer at this point no longer exists, showing the error.