summaryrefslogtreecommitdiffstats
path: root/modules/multiplayer
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2023-12-17 12:27:24 +0100
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2023-12-17 12:27:24 +0100
commit4826c14d2042aa8044d9751d459aeab644bcb602 (patch)
treef1fa6e97a70968765fcaa4837bac4dc41eb6a1c7 /modules/multiplayer
parent2d0ee20ff30461b6b10f6fdfba87511a0ebc6642 (diff)
downloadredot-engine-4826c14d2042aa8044d9751d459aeab644bcb602.tar.gz
[MP] Fix complete_auth notifying the wrong peer
The SceneMultiplayer complete_auth method was not configuring the multiplayer peer correctly, causing it to potentially send the notification to the wrong peer, on the wrong channel, and/or with an incorrect transfer mode.
Diffstat (limited to 'modules/multiplayer')
-rw-r--r--modules/multiplayer/scene_multiplayer.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/modules/multiplayer/scene_multiplayer.cpp b/modules/multiplayer/scene_multiplayer.cpp
index 04de3dfb7f..665b246bc5 100644
--- a/modules/multiplayer/scene_multiplayer.cpp
+++ b/modules/multiplayer/scene_multiplayer.cpp
@@ -483,9 +483,14 @@ Error SceneMultiplayer::complete_auth(int p_peer) {
ERR_FAIL_COND_V(!pending_peers.has(p_peer), ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V_MSG(pending_peers[p_peer].local, ERR_FILE_CANT_WRITE, "The authentication session was already marked as completed.");
pending_peers[p_peer].local = true;
+
// Notify the remote peer that the authentication has completed.
uint8_t buf[2] = { NETWORK_COMMAND_SYS, SYS_COMMAND_AUTH };
+ multiplayer_peer->set_target_peer(p_peer);
+ multiplayer_peer->set_transfer_channel(0);
+ multiplayer_peer->set_transfer_mode(MultiplayerPeer::TRANSFER_MODE_RELIABLE);
Error err = _send(buf, 2);
+
// The remote peer already reported the authentication as completed, so admit the peer.
// May generate new packets, so it must happen after sending confirmation.
if (pending_peers[p_peer].remote) {