Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MP] Fix relay protocol routing with negative targets #95194

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions modules/multiplayer/scene_multiplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,21 +321,24 @@ void SceneMultiplayer::_process_sys(int p_from, const uint8_t *p_packet, int p_p
multiplayer_peer->set_transfer_mode(p_mode);
multiplayer_peer->set_transfer_channel(p_channel);
if (peer > 0) {
// Single destination.
multiplayer_peer->set_target_peer(peer);
_send(data.ptr(), relay_buffer->get_position());
} else {
// Multiple destinations.
for (const int &P : connected_peers) {
// Not to sender, nor excluded.
if (P == p_from || (peer < 0 && P != -peer)) {
if (P == p_from || P == -peer) {
continue;
}
multiplayer_peer->set_target_peer(P);
_send(data.ptr(), relay_buffer->get_position());
}
}
if (peer == 0 || peer == -1) {
should_process = true;
peer = p_from; // Process as the source.
if (peer != -1) {
// The server is one of the targets, process the packet with sender as source.
should_process = true;
peer = p_from;
}
}
} else {
ERR_FAIL_COND(p_from != 1); // Bug.
Expand Down
Loading