diff --git a/Assets/Scripts/UI/NetwMenu/WaitingForLocalMMT.cs b/Assets/Scripts/UI/NetwMenu/WaitingForLocalMMT.cs index 0cea37ab41aaeacd1fd04bcd63379c5d003c20e5..8c15842741c81f6a62cfac0e99e3b8807b9ec7ec 100644 --- a/Assets/Scripts/UI/NetwMenu/WaitingForLocalMMT.cs +++ b/Assets/Scripts/UI/NetwMenu/WaitingForLocalMMT.cs @@ -23,30 +23,29 @@ void PrepareGame() { CommunicationEvents.ServerAdress = "http://" + CommunicationEvents.ServerAddressLocal; //ServerAddress needs the "http://" //UnityEngine.Debug.Log("StartMainMenu"); + // TODO: Display "Loading in progress" to the player SceneManager.LoadScene("MainMenu"); } } IEnumerator ServerRoutine() { - while (true) - { - yield return ServerSlots[ServerSlot.localServer].UpdateServerStatus(skipIfAlreadyChecked: false); - - // The address of the localServer currently cannot change, so it is never empty/illegal - // If this can happen in the future, this condition may not suffice - if (ServerSlots[ServerSlot.localServer].currentStatus == ServerStatus.online) - { - CommunicationEvents.ServerRunning = true; - PrepareGame(); - } + yield return ServerSlots[ServerSlot.localServer].UpdateServerStatus(skipIfAlreadyChecked: false); - //Wait for 2 seconds + // The address of the localServer currently cannot change, so it is never empty/illegal + // If this can happen in the future, this condition may not suffice + while (ServerSlots[ServerSlot.localServer].currentStatus != ServerStatus.online) + { + Debug.Log("Local MMT Server not ready yet\n Will try again in 2 sec."); yield return new WaitForSecondsRealtime(2f); - print("waiting"); + yield return ServerSlots[ServerSlot.localServer].UpdateServerStatus(skipIfAlreadyChecked: false); } - + Debug.Log("Preparing game now"); + CommunicationEvents.ServerRunning = true; + // Give Unity time to flush the debug log + yield return new WaitForSecondsRealtime(0.1f); + PrepareGame(); } public UnityWebRequest pingL()