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/materials/fire.rs | 33 ++++++++++++++++----------------- src/sim/materials/smoke.rs | 24 ++++++++++-------------- 2 files changed, 26 insertions(+), 31 deletions(-) (limited to 'src/sim/materials') diff --git a/src/sim/materials/fire.rs b/src/sim/materials/fire.rs index 3c686fe..97027d5 100644 --- a/src/sim/materials/fire.rs +++ b/src/sim/materials/fire.rs @@ -12,7 +12,7 @@ impl FireCellView for Cell { fn get_ticks_lived(self) -> u16 { self.data } - fn set_ticks_lived(&mut self, ticks: u16) -> () { + fn set_ticks_lived(&mut self, ticks: u16) { self.data = ticks; } // this could be a property of the material def, I think it's better here for now @@ -52,22 +52,21 @@ pub fn sim_update(ctx: &mut UpdateCtx) { } // 8 times in our lifespan, emit smoke - if ticks_lived % 30 == 0 { - if let Some(target) = ctx.get_cell(0, -1) - && target.material == MaterialId::Void - { - for (dx, dy) in [ - (0, -1), - (1 - ctx.seqno_parity as i32 * 2, 0), - (-1 + ctx.seqno_parity as i32 * 2, 0), - (0, 1), - ] { - if let Some(target) = ctx.get_cell(dx, dy) - && target.material == MaterialId::Void - { - ctx.set_cell(dx, dy, Cell::from_material(MaterialId::Smoke)); - break; - } + if ticks_lived.is_multiple_of(30) + && let Some(target) = ctx.get_cell(0, -1) + && target.material == MaterialId::Void + { + for (dx, dy) in [ + (0, -1), + (1 - ctx.seqno_parity as i32 * 2, 0), + (-1 + ctx.seqno_parity as i32 * 2, 0), + (0, 1), + ] { + if let Some(target) = ctx.get_cell(dx, dy) + && target.material == MaterialId::Void + { + ctx.set_cell(dx, dy, Cell::from_material(MaterialId::Smoke)); + break; } } } diff --git a/src/sim/materials/smoke.rs b/src/sim/materials/smoke.rs index 68f77ca..5240bc9 100644 --- a/src/sim/materials/smoke.rs +++ b/src/sim/materials/smoke.rs @@ -1,24 +1,20 @@ use rand::RngExt; -use crate::sim::{cell::Cell, materials::MaterialId, sim::UpdateCtx}; +use crate::sim::sim::UpdateCtx; #[inline] pub fn sim_update(ctx: &mut UpdateCtx) { // only allow upward movement some of the time to limit movement speed - if ctx.rng.random_range(0.0..1.0) > 0.8 { - if ctx.candidates_swap(&[(0, -1)]) { - return; - } + if ctx.rng.random_range(0.0..1.0) > 0.8 && ctx.candidates_swap(&[(0, -1)]) { + return; } // same for each horizontal direction - if ctx.rng.random_range(0.0..1.0) > 0.8 { - if ctx.candidates_swap(&[(1 - ctx.seqno_parity as i32 * 2, 0)]) { - return; - } - } - if ctx.rng.random_range(0.0..1.0) > 0.8 { - if ctx.candidates_swap(&[(-1 + ctx.seqno_parity as i32 * 2, 0)]) { - return; - } + if ctx.rng.random_range(0.0..1.0) > 0.8 + && ctx.candidates_swap(&[(1 - ctx.seqno_parity as i32 * 2, 0)]) + { + return; } + if ctx.rng.random_range(0.0..1.0) > 0.8 + && ctx.candidates_swap(&[(-1 + ctx.seqno_parity as i32 * 2, 0)]) + {} } -- cgit v1.3.1