From 670365dc1152101f294e5c2b07fce32e90393345 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Sun, 14 Apr 2024 14:26:58 +0100 Subject: client requests visible chunks!!! --- client/main.ha | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'client') diff --git a/client/main.ha b/client/main.ha index 9f43aaf..3279fb0 100644 --- a/client/main.ha +++ b/client/main.ha @@ -106,6 +106,8 @@ export fn main() void = { if (did_move) { packet_reader::send(conn, camera_pos: packet_reader::packet_position)!; + request_visible_chunks(pictures, conn, camera_pos); + }; const n = poll::poll(pollfd, poll::NONBLOCK)!; @@ -237,11 +239,17 @@ fn request_visible_chunks(pictures: []drawing::picture, conn: net::socket, camer for (let dx = 0i32; dx < 3; dx += 1) for (let dy = 0i32; dy < 3; dy += 1) { let world_pos = (x0+CHUNKSIZE*dx, y0+CHUNKSIZE*dy): pos; - fmt::printfln("investigating {},{}", world_pos.0, world_pos.1)!; + if (!is_picture_visible(camera_pos, world_pos)) { + fmt::printfln("invisible {},{}", world_pos.0, world_pos.1)!; + continue; + }; + fmt::printfln("visible {},{}, checking availability", world_pos.0, world_pos.1)!; match (find_chunk(pictures,world_pos)) { - case *drawing::picture => yield; + case *drawing::picture => + fmt::printfln("\talready got that one")!; + yield; case null => - fmt::printfln("requesting {},{}", world_pos.0, world_pos.1)!; + fmt::printfln("\trequesting {},{}", world_pos.0, world_pos.1)!; packet_reader::send(conn, world_pos: packet_reader::packet_reqchunk)!; }; }; -- cgit v1.2.3