fix(NetworkManager): Prevent client from calling ServerChangeScene (#3729)

- Throws error if server isn't active
- allows for changing to offline scene regardless
This commit is contained in:
MrGadget 2024-01-10 04:16:47 -05:00 committed by GitHub
parent 6445547aef
commit 6e0c4a66d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -850,6 +850,14 @@ public virtual void ServerChangeScene(string newSceneName)
return; return;
} }
// Throw error if called from client
// Allow changing scene while stopping the server
if (!NetworkServer.active && newSceneName != offlineScene)
{
Debug.LogError("ServerChangeScene can only be called on an active server.");
return;
}
// Debug.Log($"ServerChangeScene {newSceneName}"); // Debug.Log($"ServerChangeScene {newSceneName}");
NetworkServer.SetAllClientsNotReady(); NetworkServer.SetAllClientsNotReady();
networkSceneName = newSceneName; networkSceneName = newSceneName;