diff --git a/voxygen/src/menu/main/client_init.rs b/voxygen/src/menu/main/client_init.rs index 82b920754c..239d7646bd 100644 --- a/voxygen/src/menu/main/client_init.rs +++ b/voxygen/src/menu/main/client_init.rs @@ -15,6 +15,7 @@ pub enum Error { NoAddress, // Parsing/host name resolution successful but could not connect ConnectionFailed(ClientError), + ClientCrashed, } // Used to asynchronusly parse the server address, resolve host names, and create the client (which involves establishing a connection to the server) @@ -31,7 +32,7 @@ impl ClientInit { let handle = Some(thread::spawn(move || { // Sleep the thread to wait for the single-player server to start up if wait { - thread::sleep(Duration::from_millis(250)); + thread::sleep(Duration::from_millis(500)); } // Parses ip address or resolves hostname // Note: if you use an ipv6 address the number after the last colon will be used as the port unless you use [] around the address @@ -85,7 +86,7 @@ impl ClientInit { match self.rx.try_recv() { Ok(result) => Some(result), Err(TryRecvError::Empty) => None, - Err(TryRecvError::Disconnected) => panic!("Thread panicked or already finished"), + Err(TryRecvError::Disconnected) => Some(Err(Error::ClientCrashed)), } } } diff --git a/voxygen/src/menu/main/mod.rs b/voxygen/src/menu/main/mod.rs index 417643863a..f87fd6128b 100644 --- a/voxygen/src/menu/main/mod.rs +++ b/voxygen/src/menu/main/mod.rs @@ -78,6 +78,7 @@ impl PlayState for MainMenuState { match err { InitError::BadAddress(_) | InitError::NoAddress => "Server not found", InitError::ConnectionFailed(_) => "Connection failed", + InitError::ClientCrashed => "Client crashed", } .to_string(), ); diff --git a/voxygen/src/menu/main/start_singleplayer.rs b/voxygen/src/menu/main/start_singleplayer.rs index c160439d04..841d876205 100644 --- a/voxygen/src/menu/main/start_singleplayer.rs +++ b/voxygen/src/menu/main/start_singleplayer.rs @@ -1,4 +1,5 @@ use std::net::SocketAddr; +use log::warn; use common::comp; use crate::{ menu::char_selection::CharSelectionState, singleplayer::Singleplayer, Direction, GlobalState, @@ -40,8 +41,11 @@ impl PlayState for StartSingleplayerState { let client = loop { match client_init.poll() { Some(Ok(client)) => break client, - // Should always work - Some(Err(err)) => {}, + // An error occured! + Some(Err(err)) => { + warn!("Failed to start singleplayer server: {:?}", err); + return PlayStateResult::Pop; + }, _ => {} } };