Fix retry after defeat

This commit is contained in:
Ben Calegari 2026-07-28 20:47:06 -07:00
parent a26d0acbfb
commit 726af6d379

View file

@ -2169,10 +2169,22 @@ namespace TD.UI
// Fallback: LobbyService isn't spawned (e.g. testing the gameplay
// scene standalone without the lobby flow). Hard-reload the scene.
Debug.LogWarning("[HUDController] LobbyService not found — falling back to scene reload.");
//
// Do NOT reload via NetworkManager.SceneManager here. Reloading the
// currently-active scene through NGO's networked scene manager in
// Single mode deadlocks: SceneEventProgress unloads the active scene
// then waits on a load-complete ack for the same scene handle it is
// mid-transition on, which never arrives — the main thread hangs
// (beachball). LoadSceneAsHost is safe only because it loads a
// *different* scene (Lobby). With no LobbyService there is no real
// multiplayer session worth preserving, so shut the host down and do
// a plain, non-networked Unity scene reload instead.
Debug.LogWarning("[HUDController] LobbyService not found — falling back to non-networked scene reload.");
string activeScene = SceneManager.GetActiveScene().name;
var nm = NetworkManager.Singleton;
if (nm != null && nm.IsServer && nm.SceneManager != null)
nm.SceneManager.LoadScene(SceneManager.GetActiveScene().name, LoadSceneMode.Single);
if (nm != null && nm.IsListening)
nm.Shutdown();
SceneManager.LoadScene(activeScene, LoadSceneMode.Single);
}
// Return to Main Menu: disconnect only this player. SessionFlow's