mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix clear_terrain not changing Changes
Former-commit-id: da7b02939d6d0bc7dbef7d923fb880081f6e08aa
This commit is contained in:
parent
525af4c201
commit
f4434013db
@ -133,8 +133,8 @@ impl Client {
|
||||
|
||||
/// Remove all cached terrain
|
||||
#[allow(dead_code)]
|
||||
pub fn reset_terrain(&mut self) {
|
||||
self.state.terrain_mut().clear();
|
||||
pub fn clear_terrain(&mut self) {
|
||||
self.state.clear_terrain();
|
||||
self.pending_chunks.clear();
|
||||
}
|
||||
|
||||
|
@ -190,6 +190,18 @@ impl State {
|
||||
self.ecs.write_resource::<TerrainMap>()
|
||||
}
|
||||
|
||||
/// Removes every chunk of the terrain.
|
||||
pub fn clear_terrain(&mut self) {
|
||||
let keys = self.terrain_mut()
|
||||
.drain()
|
||||
.map(|(key, _)| key)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
for key in keys {
|
||||
self.remove_chunk(key);
|
||||
}
|
||||
}
|
||||
|
||||
/// Insert the provided chunk into this state's terrain.
|
||||
pub fn insert_chunk(&mut self, key: Vec2<i32>, chunk: TerrainChunk) {
|
||||
if self
|
||||
|
@ -6,7 +6,7 @@ use crate::{
|
||||
dyna::{Dyna, DynaErr},
|
||||
},
|
||||
};
|
||||
use std::{collections::HashMap, marker::PhantomData, sync::Arc};
|
||||
use std::{collections::{hash_map, HashMap}, marker::PhantomData, sync::Arc};
|
||||
use vek::*;
|
||||
|
||||
#[derive(Debug)]
|
||||
@ -149,6 +149,10 @@ impl<V: BaseVol, S: VolSize> VolMap2d<V, S> {
|
||||
self.chunks.clear();
|
||||
}
|
||||
|
||||
pub fn drain(&mut self) -> hash_map::Drain<Vec2<i32>, Arc<V>> {
|
||||
self.chunks.drain()
|
||||
}
|
||||
|
||||
pub fn remove(&mut self, key: Vec2<i32>) -> Option<Arc<V>> {
|
||||
self.chunks.remove(&key)
|
||||
}
|
||||
|
@ -45,7 +45,6 @@ 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().reset_terrain();
|
||||
|
||||
let mut current_client_state = self.client.borrow().get_client_state();
|
||||
while let ClientState::Pending | ClientState::Registered = current_client_state {
|
||||
|
@ -205,8 +205,4 @@ impl Terrain {
|
||||
renderer.render_terrain_chunk(&chunk.model, globals, &chunk.locals);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn clear(&mut self) {
|
||||
self.chunks.clear();
|
||||
}
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ impl PlayState for SessionState {
|
||||
|
||||
// Set up an fps clock.
|
||||
let mut clock = Clock::new();
|
||||
self.client.borrow_mut().reset_terrain();
|
||||
self.client.borrow_mut().clear_terrain();
|
||||
|
||||
// Game loop
|
||||
let mut current_client_state = self.client.borrow().get_client_state();
|
||||
|
Loading…
Reference in New Issue
Block a user