diff --git a/client/src/lib.rs b/client/src/lib.rs index aa2447ce30..e071c566e5 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -77,8 +77,6 @@ pub struct Client { loaded_distance: f32, pending_chunks: HashMap, Instant>, - - disconnected: bool, } impl Client { @@ -165,8 +163,6 @@ impl Client { loaded_distance: 0.0, pending_chunks: HashMap::new(), - - disconnected: false, }) } @@ -703,7 +699,6 @@ impl Client { ); }, ServerMsg::Disconnect => { - self.disconnected = true; frontend_events.push(Event::Disconnect); self.postbox.send_message(ClientMsg::Terminate); }, @@ -718,9 +713,6 @@ impl Client { Ok(frontend_events) } - // Get's whether or not the client just disconnected - pub fn disconnected(&self) -> bool { self.disconnected } - /// Get the player's entity. pub fn entity(&self) -> EcsEntity { self.entity } diff --git a/voxygen/src/menu/char_selection/mod.rs b/voxygen/src/menu/char_selection/mod.rs index 0931126e37..23b43d7eb9 100644 --- a/voxygen/src/menu/char_selection/mod.rs +++ b/voxygen/src/menu/char_selection/mod.rs @@ -39,11 +39,6 @@ impl PlayState for CharSelectionState { // Set up an fps clock. let mut clock = Clock::start(); - // Check if we just disconnected, if so go to main menu - if self.client.borrow().disconnected() { - return PlayStateResult::Pop; - } - let mut current_client_state = self.client.borrow().get_client_state(); while let ClientState::Pending | ClientState::Registered = current_client_state { // Handle window events @@ -83,7 +78,7 @@ impl PlayState for CharSelectionState { char_data.body, char_data.tool, ); - return PlayStateResult::Push(Box::new(SessionState::new( + return PlayStateResult::Switch(Box::new(SessionState::new( global_state, self.client.clone(), ))); diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index 7e36d44543..c6de6e40e0 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -3,6 +3,7 @@ use crate::{ hud::{DebugInfo, Event as HudEvent, Hud}, i18n::{i18n_asset_key, VoxygenLocalization}, key_state::KeyState, + menu::char_selection::CharSelectionState, render::Renderer, scene::{camera, Scene, SceneData}, window::{Event, GameInput}, @@ -680,6 +681,13 @@ impl PlayState for SessionState { current_client_state = self.client.borrow().get_client_state(); } + if let ClientState::Registered = current_client_state { + return PlayStateResult::Switch(Box::new(CharSelectionState::new( + global_state, + self.client.clone(), + ))); + } + PlayStateResult::Pop }