Skip to content

Commit 03afb92

Browse files
committed
Merge pull request #95194 from Faless/mp/fix_relay_negative_target
[MP] Fix relay protocol routing with negative targets
2 parents 32eb97f + c5fa735 commit 03afb92

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

modules/multiplayer/scene_multiplayer.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -321,21 +321,24 @@ void SceneMultiplayer::_process_sys(int p_from, const uint8_t *p_packet, int p_p
321321
multiplayer_peer->set_transfer_mode(p_mode);
322322
multiplayer_peer->set_transfer_channel(p_channel);
323323
if (peer > 0) {
324+
// Single destination.
324325
multiplayer_peer->set_target_peer(peer);
325326
_send(data.ptr(), relay_buffer->get_position());
326327
} else {
328+
// Multiple destinations.
327329
for (const int &P : connected_peers) {
328330
// Not to sender, nor excluded.
329-
if (P == p_from || (peer < 0 && P != -peer)) {
331+
if (P == p_from || P == -peer) {
330332
continue;
331333
}
332334
multiplayer_peer->set_target_peer(P);
333335
_send(data.ptr(), relay_buffer->get_position());
334336
}
335-
}
336-
if (peer == 0 || peer == -1) {
337-
should_process = true;
338-
peer = p_from; // Process as the source.
337+
if (peer != -1) {
338+
// The server is one of the targets, process the packet with sender as source.
339+
should_process = true;
340+
peer = p_from;
341+
}
339342
}
340343
} else {
341344
ERR_FAIL_COND(p_from != 1); // Bug.

0 commit comments

Comments
 (0)