From a945a872e9d6d6e2dfe3849d07a5d3d40312f3e0 Mon Sep 17 00:00:00 2001 From: David Woodruff Date: Mon, 29 Mar 2021 17:18:56 -0400 Subject: [PATCH] fixing issue where client disconnect boots everyone else --- .../Scripts/Client/Net/ClientGameNetPortal.cs | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/Assets/BossRoom/Scripts/Client/Net/ClientGameNetPortal.cs b/Assets/BossRoom/Scripts/Client/Net/ClientGameNetPortal.cs index 85af84629..d32ede252 100644 --- a/Assets/BossRoom/Scripts/Client/Net/ClientGameNetPortal.cs +++ b/Assets/BossRoom/Scripts/Client/Net/ClientGameNetPortal.cs @@ -63,18 +63,21 @@ private void OnConnectFinished(ConnectStatus status) private void OnDisconnectOrTimeout(ulong clientID) { - //On a client disconnect we want to take them back to the main menu. - //We have to check here in SceneManager if our active scene is the main menu, as if it is, it means we timed out rather than a raw disconnect; - if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name != "MainMenu") + if(clientID == MLAPI.NetworkManager.Singleton.LocalClientId ) { - // we're not at the main menu, so we obviously had a connection before... thus, we aren't in a timeout scenario. - // Just shut down networking and switch back to main menu. - MLAPI.NetworkManager.Singleton.Shutdown(); - SceneManager.LoadScene("MainMenu"); - } - else - { - NetworkTimedOut?.Invoke(); + //On a client disconnect we want to take them back to the main menu. + //We have to check here in SceneManager if our active scene is the main menu, as if it is, it means we timed out rather than a raw disconnect; + if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name != "MainMenu") + { + // we're not at the main menu, so we obviously had a connection before... thus, we aren't in a timeout scenario. + // Just shut down networking and switch back to main menu. + MLAPI.NetworkManager.Singleton.Shutdown(); + SceneManager.LoadScene("MainMenu"); + } + else + { + NetworkTimedOut?.Invoke(); + } } }