From 3112486005758691676ba503fcff8da77cc4073c Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Fri, 12 Apr 2019 10:09:14 +0100 Subject: [PATCH] Added partial chunk loading, package section to workspace Cargo.toml Former-commit-id: 4164daf4ccbe6695f664a44d0fce0ee10df39b8d --- Cargo.toml | 6 ++++++ client/src/lib.rs | 4 ++++ common/src/volumes/vol_map.rs | 18 ++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 533a0add9c..437f7f5e71 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,9 @@ +[package] +name = "veloren" +description = "Veloren is an open-world, open-source multiplayer voxel RPG." +documentation = "https://docs.veloren.net" +repository = "https://www.gitlab.com/veloren/veloren" + [workspace] members = [ "common", diff --git a/client/src/lib.rs b/client/src/lib.rs index 1d5bdc1a00..c98a01b746 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -144,6 +144,10 @@ impl Client { // Handle new messages from the server frontend_events.append(&mut self.handle_new_messages()?); + self.state.terrain().iter().for_each(|(k, _)| { + println!("Chunk at {:?}", k); + }); + // Step 1 if let Some(ecs_entity) = self.player { // TODO: remove this diff --git a/common/src/volumes/vol_map.rs b/common/src/volumes/vol_map.rs index 507c009aea..fcf45d32cd 100644 --- a/common/src/volumes/vol_map.rs +++ b/common/src/volumes/vol_map.rs @@ -141,4 +141,22 @@ impl VolMap { pub fn pos_key(&self, pos: Vec3) -> Vec3 { Self::chunk_key(pos) } + + pub fn iter<'a>(&'a self) -> ChunkIter<'a, V, S, M> { + ChunkIter { + iter: self.chunks.iter(), + } + } +} + +pub struct ChunkIter<'a, V: Vox, S: VolSize, M> { + iter: std::collections::hash_map::Iter<'a, Vec3, Chunk>, +} + +impl<'a, V: Vox, S: VolSize, M> Iterator for ChunkIter<'a, V, S, M> { + type Item = (Vec3, &'a Chunk); + + fn next(&mut self) -> Option { + self.iter.next().map(|(k, c)| (*k, c)) + } }