NetworkManager: Consolidated two if's in OnClientDisconnectInternal

This commit is contained in:
MrGadget1024 2023-11-24 18:23:28 -05:00
parent 7eb3dd3198
commit d8f06b2922

View File

@ -1283,11 +1283,18 @@ void OnClientDisconnectInternal()
// shutdown client // shutdown client
NetworkClient.Shutdown(); NetworkClient.Shutdown();
foreach (NetworkIdentity identity in NetworkServer.spawned.Values) // If we're in ServerOnly mode now, StopClient was called for host client.
identity.clientStarted = false; // We need to reset clientStarted to false so that when we return to
// Host mode, we properly respawn objects from StartClient again.
if (mode == NetworkManagerMode.ServerOnly)
{
foreach (NetworkIdentity identity in NetworkServer.spawned.Values)
identity.clientStarted = false;
// Exit here if we're now in ServerOnly mode (StopClient called in Host mode). // Exit here if we're now in ServerOnly mode (StopClient called in Host mode).
if (mode == NetworkManagerMode.ServerOnly) return; // This allows the server to keep running without the host client, keeping remote clients connected.
return;
}
// Get Network Manager out of DDOL before going to offline scene // Get Network Manager out of DDOL before going to offline scene
// to avoid collision and let a fresh Network Manager be created. // to avoid collision and let a fresh Network Manager be created.