parse test chunk distance from config

This commit is contained in:
Snowiiii 2024-08-15 15:06:19 +02:00
parent ceb718d475
commit 21983824a3
2 changed files with 6 additions and 6 deletions

View File

@ -1,14 +1,14 @@
pub struct RadialIterator {
radius: i32,
radius: u32,
direction: usize,
current: (i32, i32),
step_size: i32,
steps_taken: i32,
steps_taken: u32,
steps_in_direction: i32,
}
impl RadialIterator {
pub fn new(radius: i32) -> Self {
pub fn new(radius: u32) -> Self {
RadialIterator {
radius,
direction: 0,

View File

@ -288,7 +288,7 @@ impl Server {
)
}
Server::spawn_test_chunk(client).await;
Server::spawn_test_chunk(client, self.base_config.view_distance as u32).await;
}
/// TODO: This definitly should be in world
@ -337,7 +337,7 @@ impl Server {
}
// TODO: do this in a world
async fn spawn_test_chunk(client: &mut Client) {
async fn spawn_test_chunk(client: &mut Client, distance: u32) {
let inst = std::time::Instant::now();
let (sender, mut chunk_receiver) = mpsc::channel(1024);
tokio::spawn(async move {
@ -346,7 +346,7 @@ impl Server {
"./world".parse().unwrap(),
);
level
.read_chunks(RadialIterator::new(7).collect(), sender)
.read_chunks(RadialIterator::new(distance).collect(), sender)
.await;
});