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

server_disconnected emits on client when authentication is failed #95183

Open
Summersay415 opened this issue Aug 6, 2024 · 1 comment
Open

Comments

@Summersay415
Copy link
Contributor

Summersay415 commented Aug 6, 2024

Tested versions

  • Reproducible in: v4.0.beta17.official [c400205], v4.1.4.stable.official [fe0e8e5], v4.2.2.stable.official [15073af], v4.3.rc2.official [3978628]

System information

Godot v4.3.rc2 - Ubuntu 24.04 LTS 24.04 - X11 - GLES3 (Compatibility) - Mesa Intel(R) Graphics (ADL GT2) - 12th Gen Intel(R) Core(TM) i5-1235U (12 Threads)

Issue description

server_disconnected signal emits on client when authenticating is failed, and I think this is not correct, because connected_to_server doesn't emit.

Steps to reproduce

  1. Set authenticate callback which rejects clients with multiplayer.multiplayer_peer.disconnect_peer(<peer>) (if clients gets rejected with timeout, this also works).
  2. On one game instance, create server.
  3. On other game instance, try to connect.
  4. Observe both peer_authentication_failed and server_disconnected emitted on client.

Minimal reproduction project (MRP)

mrp.zip

  1. Run 2 instances.
  2. On first, click "create".
  3. On second, click "join".
  4. Observe both peer_authentication_failed and server_disconnected emitted on client (visible in console).
@RedMser
Copy link
Contributor

RedMser commented Aug 6, 2024

Maybe something like this would be enough? (Untested! Needs someone who's more familiar with the multiplayer code to have another look, and decide if this is considered a bug or not.)

diff --git a/modules/multiplayer/scene_multiplayer.cpp b/modules/multiplayer/scene_multiplayer.cpp
index 99aba680cc..0488d302e3 100644
--- a/modules/multiplayer/scene_multiplayer.cpp
+++ b/modules/multiplayer/scene_multiplayer.cpp
@@ -57,7 +57,7 @@ void SceneMultiplayer::_update_status() {
 		if (status == MultiplayerPeer::CONNECTION_DISCONNECTED) {
 			if (last_connection_status == MultiplayerPeer::CONNECTION_CONNECTING) {
 				emit_signal(SNAME("connection_failed"));
-			} else {
+			} else if (!pending_peers.has(get_unique_id())) {
 				emit_signal(SNAME("server_disconnected"));
 			}
 			clear();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants