mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Use vd setting when creating client
Former-commit-id: b9a32c6b2f1a61a407991507c63ba7d708723410
This commit is contained in:
@ -105,7 +105,7 @@ impl Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_view_distance(&mut self, view_distance: u32) {
|
pub fn set_view_distance(&mut self, view_distance: u32) {
|
||||||
self.view_distance = Some(view_distance.max(5).min(25));
|
self.view_distance = Some(view_distance.max(1).min(25));
|
||||||
self.postbox
|
self.postbox
|
||||||
.send_message(ClientMsg::SetViewDistance(self.view_distance.unwrap())); // Can't fail
|
.send_message(ClientMsg::SetViewDistance(self.view_distance.unwrap())); // Can't fail
|
||||||
}
|
}
|
||||||
@ -230,9 +230,9 @@ impl Client {
|
|||||||
|
|
||||||
// Request chunks from the server.
|
// Request chunks from the server.
|
||||||
// TODO: This is really inefficient.
|
// TODO: This is really inefficient.
|
||||||
'outer: for dist in 0..view_distance as i32 {
|
'outer: for dist in 0..=view_distance as i32 {
|
||||||
for i in chunk_pos.x - dist..chunk_pos.x + dist + 1 {
|
for i in chunk_pos.x - dist..=chunk_pos.x + dist {
|
||||||
for j in chunk_pos.y - dist..chunk_pos.y + dist + 1 {
|
for j in chunk_pos.y - dist..=chunk_pos.y + dist {
|
||||||
let key = Vec2::new(i, j);
|
let key = Vec2::new(i, j);
|
||||||
if self.state.terrain().get_key(key).is_none()
|
if self.state.terrain().get_key(key).is_none()
|
||||||
&& !self.pending_chunks.contains_key(&key)
|
&& !self.pending_chunks.contains_key(&key)
|
||||||
|
@ -295,7 +295,7 @@ impl Server {
|
|||||||
.map(|e: i32| e.abs())
|
.map(|e: i32| e.abs())
|
||||||
.reduce_max() as u32;
|
.reduce_max() as u32;
|
||||||
|
|
||||||
if player.view_distance.map(|vd| dist < vd).unwrap_or(false) {
|
if player.view_distance.map(|vd| dist <= vd).unwrap_or(false) {
|
||||||
self.clients.notify(
|
self.clients.notify(
|
||||||
entity,
|
entity,
|
||||||
ServerMsg::TerrainChunkUpdate {
|
ServerMsg::TerrainChunkUpdate {
|
||||||
@ -329,6 +329,7 @@ impl Server {
|
|||||||
|
|
||||||
if player.view_distance.map(|vd| dist <= vd).unwrap_or(false) {
|
if player.view_distance.map(|vd| dist <= vd).unwrap_or(false) {
|
||||||
should_drop = false;
|
should_drop = false;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,10 @@ impl PlayState for MainMenuState {
|
|||||||
// Don't try to connect if there is already a connection in progress.
|
// Don't try to connect if there is already a connection in progress.
|
||||||
client_init = client_init.or(Some(ClientInit::new(
|
client_init = client_init.or(Some(ClientInit::new(
|
||||||
(server_address, DEFAULT_PORT, false),
|
(server_address, DEFAULT_PORT, false),
|
||||||
comp::Player::new(username.clone(), Some(10)),
|
comp::Player::new(
|
||||||
|
username.clone(),
|
||||||
|
Some(global_state.settings.graphics.view_distance),
|
||||||
|
),
|
||||||
false,
|
false,
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,10 @@ impl PlayState for StartSingleplayerState {
|
|||||||
|
|
||||||
let client_init = ClientInit::new(
|
let client_init = ClientInit::new(
|
||||||
(server_address.clone(), self.sock.port(), true),
|
(server_address.clone(), self.sock.port(), true),
|
||||||
comp::Player::new(username.clone(), Some(10)),
|
comp::Player::new(
|
||||||
|
username.clone(),
|
||||||
|
Some(global_state.settings.graphics.view_distance),
|
||||||
|
),
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user