fix: #2842 Revert "fix: Prevent recursion overflow when stopping (#2833)"

This reverts commit 32fdd5215f.
This commit is contained in:
vis2k 2021-07-20 11:40:29 +08:00
parent c3bd1f2798
commit 24033c101b

View File

@ -532,12 +532,9 @@ public void StopHost()
/// <summary>Stops the server from listening and simulating the game.</summary>
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()
/// <summary>Stops and disconnects the client.</summary>
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();