From f5751d65b13fbb5d219e9ffd2c5db43c6670a273 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Mon, 20 May 2019 01:00:31 +0200 Subject: [PATCH] Fix terrain not loading Former-commit-id: f9279878ab051c6083c4a1f5125531fe79151fb8 --- common/src/state.rs | 5 +++++ common/src/volumes/vol_map_2d.rs | 4 ++++ voxygen/src/menu/char_selection/mod.rs | 1 + voxygen/src/scene/terrain.rs | 4 ++++ voxygen/src/session.rs | 1 + 5 files changed, 15 insertions(+) diff --git a/common/src/state.rs b/common/src/state.rs index 8b9b4e7965..7397cc5d44 100644 --- a/common/src/state.rs +++ b/common/src/state.rs @@ -184,6 +184,11 @@ impl State { self.ecs.read_resource::() } + /// Get a writable reference to this state's terrain. + pub fn terrain_mut(&self) -> FetchMut { + self.ecs.write_resource::() + } + /// Insert the provided chunk into this state's terrain. pub fn insert_chunk(&mut self, key: Vec2, chunk: TerrainChunk) { if self diff --git a/common/src/volumes/vol_map_2d.rs b/common/src/volumes/vol_map_2d.rs index 79db65cee4..5b06479b7d 100644 --- a/common/src/volumes/vol_map_2d.rs +++ b/common/src/volumes/vol_map_2d.rs @@ -145,6 +145,10 @@ impl VolMap2d { self.chunks.get(&key) } + pub fn clear(&mut self) { + self.chunks.clear(); + } + pub fn remove(&mut self, key: Vec2) -> Option> { self.chunks.remove(&key) } diff --git a/voxygen/src/menu/char_selection/mod.rs b/voxygen/src/menu/char_selection/mod.rs index 2e1f5a3635..cec06a2b4a 100644 --- a/voxygen/src/menu/char_selection/mod.rs +++ b/voxygen/src/menu/char_selection/mod.rs @@ -45,6 +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(); while self.client.borrow().is_request_pending() || self.client.borrow().get_client_state() == Some(ClientState::Registered) diff --git a/voxygen/src/scene/terrain.rs b/voxygen/src/scene/terrain.rs index da8bd9ec82..8c3c7b0436 100644 --- a/voxygen/src/scene/terrain.rs +++ b/voxygen/src/scene/terrain.rs @@ -205,4 +205,8 @@ impl Terrain { renderer.render_terrain_chunk(&chunk.model, globals, &chunk.locals); } } + + pub fn clear(&mut self) { + self.chunks.clear(); + } } diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index 54d56a7f5b..239775cf28 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -115,6 +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(); // Load a few chunks. TODO: Remove this. /*