From 24033c101b328bb46b4bada5a7105f81d304fce1 Mon Sep 17 00:00:00 2001 From: vis2k Date: Tue, 20 Jul 2021 11:40:29 +0800 Subject: [PATCH] fix: #2842 Revert "fix: Prevent recursion overflow when stopping (#2833)" This reverts commit 32fdd5215fb02f67935a4359ea285d3fba54772c. --- Assets/Mirror/Runtime/NetworkManager.cs | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/Assets/Mirror/Runtime/NetworkManager.cs b/Assets/Mirror/Runtime/NetworkManager.cs index a92d80c2b..0f2a6fa33 100644 --- a/Assets/Mirror/Runtime/NetworkManager.cs +++ b/Assets/Mirror/Runtime/NetworkManager.cs @@ -532,12 +532,9 @@ public void StopHost() /// Stops the server from listening and simulating the game. public void StopServer() { - // return if already stopped to avoid recursion deadlock - if (!isNetworkActive) + if (!NetworkServer.active) return; - //Debug.Log("NetworkManager StopServer"); - if (authenticator != null) { authenticator.OnServerAuthenticated.RemoveListener(OnServerAuthenticated); @@ -556,10 +553,10 @@ public void StopServer() SceneManager.MoveGameObjectToScene(gameObject, SceneManager.GetActiveScene()); #pragma warning restore 618 - isNetworkActive = false; - OnStopServer(); + //Debug.Log("NetworkManager StopServer"); + isNetworkActive = false; NetworkServer.Shutdown(); // set offline mode BEFORE changing scene so that FinishStartScene @@ -579,12 +576,6 @@ public void StopServer() /// Stops and disconnects the client. public void StopClient() { - // return if already stopped to avoid recursion deadlock - if (!isNetworkActive) - return; - - //Debug.Log("NetworkManager StopClient"); - if (authenticator != null) { authenticator.OnClientAuthenticated.RemoveListener(OnClientAuthenticated); @@ -603,10 +594,11 @@ public void StopClient() SceneManager.MoveGameObjectToScene(gameObject, SceneManager.GetActiveScene()); #pragma warning restore 618 - isNetworkActive = false; - OnStopClient(); + //Debug.Log("NetworkManager StopClient"); + isNetworkActive = false; + // shutdown client NetworkClient.Disconnect(); NetworkClient.Shutdown();