mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Remove post debugging
Former-commit-id: 4a82bf8b6178fb88d5a6ea93706fb4e97ac2256d
This commit is contained in:
parent
5e38eee8d4
commit
e4d6d96afc
@ -194,9 +194,9 @@ impl Client {
|
||||
|
||||
// Remove chunks that are too far from the player
|
||||
let mut chunks_to_remove = Vec::new();
|
||||
self.state.terrain().iter().for_each(|(k, _)| {
|
||||
if (chunk_pos - k).map(|e| e.abs()).reduce_max() > 3 {
|
||||
chunks_to_remove.push(k);
|
||||
self.state.terrain().iter().for_each(|(key, _)| {
|
||||
if (chunk_pos - key).map(|e| e.abs()).reduce_max() > 3 {
|
||||
chunks_to_remove.push(key);
|
||||
}
|
||||
});
|
||||
for key in chunks_to_remove {
|
||||
|
@ -212,7 +212,6 @@ impl<S: PostMsg, R: PostMsg> PostBox<S, R> {
|
||||
|
||||
// Try sending bytes through the TCP stream
|
||||
for _ in 0..100 {
|
||||
//println!("HERE! Outgoing len: {}", outgoing_chunks.len());
|
||||
match outgoing_chunks.pop_front() {
|
||||
Some(mut chunk) => match stream.write(&chunk) {
|
||||
Ok(n) => if n == chunk.len() {},
|
||||
@ -227,7 +226,6 @@ impl<S: PostMsg, R: PostMsg> PostBox<S, R> {
|
||||
},
|
||||
// Worker error
|
||||
Err(e) => {
|
||||
println!("SEND ERROR: {:?}", e);
|
||||
recv_tx.send(Err(e.into())).unwrap();
|
||||
break 'work;
|
||||
},
|
||||
@ -265,7 +263,6 @@ impl<S: PostMsg, R: PostMsg> PostBox<S, R> {
|
||||
match bincode::deserialize(&incoming_buf[8..len + 8]) {
|
||||
Ok(msg) => recv_tx.send(Ok(msg)).unwrap(),
|
||||
Err(err) => {
|
||||
println!("Invalid message: {:?}", err);
|
||||
recv_tx.send(Err(err.into())).unwrap()
|
||||
},
|
||||
}
|
||||
|
@ -194,13 +194,15 @@ impl Server {
|
||||
&self.state.ecs().read_storage::<comp::Player>(),
|
||||
&self.state.ecs().read_storage::<comp::phys::Pos>(),
|
||||
).join() {
|
||||
// TODO: Distance check
|
||||
// if self.state.terrain().key_pos(key)
|
||||
let chunk_pos = self.state.terrain().pos_key(pos.0.map(|e| e as i32));
|
||||
let dist = (chunk_pos - key).map(|e| e.abs()).reduce_max();
|
||||
|
||||
self.clients.notify(entity, ServerMsg::TerrainChunkUpdate {
|
||||
key,
|
||||
chunk: Box::new(chunk.clone()),
|
||||
});
|
||||
if dist < 4 {
|
||||
self.clients.notify(entity, ServerMsg::TerrainChunkUpdate {
|
||||
key,
|
||||
chunk: Box::new(chunk.clone()),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
self.state.insert_chunk(key, chunk);
|
||||
@ -209,7 +211,7 @@ impl Server {
|
||||
|
||||
// Remove chunks that are too far from players
|
||||
let mut chunks_to_remove = Vec::new();
|
||||
self.state.terrain().iter().for_each(|(k, _)| {
|
||||
self.state.terrain().iter().for_each(|(key, _)| {
|
||||
let mut min_dist = i32::MAX;
|
||||
|
||||
// For each player with a position, calculate the distance
|
||||
@ -218,12 +220,12 @@ impl Server {
|
||||
&self.state.ecs().read_storage::<comp::phys::Pos>(),
|
||||
).join() {
|
||||
let chunk_pos = self.state.terrain().pos_key(pos.0.map(|e| e as i32));
|
||||
let dist = (chunk_pos - k).map(|e| e.abs()).reduce_max();
|
||||
let dist = (chunk_pos - key).map(|e| e.abs()).reduce_max();
|
||||
min_dist = min_dist.min(dist);
|
||||
}
|
||||
|
||||
if min_dist > 3 {
|
||||
chunks_to_remove.push(k);
|
||||
chunks_to_remove.push(key);
|
||||
}
|
||||
});
|
||||
for key in chunks_to_remove {
|
||||
|
Loading…
x
Reference in New Issue
Block a user