Fix clippy::branches_sharing_code in chunk loading

This commit is contained in:
ice_iix 2021-06-18 17:58:32 -07:00
parent 526dfa65b6
commit b145e1ad0e
1 changed files with 15 additions and 24 deletions

View File

@ -661,15 +661,12 @@ impl World {
let cpos = CPos(x, z); let cpos = CPos(x, z);
{ {
let chunk = if new { if new {
self.chunks.insert(cpos, Chunk::new(cpos)); self.chunks.insert(cpos, Chunk::new(cpos));
self.chunks.get_mut(&cpos).unwrap() } else if !self.chunks.contains_key(&cpos) {
} else { return Ok(());
if !self.chunks.contains_key(&cpos) { }
return Ok(()); let chunk = self.chunks.get_mut(&cpos).unwrap();
}
self.chunks.get_mut(&cpos).unwrap()
};
for i in 0..16 { for i in 0..16 {
if chunk.sections[i].is_none() { if chunk.sections[i].is_none() {
@ -816,15 +813,12 @@ impl World {
) -> Result<(), protocol::Error> { ) -> Result<(), protocol::Error> {
let cpos = CPos(x, z); let cpos = CPos(x, z);
{ {
let chunk = if new { if new {
self.chunks.insert(cpos, Chunk::new(cpos)); self.chunks.insert(cpos, Chunk::new(cpos));
self.chunks.get_mut(&cpos).unwrap() } else if !self.chunks.contains_key(&cpos) {
} else { return Ok(());
if !self.chunks.contains_key(&cpos) { }
return Ok(()); let chunk = self.chunks.get_mut(&cpos).unwrap();
}
self.chunks.get_mut(&cpos).unwrap()
};
// Block type array - whole byte per block // Block type array - whole byte per block
let mut block_types = [[0u8; 4096]; 16]; let mut block_types = [[0u8; 4096]; 16];
@ -1015,15 +1009,12 @@ impl World {
let cpos = CPos(x, z); let cpos = CPos(x, z);
{ {
let chunk = if new { if new {
self.chunks.insert(cpos, Chunk::new(cpos)); self.chunks.insert(cpos, Chunk::new(cpos));
self.chunks.get_mut(&cpos).unwrap() } else if !self.chunks.contains_key(&cpos) {
} else { return Ok(());
if !self.chunks.contains_key(&cpos) { }
return Ok(()); let chunk = self.chunks.get_mut(&cpos).unwrap();
}
self.chunks.get_mut(&cpos).unwrap()
};
for i in 0..16 { for i in 0..16 {
if chunk.sections[i].is_none() { if chunk.sections[i].is_none() {