summaryrefslogtreecommitdiffstats
path: root/modules/multiplayer
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-08-08 10:16:31 +0200
committerRémi Verschelde <rverschelde@gmail.com>2024-08-08 10:16:31 +0200
commit03afb92efa18874da19f7fc185a32c005d20aa1d (patch)
treee8c110da0bc1203c275fd5501462e7dc02612282 /modules/multiplayer
parent32eb97fd2ae97ff2c8733d059d39ac4b23a3e739 (diff)
parentc5fa7354bb17ce41a292282a14c92eff3e2ba5ab (diff)
downloadredot-engine-03afb92efa18874da19f7fc185a32c005d20aa1d.tar.gz
Merge pull request #95194 from Faless/mp/fix_relay_negative_target
[MP] Fix relay protocol routing with negative targets
Diffstat (limited to 'modules/multiplayer')
-rw-r--r--modules/multiplayer/scene_multiplayer.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/modules/multiplayer/scene_multiplayer.cpp b/modules/multiplayer/scene_multiplayer.cpp
index 6694376b30..e245101eeb 100644
--- a/modules/multiplayer/scene_multiplayer.cpp
+++ b/modules/multiplayer/scene_multiplayer.cpp
@@ -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.