From 40e9d818195824749293dff3afcfdd5c1432adbe Mon Sep 17 00:00:00 2001 From: Kai Stevenson Date: Sun, 16 Aug 2026 11:00:02 -0700 Subject: lint --- src/sim/sim.rs | 52 ++++++++++++++++++++++++---------------------------- 1 file changed, 24 insertions(+), 28 deletions(-) (limited to 'src/sim/sim.rs') diff --git a/src/sim/sim.rs b/src/sim/sim.rs index 84c3126..b9f4b76 100644 --- a/src/sim/sim.rs +++ b/src/sim/sim.rs @@ -39,17 +39,13 @@ fn get_cell(chunks: &[Option<&mut Chunk>; 9], x: i32, y: i32) -> Option { let nc_x = x.rem_euclid(CHUNK_SIZE) as u8; let nc_y = y.rem_euclid(CHUNK_SIZE) as u8; - return if let Some(chunk) = &chunks[(dcx + 1 + (dcy + 1) * 3) as usize] { - Some(chunk.get_cell_at_local_position(nc_x, nc_y)) - } else { - None - }; + chunks[(dcx + 1 + (dcy + 1) * 3) as usize] + .as_ref() + .map(|chunk| chunk.get_cell_at_local_position(nc_x, nc_y)) } else { - if let Some(target) = &chunks[4] { - Some(target.get_cell_at_local_position(x as u8, y as u8)) - } else { - None - } + chunks[4] + .as_ref() + .map(|target| target.get_cell_at_local_position(x as u8, y as u8)) } } @@ -138,28 +134,28 @@ pub fn sim_tick_chunk(chunks: &mut [Option<&mut Chunk>; 9], seqno: u64) { let mut cell = get_cell(chunks, x, y).unwrap(); let material = cell.material.def(); - if let Some(update) = material.sim_update { - if cell.parity() == seqno_parity { - cell.flip_parity(); - // apply the flipped parity in case the sim target doesn't - set_cell(chunks, x, y, cell); + if let Some(update) = material.sim_update + && cell.parity() == seqno_parity + { + cell.flip_parity(); + // apply the flipped parity in case the sim target doesn't + set_cell(chunks, x, y, cell); - let mut update_ctx = UpdateCtx { - chunks, - seqno, - seqno_parity, + let mut update_ctx = UpdateCtx { + chunks, + seqno, + seqno_parity, - x, - y, - cell: &mut cell, - material, + x, + y, + cell: &mut cell, + material, - // TODO this is platform-dependent, will break for multiplayer - rng: &mut rng, - }; + // TODO this is platform-dependent, will break for multiplayer + rng: &mut rng, + }; - update(&mut update_ctx); - } + update(&mut update_ctx); } } } -- cgit v1.3.1