diff options
| author | mat <git@matdoes.dev> | 2025-02-22 23:01:54 +0000 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-02-22 23:01:54 +0000 |
| commit | 34f53baf85fb5c7163ec5d71a8ab9d45d3f271b6 (patch) | |
| tree | 7920fec1203e8e96463a142f5f6da6164e76e684 /azalea-world/src/container.rs | |
| parent | bdd2fc91e11e2896d8e1c7046df247e1075bd40d (diff) | |
| download | azalea-drasl-34f53baf85fb5c7163ec5d71a8ab9d45d3f271b6.tar.xz | |
update to rust edition 2024
Diffstat (limited to 'azalea-world/src/container.rs')
| -rw-r--r-- | azalea-world/src/container.rs | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/azalea-world/src/container.rs b/azalea-world/src/container.rs index f7f05a89..8648d19e 100644 --- a/azalea-world/src/container.rs +++ b/azalea-world/src/container.rs @@ -53,31 +53,34 @@ impl InstanceContainer { min_y: i32, default_registries: &RegistryHolder, ) -> Arc<RwLock<Instance>> { - if let Some(existing_lock) = self.instances.get(&name).and_then(|world| world.upgrade()) { - let existing = existing_lock.read(); - if existing.chunks.height != height { - error!( - "Shared dimension height mismatch: {} != {height}", - existing.chunks.height - ); + match self.instances.get(&name).and_then(|world| world.upgrade()) { + Some(existing_lock) => { + let existing = existing_lock.read(); + if existing.chunks.height != height { + error!( + "Shared dimension height mismatch: {} != {height}", + existing.chunks.height + ); + } + if existing.chunks.min_y != min_y { + error!( + "Shared world min_y mismatch: {} != {min_y}", + existing.chunks.min_y + ); + } + existing_lock.clone() } - if existing.chunks.min_y != min_y { - error!( - "Shared world min_y mismatch: {} != {min_y}", - existing.chunks.min_y - ); + _ => { + let world = Arc::new(RwLock::new(Instance { + chunks: ChunkStorage::new(height, min_y), + entities_by_chunk: HashMap::new(), + entity_by_id: IntMap::default(), + registries: default_registries.clone(), + })); + debug!("Added new instance {name}"); + self.instances.insert(name, Arc::downgrade(&world)); + world } - existing_lock.clone() - } else { - let world = Arc::new(RwLock::new(Instance { - chunks: ChunkStorage::new(height, min_y), - entities_by_chunk: HashMap::new(), - entity_by_id: IntMap::default(), - registries: default_registries.clone(), - })); - debug!("Added new instance {name}"); - self.instances.insert(name, Arc::downgrade(&world)); - world } } } |
