Commit 16e4214a authored by Capucho's avatar Capucho

Switch states instead of popping

parent 5fe95212
......@@ -78,8 +78,6 @@ pub struct Client {
loaded_distance: f32,
pending_chunks: HashMap<Vec2<i32>, Instant>,
disconnected: bool,
}
impl Client {
......@@ -166,8 +164,6 @@ impl Client {
loaded_distance: 0.0,
pending_chunks: HashMap::new(),
disconnected: false,
})
}
......@@ -722,7 +718,6 @@ impl Client {
);
},
ServerMsg::Disconnect => {
self.disconnected = true;
frontend_events.push(Event::Disconnect);
self.postbox.send_message(ClientMsg::Terminate);
},
......@@ -737,9 +732,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 }
......
......@@ -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(),
)));
......
......@@ -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
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment