Fix chunk loading delay

Former-commit-id: b287ab5be22ae6e4d0b10b5010e592a7a514cacb
This commit is contained in:
timokoesters 2019-05-20 21:24:47 +02:00
parent f5751d65b1
commit e34a47d0d7
3 changed files with 10 additions and 3 deletions

View File

@ -137,6 +137,13 @@ impl Client {
&mut self.state
}
/// Remove all cached terrain
#[allow(dead_code)]
pub fn reset_terrain(&mut self) {
self.state.terrain_mut().clear();
self.pending_chunks.clear();
}
/// Get the player's entity.
#[allow(dead_code)]
pub fn entity(&self) -> EcsEntity {
@ -394,7 +401,7 @@ impl Client {
self.pending_state_request = false;
}
ServerMsg::ForceState(state) => {
self.client_state = Some(dbg!(state));
self.client_state = Some(state);
}
ServerMsg::Disconnect => {
self.client_state = None;

View File

@ -45,7 +45,7 @@ impl PlayState for CharSelectionState {
fn play(&mut self, _: Direction, global_state: &mut GlobalState) -> PlayStateResult {
// Set up an fps clock.
let mut clock = Clock::new();
self.client.borrow_mut().state_mut().terrain_mut().clear();
self.client.borrow_mut().reset_terrain();
while self.client.borrow().is_request_pending()
|| self.client.borrow().get_client_state() == Some(ClientState::Registered)

View File

@ -115,7 +115,7 @@ impl PlayState for SessionState {
// Set up an fps clock.
let mut clock = Clock::new();
self.client.borrow_mut().state_mut().terrain_mut().clear();
self.client.borrow_mut().reset_terrain();
// Load a few chunks. TODO: Remove this.
/*