aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2024-04-14 14:26:58 +0100
committerubq323 <ubq323@ubq323.website>2024-04-14 14:26:58 +0100
commit670365dc1152101f294e5c2b07fce32e90393345 (patch)
treed706b0bed06bf4780ec03a52eff30f61c875f789
parentad6b3f23824c4d613f42d7d171f1bd31e0edded8 (diff)
client requests visible chunks!!!
-rw-r--r--client/main.ha14
1 files changed, 11 insertions, 3 deletions
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)!;
};
};