Merge branch 'timo-warnings-client' into 'master'

Timo warnings client

See merge request veloren/veloren!291
This commit is contained in:
Timo Koesters
2019-07-02 19:08:31 +00:00

View File

@ -85,7 +85,7 @@ impl Client {
thread_pool.set_num_threads((thread_pool.max_count() - 1).max(1)); thread_pool.set_num_threads((thread_pool.max_count() - 1).max(1));
// Set client-only components // Set client-only components
state let _ = state
.ecs_mut() .ecs_mut()
.write_storage() .write_storage()
.insert(entity, comp::AnimationInfo::default()); .insert(entity, comp::AnimationInfo::default());
@ -236,7 +236,7 @@ impl Client {
// Remove chunks that are too far from the player. // Remove chunks that are too far from the player.
let mut chunks_to_remove = Vec::new(); let mut chunks_to_remove = Vec::new();
self.state.terrain().iter().for_each(|(key, _)| { self.state.terrain().iter().for_each(|(key, _)| {
if (Vec2::from(chunk_pos) - Vec2::from(key)) if (chunk_pos - key)
.map(|e: i32| (e.abs() as u32).checked_sub(2).unwrap_or(0)) .map(|e: i32| (e.abs() as u32).checked_sub(2).unwrap_or(0))
.magnitude_squared() .magnitude_squared()
> view_distance.pow(2) > view_distance.pow(2)
@ -311,17 +311,14 @@ impl Client {
// 6) Update the server about the player's physics attributes. // 6) Update the server about the player's physics attributes.
if let ClientState::Character = self.client_state { if let ClientState::Character = self.client_state {
match ( if let (Some(pos), Some(vel), Some(ori)) = (
self.state.read_storage().get(self.entity).cloned(), self.state.read_storage().get(self.entity).cloned(),
self.state.read_storage().get(self.entity).cloned(), self.state.read_storage().get(self.entity).cloned(),
self.state.read_storage().get(self.entity).cloned(), self.state.read_storage().get(self.entity).cloned(),
) { ) {
(Some(pos), Some(vel), Some(ori)) => {
self.postbox self.postbox
.send_message(ClientMsg::PlayerPhysics { pos, vel, ori }); .send_message(ClientMsg::PlayerPhysics { pos, vel, ori });
} }
_ => {}
}
} }
// Output debug metrics // Output debug metrics
@ -377,15 +374,14 @@ impl Client {
vel, vel,
ori, ori,
action_state, action_state,
} => match self.state.ecs().entity_from_uid(entity) { } => {
Some(entity) => { if let Some(entity) = self.state.ecs().entity_from_uid(entity) {
self.state.write_component(entity, pos); self.state.write_component(entity, pos);
self.state.write_component(entity, vel); self.state.write_component(entity, vel);
self.state.write_component(entity, ori); self.state.write_component(entity, ori);
self.state.write_component(entity, action_state); self.state.write_component(entity, action_state);
} }
None => {} }
},
ServerMsg::TerrainChunkUpdate { key, chunk } => { ServerMsg::TerrainChunkUpdate { key, chunk } => {
self.state.insert_chunk(key, *chunk); self.state.insert_chunk(key, *chunk);
self.pending_chunks.remove(&key); self.pending_chunks.remove(&key);
@ -394,7 +390,10 @@ impl Client {
self.client_state = state; self.client_state = state;
} }
ServerMsg::StateAnswer(Err((error, state))) => { ServerMsg::StateAnswer(Err((error, state))) => {
warn!("StateAnswer: {:?}", error); warn!(
"StateAnswer: {:?}. Server thinks client is in state {:?}.",
error, state
);
} }
ServerMsg::ForceState(state) => { ServerMsg::ForceState(state) => {
self.client_state = state; self.client_state = state;
@ -463,7 +462,7 @@ impl Client {
.ecs() .ecs()
.read_storage::<comp::Player>() .read_storage::<comp::Player>()
.join() .join()
.map(|p| p.clone()) .cloned()
.collect() .collect()
} }
} }